Abstract
Standard attention mechanisms in Large Language Models (LLMs) face significant scalability challenges due to quadratic computational complexity and high KV-cache memory overhead. This paper introduces Alternating Sparse Attention (ASA), an architecture that alternates between local and global attention patterns across layers. By integrating latent attention mechanisms like Multi-head Latent Attention (MLA) and Grouped-head Latent Attention (GLA), ASA reduces KV-cache memory usage by 50% while maintaining or exceeding the performance of full-attention models on reasoning and long-context tasks.
Introduction
As the demand for long-context capabilities in LLMs grows—driven by tasks like multi-document analysis and long-form code generation—the efficiency of the attention mechanism has become a critical bottleneck. Standard attention scales quadratically ($O(n^2)$) with sequence length, leading to prohibitive computational costs and massive GPU memory consumption for storing the KV-cache.
Native Sparse Attention (NSA) was developed to mitigate these issues by partitioning attention into three specialized branches: sliding-window (local), compressed (summary), and selective (important tokens). However, NSA often suffers from interference between these branches and still maintains a significant memory footprint.
Methods: Alternating Sparse Attention (ASA)
The core innovation of ASA is the Local-Global Alternating Strategy. Unlike NSA, which executes all three sparse attention branches in every layer, ASA alternates them. This design allows specific layers to specialize in either local context processing or global information retrieval, reducing interference and forcing the model to learn effective long-range dependencies.
Latent Attention Integration
To further optimize memory, ASA incorporates latent attention mechanisms. For the sliding-window branch, it employs Multi-head Latent Attention (MLA), which compresses the KV-cache into a low-dimensional latent vector. For the selective and compressed branches, the authors introduce Grouped-head Latent Attention (GLA), ensuring compatibility with sparse retrieval patterns. This integration allows the model to maintain high performance while drastically reducing the footprint of the keys and values stored during inference.
Key Insights
The research highlights two critical findings regarding model behavior:
- Functional Specialization: The sliding-window branch acts as the primary engine for common-sense reasoning, whereas the selective branch serves as a "librarian" for long-distance retrieval.
- Overcoming the "Shortcut" Problem: In models where local and global attention coexist in every layer, the model tends to rely "lazily" on local context. Alternating these branches across layers forces the network to utilize global retrieval mechanisms more effectively, improving overall retrieval accuracy.
Results and Performance
Evaluations on models up to 1.3B parameters trained on SlimPajama demonstrate that ASA achieves:
- 50% Reduction in KV-cache Storage: Significant memory savings compared to standard NSA.
- Performance Parity: Matches or exceeds "Full Attention" models in common-sense reasoning (e.g., PIQA, HellaSwag) and long-context understanding (LongBench).
- Superior Retrieval: Outperforms NSA on "Needle-In-A-Haystack" benchmarks, indicating better information pinpointing in massive contexts.
- Hardware Efficiency: Custom GPU kernels provide a 30% speedup in forward-pass latency and a 13% reduction in backward latency for sequences up to 32k tokens.
Conclusion
Alternating Sparse Attention (ASA) represents a significant step toward efficient long-context LLMs. By combining structural alternation with latent attention, it achieves substantial memory savings without sacrificing reasoning or retrieval capabilities. Future work will explore optimal layer placement recipes and scaling these strategies to 70B+ parameter models.
Summary updated