Sparse Attention: Unlocking Million-Token Contexts
Sparse attention mechanisms, like sliding windows or landmark tokens, overcome the quadratic memory scaling of traditional attention by having queries attend to only a subset of keys, enabling LLMs to handle context lengths up to 100 million tokens.
The top 3
- Top 3 Sparse Attention Patterns for Extreme Context: Key sparse attention patterns include the Sliding Window for efficient local context, Global Attention for critical tokens, and Dilated/Block-Sparse structures, which collectively reduce the quadratic O(N²) complexity to near O(N) for processing millions of tokens.
- Sparse Attention's O(N) Advantage: Speed & Memory Gains: Sparse attention dramatically reduces the O(N²) computational and memory costs of full attention to near O(N), enabling up to 10x prefill speedups over dense FlashAttention-2 and 30-35% peak memory reduction for 100K+ token contexts on devices like a 24 GB GPU.
- LLMs That Pioneered & Advanced Context with Sparse Attention: Early models like Longformer and BigBird utilized sparse attention to push context windows to 4K-16K tokens. More recently, Dynamic Hierarchical Sparse Attention (DHSA) has enabled Llama 3.1-8B to handle 100K context lengths on a single 24GB GPU, while experimental approaches claim up to 100M tokens for models like Qwen3.
Sources
Open the full topic