Subquadratic Attention with a Hierarchical Tree-Structured Indexer
AuthorsLeon Lufkin, Cutter Dawes, Alexander Speicher, Kamesh Krishnamurthy, Tomás Figliolia, Beren Millidge
AffiliationsZyphra Research
ZHA uses a hierarchical tree to find relevant keys efficiently, aiming to make very long-context attention practical.
Key results
KL distillation adapts the frozen pretrained model.
Six-level ZHA on Qwen3.6-35B-A3B; dense attention scores 96.0%.
Percentage-point lead at a similar decode-key share.
Predicted context length where ZHA becomes faster than MSA.
Lower end of the predicted 373×–417× speedup at 1B tokens; not measured.
What the paper found
Zyphra Hierarchical Attention, or ZHA, replaces all-to-all attention with a tree of compressed key summaries: learned reference queries build the summaries, and adaptive top-p routing follows relevant branches before exact attention on selected keys. Unlike fixed-budget sparse methods, this lets each query retrieve a different subset while the hierarchy grows with context; the authors show subquadratic scaling under suitable routing and tree-depth choices. ZHA can be added to frozen pretrained models with a 1B-token KL-distillation stage. On Qwen3.6-35B-A3B, a six-level router scored 93.3% on RULER-13 versus 96.0% for dense attention while attending to 1%–6% of the KV cache, and exceeded MiniMax Sparse Attention by 12.7 percentage points on LongBench v2. A roofline model—not measured end-to-end latency—predicts ZHA overtakes MSA around 0.48M tokens and, at 1B tokens, reaches 373×–417× the speed of dense attention and 52×–58× that of MSA. These extreme-context projections remain unvalidated for task accuracy. Tests on NVIDIA’s Nemotron-3.5-Lightning-30B-A3B retained reasoning and coding performance, but showed larger retrieval losses, underscoring that results depend on model and positional-encoding characteristics.
Original abstract
The quadratic scaling of attention is a fundamental bottleneck limiting the long-context capabilities of large language models (LLMs). A variety of approaches have attempted to circumvent this, but they either fail to match attention's expressiveness (e.g., sliding-window or linear attention variants with fixed-size state) or only achieve constant-factor speedups (e.g., sparse attention methods whose indexers themselves scale quadratically). In this paper, we derive an asymptotically subquadratic sparse attention method based on a hierarchical, tree-structured indexer, which we call Zyphra Hierarchical Attention (ZHA). ZHA constructs a tree of recursively compressed key summaries over the KV cache, which future queries traverse from the top down to retrieve a sparse subset of keys. Crucially, by iteratively growing the tree's depth, the total cost including routing and final attention grows sublinearly in sequence length, resulting in overall subquadratic (but superlinear) scaling for attention. We demonstrate that ZHA can be cheaply applied to existing pretrained models with only a short KL distillation training stage of a billion tokens, and maintains performance on long-context retrieval and challenging reasoning, mathematical, and agentic coding evaluation tasks. Moreover, we show that our method is highly robust to tree geometry including very deep trees of up to 6 levels. Finally, we develop a detailed performance model and show that our approach scales subquadratically, dramatically outperforms competing methods beyond 1 million tokens of context, and ultimately has the potential to extend effective context windows to the hundreds of millions or billions of tokens.
Read the original paperMore in Attention Mechanisms
Browse all 24 papers →HyScale: Scaling Long-Context Training for Learned Sparse Attention
Yangshen Deng, Xinjing Huang, Yulong Wang, Yunzhuo Liu, Jun Hu, Shuyong Tan, Chun-Chih Tseng, Mingji Han, Ray Ying, Key Zhang, Luo Mai
HyScale makes training long-context sparse attention faster by avoiding large selection tables and reusing selection results during recomputation.
Latent Sparse Attention: Towards Subquadratic Ultra-Long Context Attention
Ales Kubicek, Andrea Caciolai, Liangzu Peng, Sukrit Sumant, Benjamin Hoover, Fraser Greenlee, Ruairidh M. Battleday, Radim Urban, Torsten Hoefler, James C. R. Whittington
Latent Sparse Attention organizes keys into learned clusters so models can attend over million-token contexts more efficiently.
Can Computation from Earlier Problems Help LLMs Solve New Ones?
Jipei He, Wenhui Tan, Xiaoyi Yu, Enver Sangineto, Fiorenzo Parascandolo, Rita Cucchiara, Ruihua Song
STAIR helps language models reuse useful computation from earlier questions, improving performance on later problems with only a tiny trainable module.