arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.22300cs.LGcs.AI
收藏

通过特征稀疏性扩展注意力机制

Scaling Attention via Feature Sparsity

School of Electronic Engineering, Xidian University(西安电子科技大学电子工程学院);Stony Brook University(石溪大学);TUM(慕尼黑工业大学);MIT(麻省理工学院);Amazon AGI SF Lab(亚马逊AGI旧金山实验室)

Yan Xie, Tiansheng Wen, Tangda Huang, Bo Chen, Chenyu You, Stefanie Jegelka, Yifei Wang

AI总结:

本文提出Sparse Feature Attention (SFA),通过特征稀疏性降低注意力计算成本,提升处理超长上下文的能力,实验表明其在速度和资源消耗上优于现有方法。

摘要:

将Transformer扩展到超长上下文受限于自注意力的O(n²d)成本。现有方法通过局部窗口、核近似或token级稀疏性降低成本,但会降低准确性。本文探索特征稀疏性轴,提出Sparse Feature Attention (SFA),通过k稀疏编码降低计算成本至Θ(n²k²/d)。引入FlashSFA,使稀疏重叠直接计算而不生成密集分数矩阵。在GPT-2和Qwen3预训练中,SFA在速度提升2.5倍,FLOPs和KV-cache减少近50%。在合成和下游基准中,SFA在长上下文中保持检索精度和鲁棒性,优于短嵌入基线。这些结果证明特征级稀疏性是高效注意力的互补且未被探索的轴,使Transformer能扩展到数个数量级更长的上下文,质量损失最小。代码见https://github.com/YannX1e/Sparse-Feature-Attention。

英文摘要:

Scaling Transformers to ultra-long contexts is bottlenecked by the $O(n^2 d)$ cost of self-attention. Existing methods reduce this cost along the sequence axis through local windows, kernel approximations, or token-level sparsity, but these approaches consistently degrade accuracy. In this paper, we instead explore an orthogonal axis: feature sparsity. We propose Sparse Feature Attention (SFA), where queries and keys are represented as $k$-sparse codes that preserve high-dimensional expressivity while reducing the cost of attention from $Θ(n^2 d)$ to $Θ(n^2 k^2/d)$. To make this efficient at scale, we introduce FlashSFA, an IO-aware kernel that extends FlashAttention to operate directly on sparse overlaps without materializing dense score matrices. Across GPT-2 and Qwen3 pretraining, SFA matches dense baselines while improving speed by up to $2.5\times$ and reducing FLOPs and KV-cache by nearly 50\%. On synthetic and downstream benchmarks, SFA preserves retrieval accuracy and robustness at long contexts, outperforming short-embedding baselines that collapse feature diversity. These results establish feature-level sparsity as a complementary and underexplored axis for efficient attention, enabling Transformers to scale to orders-of-magnitude longer contexts with minimal quality loss. Code is available at https://github.com/YannX1e/Sparse-Feature-Attention.

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

↑