[2502.11089] Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attention
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 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.
Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attention Jingyang Yuan∗1,2 , Huazuo Gao1 , Damai Dai1 , Junyu Luo2 , Liang Zhao1 , Zhengyan Zhang1 , Zhenda Xie1 , Y. X. Wei1 , Lean Wang1 , Zhiping Xiao3 , Yuqing Wang1 , Chong Ruan1 , Ming Zhang2 , Wenfeng Liang1 , Wangding Zeng1…
related reading
- 2502.11089arxiv.org
- [2205.14135] FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenessarxiv.org
- [2604.20920] Simplified Sparse Attention via Gist Tokensarxiv.org
- [2603.23516] MSA: Memory Sparse Attention for Efficient End-to-End Memory Model Scaling to 100M Tokensarxiv.org
- Sparse Attention Post-Training for Mechanistic Interpretabilityarxiv.org
- A Survey on Sparse Autoencoders: Interpreting the Internal Mechanisms of Large Language Modelsarxiv.org
- [2512.23675] End-to-End Test-Time Training for Long Contextarxiv.org
- Sparse Autoencoders Find Highly Interpretable Features in Language Modelsarxiv.org
- [2501.00663] Titans: Learning to Memorize at Test Timearxiv.org
- How Attention Got So Efficient [GQA/MLA/DSA]youtube.com
- Language Models Can Control Their Own Attentionarxiv.org
- Log-Linear Attentionarxiv.org