Summary (Overview)
- OpenAttention is a novel sparse attention method that approximates the tail distribution of attention weights using proxy tokens rather than discarding or sampling the tail, achieving 99% of dense accuracy at just a 1% read rate on RULER-32K HARD with Llama-3.1-8B.
- The key theoretical insight is that a single count-aware mean proxy yields lower attention weight error than random sampling at low read densities—sampling nearly doubles the weight error of discarding the tail entirely.
- Three novel components are introduced: Query-Geometry Clustering (QGC) for grouping keys under query geometry, Query-Geometry Selector (QGS) for efficient top-k selection, and ErrorGate for budget allocation based on estimated weight error.
- OpenAttention achieves state-of-the-art accuracy across multiple models (Llama-3.1-8B, DeepSeek-R1-Distill-Llama-8B, Mistral-7B), context lengths (16K–96K), and outperforms baselines (HashAttention, vAttention, MagicPIG) by large margins.
- A custom Triton-based kernel, OpenAttention.flash, runs the estimator in one online softmax pass, achieving 5–10× faster decode attention than dense attention at 3% and 1% reads.
Introduction and Theoretical Foundation
Background and Motivation
Long-context decoding is bottlenecked by the memory traffic of the key-value (KV) cache. Sparse attention reduces this cost by computing attention over only a subset of the cache. However, existing top-k approaches (Singhania et al., 2024; Yang et al., 2024; Desai et al., 2025) focus solely on predicting the top-k scores accurately and discard the remaining tail. This fundamentally prevents these methods from approximating the dense attention distribution, which is especially critical for aggregation tasks (e.g., FWE).
Sampling-based methods like MagicPIG (Chen et al., 2025) and vAttention (Desai et al., 2026) attempt to estimate the tail via importance sampling or random samples. However, estimation error of sampling grows sharply as the density decreases, and at low reads (<5%), the tail likely holds heavy hitters the selector missed.
Key Observation
The paper's central finding (Figure 3): a random sample complements the tail well at high density but yields higher error than top-k alone at low density. However, folding the same tail into a single proxy with a count-aware mean keeps the error low in every setting examined.
Theoretical analysis (Section 2.2): Let with . For a tail of size , the error formulations are:
where is the count-aware mean, for sample size , and , .
The key weight-discrepancy results (Eq. 2):
Critical finding: Sampling approaches twice the discard discrepancy when , while a single proxy stays below it. This motivates approximating the tail with well-constructed proxies rather than samples.
Methodology
3.1 Overall Architecture
OpenAttention clusters the cache once per request into clusters under query geometry (QGC). Each cluster caches:
- Size
- Mean token
- Variance token diag
For each query, two small matrix products give every and , from which ErrorGate estimates the error each proxy would leave. The exact budget is split in proportion to this estimate, and each cluster reads its highest-scoring tokens under QGS.
3.2 Query-Geometry Clustering (QGC) and Selection (QGS)
QGC: Uses top- eigenvectors of the query second-moment matrix . Since , minimizing within-cluster logit variance reduces to k-means under metric . Keys are projected as:
QGS: Scores keys using int8-quantized projections:
3.3 ErrorGate
Estimates cluster discrepancy using a Gaussian model:
Budget allocation via water-filling:
3.4 OpenAttention.flash Kernel
A Triton-based FlashAttention-2 decode kernel that processes exact tokens and proxies in one online softmax pass, with pooled sums cached per cluster for efficient subtraction of read tokens.
Empirical Validation / Results
4.1 Comparison Across Read Densities (RULER-32K HARD, Llama-3.1-8B)
At 1% read: OpenAttention scores 86.30 vs. dense 87.04 (99% retention), while the best baseline (HashAttention) scores only 48.2. OpenAttention maintains accuracy close to dense at every density from 10% to 1%.
4.2 Ablation Study (5% read, Table 4)
| Configuration | Avg |
|---|---|
| No proxies, no ErrorGate, no QGS (vAttention on HashAttention) | 67.35 |
| + Proxies | 77.91 |
| + Proxies + ErrorGate | 85.90 |
| + Proxies + QGS | 86.73 |
| + All three | 86.82 |
4.3 Cross-Model Evaluation (3% read, Table 5)
| Method | Llama-8B | DeepSeek-8B | Mistral-7B |
|---|---|---|---|
| Dense | 87.04 | 73.46 | 65.46 |
| HashAttention | 63.48 | 59.85 | 51.24 |
| vAttention | 57.15 | 49.26 | 46.14 |
| OpenAttention | 86.59 | 73.49 | 64.83 |
4.4 Context Length Scaling (Table 7, 3% read)
| Method | 16K | 32K | 64K | 96K |
|---|---|---|---|---|
| Dense | 87.14 | 87.75 | 85.49 | 78.01 |
| MagicPIG | 46.91 | 51.38 | 45.73 | 33.19 |
| HashAttention | 67.41 | 63.87 | 49.65 | 27.99 |
| vAttention | 52.69 | 55.63 | 54.79 | 40.20 |
| OpenAttention | 87.49 | 87.38 | 84.82 | 78.10 |
4.5 Clustering and Selection Validation
QGC vs. alternatives (Table 1, C=64, 1% read): QGC (16 dim) → 86.30, k-means on keys (128 dim) → 85.42, token position → 84.37.
QGS vs. selectors (Table 2): QGS achieves 0.97 top-32 logit recall at 1/16 read with 0.22 ms selection time—best balance of accuracy vs. cost.
ErrorGate ranking ablation (Table 3): Estimated error → 86.30, mean logit (mass) → 85.99, variance → 84.81.
4.6 Speedup
OpenAttention.flash runs the decode attention stage 10× faster than dense attention at 1% read and 5× faster at 3% read (batch 32, 32K context).
Theoretical and Practical Implications
Theoretical Contributions
-
Closed-form comparison (Eq. 2) of tail-treatment strategies shows sampling's fundamental disadvantage at low reads: approaches twice the discard error, while proxy error remains bounded below.
-
Exact error decomposition (Eq. 3): , separating proxy mass () from weight spread ()—providing a principled framework for cluster-based approximation.
-
Error bound: , establishing the connection between weight discrepancy and output error.
Practical Implications
- 1% read rate with 99% dense accuracy makes long-context sparse attention practical for deployment on memory-constrained hardware
- The approach is orthogonal to KV cache compression (StreamingLLM, SnapKV, PyramidKV), losing only 0.14 points on average when combined
- Custom kernel accelerates decode attention by 10×, addressing the latency bottleneck critical for interactive applications
- The training-free method requires only once-per-request clustering, making it efficient for dynamic workloads
Conclusion
Main Takeaways
OpenAttention demonstrates that approximating the tail distribution with count-aware mean proxies is fundamentally superior to discarding or sampling at low read densities. By exploiting query geometry for clustering and selection, and using estimated weight errors for budget allocation, it achieves:
- 99% dense accuracy at 1% read
- State-of-the-art across models and context lengths
- 5–10× decode attention speedup
Limitations and Future Directions
- ErrorGate approximation: The diagonal variance approximation agrees with full-variance estimates at Spearman 0.92 but cannot recover exact error—reducing this proxy error is a promising future direction
- The budget allocation in Eq. (7) is a heuristic rather than an optimal rule
- The squared logit error metric is not the only objective; output error also depends on normalizer uncertainty and value direction perturbations
Reproducibility
Code is available at https://github.com/hyunwoo137/OpenAttention with project page at https://hyunwoo137.github.io/OpenAttention/. All models and benchmarks are publicly available; the 64K and 96K RULER sets are synthetic.
Related papers
- Truncate or Not? A Scaling Study of Looped Transformers with Truncated Backpropagation
Full backpropagation through time is optimal for looped transformers when both forward and backward loop counts are free, despite truncation helping when forward loops are fixed.
- Are Self-Evolving Agents Continual Learners?
Self-evolving LLM agents trade stability for plasticity, failing as continual learners because global prompt edits cause cross-task interference and similarity-based retrieval collides on conflicting workflows.
- Depth-adaptive Inference of Looped Language Models via Continuous Depth Batching
Continuous depth batching realizes up to 99% of theoretical depth-adaptive speedup for looped language models, with fully looped architectures yielding the largest gains.