arXiv:2505.11254cs.LG2025-05NeurIPS被引 7

通过修正稀疏注意力的分布偏移,显著提升长序列推理速度与精度。

Delta Attention: Fast and Accurate Sparse Attention Inference by Delta Correction

  • 提出增量校正机制,缓解稀疏计算导致的输出分布偏移。
  • 在131K RULER上恢复88%全注意力精度,平均性能提升36个百分点。
  • 兼容任意稀疏注意力方法,适合追求高速高精度推理的场景。

Transformer 的注意力机制具有二次复杂度,导致长序列推理成本高昂。然而注意力矩阵普遍稀疏,表明可省略部分计算以实现高效推理。现有稀疏注意力方法虽降低计算负担,但常伴随性能下降。我们发现性能下降原因之一是稀疏计算引发注意力输出的分布偏移,导致解码阶段查询与预填充阶段关键键不匹配。为此,我们提出一种简单、新颖且有效的分布校正方法,使稀疏注意力输出分布更接近全注意力。该方法可叠加于任意稀疏注意力之上,在滑动窗口+锚点注意力基础上应用时,于131K RULER基准上恢复88%全注意力精度,平均性能提升36个百分点,仅引入少量开销。模型保持约98.5%的稀疏性,处理100万令牌预填充时,相较Flash Attention 2提速32倍。

原文摘要 · Abstract (English)

The attention mechanism of a transformer has a quadratic complexity, leading to high inference costs and latency for long sequences. However, attention matrices are mostly sparse, which implies that many entries may be omitted from computation for efficient inference. Sparse attention inference methods aim to reduce this computational burden; however, they also come with a troublesome performance degradation. We discover that one reason for this degradation is that the sparse calculation induces a distributional shift in the attention outputs. The distributional shift causes decoding-time queries to fail to align well with the appropriate keys from the prefill stage, leading to a drop in performance. We propose a simple, novel, and effective procedure for correcting this distributional shift, bringing the distribution of sparse attention outputs closer to that of quadratic attention. Our method can be applied on top of any sparse attention method, and results in an average 36%pt performance increase, recovering 88% of quadratic attention accuracy on the 131K RULER benchmark when applied on top of sliding window attention with sink tokens while only adding a small overhead. Our method can maintain approximately 98.5% sparsity over full quadratic attention, making our model 32 times faster than Flash Attention 2 when processing 1M token prefills.

注意力机制稀疏推理加速分布式校正

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。