通过识别解码贡献稀疏性,实现预填充阶段15倍加速。
Accelerating Prefilling via Decoding-time Contribution Sparsity
- 发现预填充中部分注意力块虽有分数但对解码几乎无贡献,提出静态三角注意力模式。
- 在128K输入下,三角注意力计算速度提升15.3倍,远超动态稀疏方法的1.9~3.4倍。
- 无需训练,可与动态稀疏方法结合,进一步降低首字延迟6%~19%,适合大长文本场景。
大型语言模型(LLMs)在输入长度增长时面临二次方复杂度的注意力瓶颈,尤其在预填充阶段尤为突出。现有加速方法主要依赖注意力分数稀疏性,通过估计高分块并应用动态稀疏注意力来优化。本文揭示了预填充阶段另一未被利用的稀疏性——解码时间贡献稀疏性:许多注意力块在预填充中具有显著分数,但对后续解码几乎无贡献,经梯度分析验证。基于此,我们提出TriangleMix,一种无需训练的静态注意力模式,仅在部分层使用密集注意力,其余层切换为三角注意力。大量实验表明,TriangleMix相比全连接注意力几乎无性能损失,同时显著降低三角层的注意力开销。对于128K长度输入,三角注意力实现15.3倍的计算加速,远超典型动态稀疏方法的1.9~3.4倍。此外,TriangleMix可无缝融合动态稀疏方法,在仅用动态稀疏的基础上额外降低TTFT 6%~19%。代码已公开于https://aka.ms/TriangleMix。
原文摘要 · Abstract (English)
Large Language Models (LLMs) incur quadratic attention complexity with input length, creating a major time bottleneck in the prefilling stage. Existing acceleration methods largely exploit attention score sparsity by estimating blocks with high attention scores and applying dynamic sparse attention. In this work, we identify another untapped form of sparsity in the prefilling stage, namely decoding-time contribution sparsity, where many attention blocks exhibit nontrivial attention scores during prefilling yet contribute negligibly to subsequent decoding, as indicated by gradient-based analysis. Building on this observation, we propose TriangleMix, a training-free static attention pattern that uses dense attention in a subset of layers and switches to Triangle attention in the others. Extensive experiments show that TriangleMix preserves nearly lossless performance relative to dense attention while substantially reducing attention overhead in Triangle layers. For 128K inputs, Triangle attention achieves a 15.3x speedup in attention computation, significantly exceeding the acceleration of typical dynamic sparse methods (1.9x to 3.4x). Furthermore, TriangleMix can be seamlessly combined with dynamic sparsity approaches, delivering an additional 6% to 19% reduction in TTFT over using dynamic sparsity alone. Our code is released at https://aka.ms/TriangleMix.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。