Zyphra's ZHA Tree Router Scans Just 2.8% of Keys at 256K Tokens

Zyphra's new hierarchical attention trades the quadratic cost of self-attention for a tree-structured search, projecting hundreds of times speedup at billion-token contexts.

·
·
·
Zyphra's ZHA Tree Router Scans Just 2.8% of Keys at 256K TokensPRO
  • Zyphra introduces ZHA, a tree-structured sparse attention that is asymptotically subquadratic.
  • Queries descend a tree of compressed KV summaries, skipping entire branches instead of scoring every key.
  • Projected speedups: 35x over dense at 10M tokens, up to 417x at 1B tokens.
  • Converted from Qwen3.6-35B-A3B with only 81,920 trainable parameters via KL distillation.
  • Matches dense on SWE-bench Verified and beats it on LongBench v2 while using around 1% of keys.
  • Robust across 28 tree geometries, including 6-level deep routers at 256K context.

Dense self-attention compares each query with every available key. For a sequence of n tokens, that produces O(n²) score calculations during training or prefill. During autoregressive decoding, each new token scans an O(n) key-value (KV) cache. That scaling makes million-token contexts impractical. Zyphra’s paper, Subquadratic Attention with a Hierarchical Tree-Structured Indexer, proposes a sparse router that organizes the KV cache as a tree and searches only selected branches.

Zyphra Hierarchical Attention, or ZHA, retains the original KV cache and adds recursively compressed key summaries above it. Future queries traverse those summaries from the root to selected leaves, where attention runs over a sparse set of original key-value pairs. Skipping one node prunes every key below it. The reported efficiency gains focus on decode, where repeated cache scans become increasingly expensive.

Why sparse attention can still scan everything

Sliding-window attention limits each token to nearby context. Linear-attention variants and state-space models compress history into fixed-size state, reducing compute but potentially weakening retrieval of specific distant tokens. Sparse attention can preserve the full cache, yet many sparse selectors still score every stored key before discarding most of them. The resulting attention matrix is sparse, but the selector retains an O(n) scan for each decoded token.

ZHA replaces that scan with hierarchical routing. Each query begins at the root and scores only the children of selected nodes. Total work depends on the tree depth and the number of branches expanded. Depth alone does not guarantee subquadratic scaling; the paper’s argument also relies on the selected set growing sublinearly as context expands.

Pro article

This story is for Pro members

You've reached the end of the free preview. Upgrade to AlphaSignal Pro to read the full article - and everything else behind the paywall.

Trending
  • No trending articles

Comments

avatar

Next Reads