AdaSplash-2加速稀疏注意力,让长文本训练更快更高效
AdaSplash-2: Faster Differentiable Sparse Attention

- 用动态直方图快速初始化注意力归一化参数,减少迭代次数至1-2次
- 在超过60%块稀疏度下,训练速度媲美甚至超越FlashAttention-2
- 适合需要长序列建模的场景,如文档理解、超长文本生成
稀疏注意力被提出以缓解Transformer中二次复杂度的瓶颈。其中,α-entmax注意力是一种可微分的稀疏替代方案,能实现输入相关的稀疏性,但因计算归一化常数τ的开销大而落后于softmax。本文提出AdaSplash-2,通过新颖的基于直方图的初始化方法,将计算τ所需的迭代次数降至通常1-2次。核心思想是在运行时动态计算注意力分数粗略直方图并存储在片上SRAM中,从而获得更准确的初始化,实现快速前向与反向传播。结合一种零块跳过的稀疏感知GPU实现,当块稀疏度中等至高(如>60%)时,训练每步时间与FlashAttention-2持平或更优,这在长上下文长度下常见。在下游任务中,使用该高效α-entmax注意力训练的模型,在短上下文下达到softmax基线性能,在长上下文设置下取得显著提升。
原文摘要 · Abstract (English)
Sparse attention has been proposed as a way to alleviate the quadratic cost of transformers, a central bottleneck in long-context training. A promising line of work is $α$-entmax attention, a differentiable sparse alternative to softmax that enables input-dependent sparsity yet has lagged behind softmax due to the computational overhead necessary to compute the normalizer $τ$. In this paper, we introduce AdaSplash-2, which addresses this limitation through a novel histogram-based initialization that reduces the number of iterations needed to compute $τ$ to typically 1--2. The key idea is to compute a coarse histogram of attention scores on the fly and store it in on-chip SRAM, yielding a more accurate initialization that enables fast forward and backward computation. Combined with a sparsity-aware GPU implementation that skips zero blocks with low overhead, AdaSplash-2 matches or improves per-step training time relative to FlashAttention-2 when block sparsity is moderate-to-high (e.g., $>$60\%), which often occurs at long-context lengths. On downstream tasks, models trained with our efficient $α$-entmax attention match softmax baselines at short-context lengths and achieve substantial gains in long-context settings.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。