arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2502.11089cs.CLcs.AIcs.LG
收藏

原生稀疏注意力:硬件对齐且可原生训练的稀疏注意力

Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attention

DeepSeek-AI(深度求索人工智能公司);Peking University(北京大学);University of Washington(华盛顿大学)
Jingyang Yuan, Huazuo Gao, Damai Dai, Junyu Luo, Liang Zhao, Zhengyan Zhang, Zhenda Xie, Y. X. Wei, Lean Wang, Zhiping Xiao, Yuqing Wang, Chong Ruan, Ming Zhang… 展开作者

Jingyang Yuan, Huazuo Gao, Damai Dai, Junyu Luo, Liang Zhao, Zhengyan Zhang, Zhenda Xie, Y. X. Wei, Lean Wang, Zhiping Xiao, Yuqing Wang, Chong Ruan, Ming Zhang, Wenfeng Liang, Wangding Zeng

AI总结:

本文提出NSA,一种硬件对齐且可原生训练的稀疏注意力机制,通过动态分层稀疏策略实现高效长上下文建模,在保持或超越全注意力性能的同时显著加速训练与推理。

摘要:

长上下文建模对于下一代语言模型至关重要,然而标准注意力机制的高计算成本带来了显著的计算挑战。稀疏注意力为提高效率同时保持模型能力提供了一个有前景的方向。我们提出了NSA,一种可原生训练的稀疏注意力机制,它融合了算法创新与硬件对齐优化,以实现高效的长上下文建模。NSA采用动态分层稀疏策略,结合粗粒度token压缩与细粒度token选择,以保留全局上下文感知和局部精度。我们的方法通过两个关键创新推进了稀疏注意力设计:(1)通过算术强度平衡的算法设计实现了显著的加速,并针对现代硬件进行了实现优化。(2)我们实现了端到端训练,在不牺牲模型性能的情况下减少了预训练计算。如图1所示,实验表明,使用NSA预训练的模型在通用基准、长上下文任务和基于指令的推理中保持或超越了全注意力模型。同时,NSA在64k长度序列的解码、前向传播和反向传播中,相较于全注意力实现了显著加速,验证了其在模型全生命周期中的效率。

英文摘要:

Long-context modeling is crucial for next-generation language models, yet the high computational cost of standard attention mechanisms poses significant computational challenges. Sparse attention offers a promising direction for improving efficiency while maintaining model capabilities. We present NSA, a Natively trainable Sparse Attention mechanism that integrates algorithmic innovations with hardware-aligned optimizations to achieve efficient long-context modeling. NSA employs a dynamic hierarchical sparse strategy, combining coarse-grained token compression with fine-grained token selection to preserve both global context awareness and local precision. Our approach advances sparse attention design with two key innovations: (1) We achieve substantial speedups through arithmetic intensity-balanced algorithm design, with implementation optimizations for modern hardware. (2) We enable end-to-end training, reducing pretraining computation without sacrificing model performance. As shown in Figure 1, experiments show the model pretrained with NSA maintains or exceeds Full Attention models across general benchmarks, long-context tasks, and instruction-based reasoning. Meanwhile, NSA achieves substantial speedups over Full Attention on 64k-length sequences across decoding, forward propagation, and backward propagation, validating its efficiency throughout the model lifecycle.

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

↑