Reproduce “Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attention” on OpenResearch
Turn your favorite coding agents into research agents that review literature, develop hypotheses, and run experiments.
Universal app for Apple silicon and Intel. Requires macOS 11 or later.
About this paper
Jingyang Yuan, Huazuo Gao, Damai Dai, Junyu Luo, Liang Zhao, Zhengyan Zhang, Zhenda Xie, Y. X. Wei and 7 more
NSA combines compressed summaries, selected full-resolution blocks, and a recent-token window through learned gates, with GPU-aligned kernels and training as part of the attention architecture. On ten LongBench subsets, its average is 0.469, versus 0.437 for Full Attention at a matched 2,560-token budget. At 64k, kernels are 9.0× faster forward and 6.0× backward; decode’s 11.6× is expected from memory-access estimates.
Key insights
- Attention scores exhibit blockwise clustering, allowing for efficient blockwise token selection that aligns with hardware memory access patterns.
- Integrating sparsity natively throughout the training process, rather than applying it post-hoc, is crucial for maintaining and even enhancing model performance.
- Hardware-aligned kernel design, especially for architectures with shared KV caches like GQA/MQA, is essential to translate theoretical FLOPs reduction into actual latency speedups.
Summary by alphaXiv.
Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.