Large deep learning models have achieved impressive performance across a range of applications. However, their large memory requirements, including parameter memory and activation memory, have become a significant challenge for their practical serving. While existing methods mainly address parameter memory, the importance of activation memory has been overlooked. Especially for long input sequences, activation memory is expected to experience a significant exponential growth as the length of sequences increases. In this approach, we propose AutoChunk, an automatic and adaptive compiler system that efficiently reduces activation memory for long sequence inference by chunk strategies. The proposed system generates chunk plans by optimizing through multiple stages. In each stage, the chunk search pass explores all possible chunk candidates and the chunk selection pass identifies the optimal one. At runtime, AutoChunk employs code generation to automatically apply chunk strategies. The experiments demonstrate that AutoChunk can reduce over 80\% of activation memory while maintaining speed loss within 10%, extend max sequence length by 3.2x to 11.7x, and outperform state-of-the-art methods by a large margin.
翻译:大型深度学习模型已在诸多应用中展现出卓越性能。然而,其庞大的内存需求(包括参数内存与激活内存)已成为实际部署中的重大挑战。现有方法主要关注参数内存优化,而激活内存的重要性长期被忽视。尤其对于长输入序列,激活内存将随序列长度呈指数级增长。本文提出AutoChunk——一种自动自适应编译器系统,通过分块策略高效降低长序列推理过程中的激活内存消耗。该系统通过多阶段优化生成分块方案:每个阶段内,分块搜索过程遍历所有候选分块方案,分块选择过程则确定最优解。运行时,AutoChunk通过代码生成自动应用分块策略。实验表明,AutoChunk可减少80%以上的激活内存,同时保持速度损失在10%以内,将最大序列长度扩展3.2倍至11.7倍,并以显著优势超越当前最优方法。