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可减少超过80%的激活内存,同时将速度损失控制在10%以内,将最大序列长度扩展3.2至11.7倍,并以显著优势超越现有最优方法。