Summary (Overview)
- Core innovation: The paper introduces a certified sparse attention method that perturbs each key's score with an independent Exp(1) variable, transforming threshold retrieval into probability-proportional-to-size (PPS) sampling. This enables unbiased Horvitz–Thompson estimation of the softmax output with finite-sample error certificates that hold simultaneously across all threshold levels.
- Key theoretical guarantee: At a suitable threshold, the estimator reads values regardless of context length, which is proven optimal up to constants via a matching lower bound. The anytime-valid certificates ensure each attention head's error exceeds with probability at most per decoding step.
- Empirical validation: Across three LLMs and ten settings at 16K–128K tokens, no certificate was violated. At equal keys read, the method achieves 4.6–7.9× lower 90th-percentile error than the best of 15 baseline families, while eliminating the heavy error tail (max errors ≤ 0.029 vs. baselines' 0.39–1.62).
- Efficiency: A 4-bit scan with deterministic bounds generates candidates exactly, reading only 16.4% of dense attention's bytes for metadata. On CPU, decoding steps at 32K–128K tokens run 1.1–1.4× faster than dense attention.
- End-to-end quality: The method stays within one point of dense attention on tasks and within 0.1% in PG-19 perplexity, with 79–98% of outputs identical to dense attention's.
Introduction and Theoretical Foundation
Background and Motivation
Sparse attention aims to accelerate long-context decoding by reading only a small fraction of the KV cache. For Llama-3.1-8B with a 128K-token context, each decoding step requires reading ~16 GiB of 16-bit keys and values, making memory bandwidth the bottleneck. Existing heuristic methods—such as attention sinks, heavy hitters, page-level bounds, and approximate nearest neighbors—do not control per-query error, which exhibits heavy tails on real KV caches (90th-percentile errors of 0.051–0.090 but maxima of 0.4–1.6 for the best of 15 baselines).
Theoretical Foundation
The key insight is that perturbing each key's score with an independent exponential variable enables principled sampling. For each key with perturbation and unnormalized attention weight , the perturbed score threshold condition holds with probability . This creates threshold (Poisson PPS) sampling, under which Horvitz–Thompson estimates of the softmax numerator and denominator are unbiased. Lowering monotonically adds keys, enabling a geometric grid search where each head stops at the first level whose certificate meets the target error.
Methodology
Problem Setup
For a fixed layer, KV head, and decoding step with cached keys and values :
- Scores: , maximum
- Unnormalized weights:
- Denominator: , Numerator:
- Attention output: , attention weights:
Error is measured on three scales: denominator (), output norm (), and value scale (, where ). The value scale is times the output norm.
Algorithm Components
1. Perturbed threshold sampling. The KV cache is split into a window (recent 64 tokens, always read exactly) and a pool. Each pool key has perturbation from a 53-bit uniform hash. The sampled set at threshold is:
2. Horvitz–Thompson estimation. Light keys have inclusion probability , giving HT weights :
3. Anytime-valid certificates. On grid with failure budgets , the algorithm computes:
- Denominator interval: Chernoff bounds on the Poisson-binomial sample count
- Centered numerator: Bernstein inequality in Hilbert space on the centered sum
- Output error bound:
- Stopping rule: Stop at first certified level meeting target error
4. Candidate generation. A 4-bit per-block-per-channel quantization (as in KIVI) with AVX-512 VNNI provides deterministic upper bounds for all scores. Candidates are bucketed by earliest possible inclusion level via counting sort, with 8-bit refinement and exact 16-bit reads only for keys that may enter the sample. Exact maximum computation covers only 0.1–1% of the pool.
Empirical Validation / Results
Error at Matched Keys Read
Table 1. Error/M at matched keys read (ε = 0.1; baselines read ≤ 1.1× our keys).
| Model · data | Ours: keys / p90 / max | Families | Best baseline: keys, p90 / max | Ratio (p90) | Error/‖o‖ p90: ours / best |
|---|---|---|---|---|---|
| Llama · LongBench 16K | 2.70% / 0.011 / 0.021 | 11/15 | MagicPIG 2.75%, 0.059/0.83 | 5.3× | 0.087/0.311 (3.6×) |
| Llama · RULER 32K | 1.35% / 0.011 / 0.025 | 10/15 | RetroInfer 1.24%, 0.058/0.49 | 5.0× | 0.075/0.287 (3.8×) |
| Llama · RULER 64K | 0.70% / 0.012 / 0.028 | 14/15 | RetroInfer 0.58%, 0.059/0.68 | 5.1× | 0.076/0.294 (3.8×) |
| Llama · LongBench-v2 64K | 0.61% / 0.011 / 0.021 | 12/15 | RetroInfer 0.57%, 0.051/0.39 | 4.6× | 0.085/0.277 (3.2×) |
| Llama · RULER 128K | 0.46% / 0.012 / 0.029 | 12/15 | RetroInfer 0.47%, 0.077/0.65 | 6.5× | 0.073/0.352 (4.8×) |
| Llama · LongBench-v2 128K | 0.42% / 0.012 / 0.022 | 12/15 | RetroInfer 0.32%, 0.069/0.65 | 5.9× | 0.081/0.340 (4.2×) |
| Qwen3 · LongBench 16K | 2.15% / 0.010 / 0.021 | 10/13 | RetroInfer 1.67%, 0.072/1.46 | 7.2× | 0.049/0.270 (5.5×) |
| Qwen3 · RULER 32K | 1.50% / 0.011 / 0.025 | 10/13 | RetroInfer 1.37%, 0.073/1.62 | 6.9× | 0.046/0.252 (5.5×) |
| Qwen2.5 · LongBench 16K | 2.67% / 0.011 / 0.022 | 11/13 | RetroInfer 2.26%, 0.072/0.95 | 6.6× | 0.057/0.308 (5.4×) |
| Qwen2.5 · RULER 32K | 1.73% / 0.011 / 0.027 | 10/13 | RetroInfer 1.22%, 0.090/0.98 | 7.9× | 0.054/0.333 (6.2×) |
Certificate Validity
Across 120 configurations (10 settings × 3 measures × 4 values of ε), no certificate was violated, no layer had a violation, and no head fell back to exact attention. Certificates are conservative: observed errors are about ε/10 at the 90th percentile, with largest errors 0.31ε (value scale) and 0.41ε (output norm).
End-to-End Performance
Table 2. End-to-end score change versus dense attention.
| Model · data | Keys read | Δ score [95% CI] | Same output as dense |
|---|---|---|---|
| Llama · LongBench (300) | 5.26% | −0.29 [−0.63, −0.03] | 0.80 |
| Llama · RULER 32K (200) | 1.50% | −0.65 [−2.05, +0.35] | 0.93 |
| Llama · RULER 64K (100) | 0.78% | 0.00 [0.00, 0.00] | 0.98 |
| Llama · RULER 128K (48) | 0.49% | 0.00 [0.00, 0.00] | 0.90 |
| Qwen3 · LongBench (150) | 5.10% | +0.17 [+0.06, +0.28] | 0.80 |
| Qwen3 · RULER 32K (100) | 1.53% | +1.00 [−0.20, +3.10] | 0.85 |
| Qwen2.5 · LongBench (150) | 5.38% | +0.07 [−0.09, +0.25] | 0.79 |
| Qwen2.5 · RULER 32K (100) | 1.73% | −0.10 [−0.30, 0.00] | 0.83 |
PG-19 perplexity changes by only −0.02% to +0.07% with KL divergence 0.0002–0.0006 from dense attention, whereas oracle top-k reading the same keys raises perplexity by 4.8–11.5%.
CPU Speed
Attention speedups over dense attention: 1.8–3.5× at 64K–128K and 1.0–2.1× at 16K–32K on Llama. Whole fp32 decoding steps are 1.1× faster at 32K and 1.4× at 128K. Fresh perturbations add a median 4% overhead.
Theoretical and Practical Implications
Theoretical Contributions
Theorem 1 (Unbiasedness and variance). , , with and .
Theorem 2 (Sample size independent of context). With and probability at least :
where , , . Thus values suffice for error , independent of .
Theorem 3 (Lower bound). Any algorithm reading at most values requires for output-norm error and for value-scale error, proving the PPS estimator is optimal up to constants.
Theorem 4 (Anytime-valid certificates). For each query head and error measure:
The proof intersects confidence events across all levels, making the data-dependent stopping level harmless.
Practical Implications
- Reliability: The method eliminates the heavy error tail of heuristic sparse attention, guaranteeing per-call error bounds that scale to full generations via union bounds ( per call).
- Efficiency floor: The 4-bit scan sets a floor of 16.4% of dense attention's bytes, which caps achievable speedups and allows baselines at equal bytes to match typical (but not worst-case) errors.
- Conservativeness: Certificates read 1.8–3.5× more keys than uncertified central-limit rules; the gap represents the cost of statistical guarantees.
Conclusion
This work demonstrates that exponential perturbations transform threshold retrieval into weight-proportional sampling, enabling a sparse attention kernel that estimates unbiasedly and certifies each call's error. The certificates held in every configuration tested across three LLMs and ten settings, removing the heavy error tail of heuristic approaches. While end-to-end task quality matches the strongest baselines at equal bytes, the method uniquely provides per-call guarantees and closer agreement with dense attention during sampling. The main limitation is the linear candidate-generation scan, which sets a bytes floor; a sublinear index with recall guarantees would remove this bottleneck. The method does not cover closed-loop generation with fixed perturbations, and deployments should not present it as a guarantee of unchanged model behavior—only as per-head, per-step error certificates with probability at least .
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.
- RecurTrace: Adaptive Latent Reasoning with Loop-Time Memory
RecurTrace adds loop-time attention memory and oracle-distilled halting to frozen LLMs, improving MathQA accuracy by 2.2 points at matched compute while scaling gains with model size.
- Multi-Reward Hacking: From Aggregation-Induced Drift to Trust-Anchored Defense
Symmetric reward aggregation in LLM post-training provably causes multi-reward hacking, favoring auxiliary rewards over correctness, and Trust-Anchored Gating reverses this collapse.