arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.11744cs.CLcs.LG
收藏

长上下文LLM的训练-推理一致分段执行

Training-Inference Consistent Segmented Execution for Long-Context LLMs

College of Computer Science, Inner Mongolia University, Hohhot 010021, China;National \& Local Joint Engineering Research Center of Intelligent Information Processing Technology for Mongolian, Hohhot 010021, China;Inner Mongolia Key Laboratory of Multilingual Artificial Intelligence Technology, Hohhot 010021, China;Thrust of Artificial Intelligence, The Hong Kong University of Science

Xianpeng Shang, Jiang Li, Zehua Duo, Qianyi Cai, Xiangdong Su

AI总结:

本文提出训练-推理一致的分段生成框架,通过统一训练和推理的分段前向执行语义,实现长上下文生成的高效与可扩展性。

摘要:

基于Transformer的大型语言模型在长上下文生成中面临严重的可扩展性挑战,由于全上下文注意力的计算和内存成本。在实际计算和内存限制下,许多高效的长上下文方法在推理时采用有界上下文或分段级执行,而继续在全上下文注意力下训练模型,导致训练和推理执行及状态转换语义不一致。基于此洞察,我们提出了一种训练-推理一致的分段生成框架,其中训练和推理遵循相同的分段级前向执行语义。在训练过程中,通过限制梯度传播到从前一个分段继承的KV状态,同时在前向传递中允许特定头部访问过去的KV状态而不参与梯度传播。在长上下文基准测试中,我们的方法在性能上与全上下文注意力相当,同时在与强大的高效推理基线相比,在延迟-内存权衡上具有竞争力,并在非常长的上下文长度下显著提高可扩展性(例如,128K时峰值预填内存比FlashAttention的全上下文注意力低约6倍)

英文摘要:

Transformer-based large language models face severe scalability challenges in long-context generation due to the computational and memory costs of full-context attention. Under practical computation and memory constraints, many inference-efficient long-context methods improve efficiency by adopting bounded-context or segment-level execution only during inference, while continuing to train models under full-context attention, resulting in a mismatch between training and inference execution and state-transition semantics. Based on this insight, we propose a training-inference consistent segment-level generation framework, in which training and inference follow the same segment-level forward execution semantics. During training, consistency with inference is enforced by restricting gradient propagation to KV states carried over from the immediately preceding segment, while permitting head-specific access to past KV states during the forward pass without involving them in gradient propagation. Across long-context benchmarks, our approach achieves performance comparable to full-context attention, while achieving competitive latency-memory trade-offs against strong inference-efficient baselines, and substantially improving scalability at very long context lengths (e.g., approximately 6x lower peak prefill memory at 128K compared to full-context attention with FlashAttention).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑