Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attention
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

TL;DR
NSA introduces a hardware-aligned, trainable sparse attention mechanism that significantly speeds up long-context modeling in language models while maintaining or improving performance, enabling efficient training and inference.
Contribution
The paper presents NSA, a novel sparse attention method combining hierarchical strategies and hardware optimizations for efficient, end-to-end trainable long-context modeling.
Findings
NSA achieves substantial speedups on 64k sequences.
Models pretrained with NSA match or outperform full attention models.
NSA reduces pretraining computation without performance loss.
Abstract
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
Taxonomy
TopicsAdvanced Neural Network Applications · Stochastic Gradient Optimization Techniques
MethodsSoftmax · Attention Is All You Need
