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

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Yuan, Jingyang, Gao, Huazuo, Dai, Damai, Luo, Junyu, Zhao, Liang, Zhang, Zhengyan, Xie, Zhenda, Wei, Y. X., Wang, Lean, Xiao, Zhiping, Wang, Yuqing, Ruan, Chong, Zhang, Ming, Liang, Wenfeng, Zeng, Wangding
Natura: Preprint
Pubblicazione: 2025
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866916632592384000
author Yuan, Jingyang
Gao, Huazuo
Dai, Damai
Luo, Junyu
Zhao, Liang
Zhang, Zhengyan
Xie, Zhenda
Wei, Y. X.
Wang, Lean
Xiao, Zhiping
Wang, Yuqing
Ruan, Chong
Zhang, Ming
Liang, Wenfeng
Zeng, Wangding
author_facet Yuan, Jingyang
Gao, Huazuo
Dai, Damai
Luo, Junyu
Zhao, Liang
Zhang, Zhengyan
Xie, Zhenda
Wei, Y. X.
Wang, Lean
Xiao, Zhiping
Wang, Yuqing
Ruan, Chong
Zhang, Ming
Liang, Wenfeng
Zeng, Wangding
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2502_11089
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attention
Yuan, Jingyang
Gao, Huazuo
Dai, Damai
Luo, Junyu
Zhao, Liang
Zhang, Zhengyan
Xie, Zhenda
Wei, Y. X.
Wang, Lean
Xiao, Zhiping
Wang, Yuqing
Ruan, Chong
Zhang, Ming
Liang, Wenfeng
Zeng, Wangding
Computation and Language
Artificial Intelligence
Machine Learning
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.
title Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attention
topic Computation and Language
Artificial Intelligence
Machine Learning
url https://arxiv.org/abs/2502.11089