WorksComputer Science
Stratified Sparse Attention: Reducing the Sparse-to-Dense Gap at Extreme Sparsity
Abstract
Large Language Model inference over long contexts is increasingly bottlenecked by the cost of attending to a growing Key-Value (KV) cache. Sparse attention reduces this cost by accessing only a fraction of the cache, but existing methods face a trade-off between deterministic retrieval, which captures high-scoring tokens but discards residual attention mass, and sampling, which improves coverage at the cost of higher variance. Hybrid methods combine top- retrieval with uniform sampling, yet still exhibit a substantial gap from dense attention at aggressive sparsity. We introduce Stratified Sparse Attention (SSA), a unified framework combining deterministic retrieval with score-guided sampling. SSA deterministically attends to high-scoring tokens while sampling the residual using proxy attention scores and correcting for their inclusion probabilities, thereby recovering attention mass beyond the retrieval set. SSA encompasses top-, top-, and hybrid top-+sampling as special cases. Across RULER, LongBench, LOFT, and AIME, and five models ranging from 3B to 27B parameters, SSA consistently improves over the baselines at matched sparsity. On RULER-HARD with Ministral-3-8B, SSA improves accuracy over the strongest practical baseline from 81.8% to 84.2% at 32K and from 63.8% to 69.3% at 128K under attention sparsity, recovering 94% and 85% of dense-attention performance, respectively. With optimized CUDA kernels, SSA achieves up to decode speedup over FlashInfer at 1M context, demonstrating that its accuracy gains translate into practical long-context inference acceleration. We open-source our code at https://github.com/skylight-org/SSA-Paper-Code.
Introduction
Large language models (LLMs) are rapidly expanding into long-context workloads, spanning large document collections [23], image analysis [10, 31], software engineering [15, 5], databases [48], video processing [33], and long-horizon agents that continuously accumulate observations, tool outputs, and interaction histories [3, 4]. As context lengths approach millions of tokens, efficient inference becomes increasingly challenging. During autoregressive decoding, each newly generated token attends to an ever-growing key-value (KV) cache, requiring keys and values to be repeatedly transferred from GPU high-bandwidth memory (HBM) onto on-chip SRAM for attention computation [35, 20]. At long contexts, this makes decoding increasingly memory-bandwidth bound: the attention cost per decoding step grows linearly with context length. Sparse attention addresses this bottleneck by attending to only a small fraction of the KV cache [39, 27, 46], reducing both memory traffic and attention latency. However, realizing these gains in practice requires sparse attention to satisfy two competing objectives: faithfully approximate dense attention at aggressive sparsity while remaining efficient enough to translate sparsity into end-to-end inference speedups [29, 25].
Existing sparse-attention methods can be broadly categorized by how they allocate a limited attention budget. First, approximate retrieval methods use proxy attention scores to deterministically select high-scoring tokens, typically through top- retrieval. Representative methods include PQCache [46], and Quest [39], with recent approaches such as Tactic [50] extending this paradigm to top- selection. While effective when attention is highly concentrated, deterministic retrieval can miss substantial attention mass when the distribution is diffuse or long-tailed [6, 9]. Second, sampling-based methods such as MagicPig [6] use importance sampling to approximate dense attention, providing broader coverage but introducing sampling variance that can lead to a larger gap from dense attention at limited budgets (see Table 5 in Appendix). Finally, hybrid methods such as vAttention [9] combine deterministic top- retrieval with uniform sampling [42], preserving high-confidence tokens while extending coverage beyond the top- set. Although this combination improves the trade-off between exploitation and coverage, a substantial gap to dense attention remains at aggressive sparsity (see Table 5 in Appendix). See § 2 for more details. These observations motivate a fundamental question: Can we design a more effective sampling strategy that substantially narrows the sparse-to-dense accuracy gap?
| Model | Dense | PQCache | vAttn(PQ) | Quest | HashAttn | Double Sparsity | MagicPig |
| Qwen3-4B-Instruct-2507 | 88.67 | 85.80 | 85.67 | 42.03 | – | 39.29 | 18.72 |
| Llama-3.2-3B-Instruct | 66.25 | 39.30 | 39.59 | 34.11 | – | 31.21 | 17.22 |
| Llama-3.1-8B-Instruct | 87.89 | 68.95 | 64.42 | 64.17 | 49.48 | 44.62 | 16.28 |
Table 5. Average performance on RULER-HARD-32K across different models at 50× sparsity.
Our preliminary studies reveal a key limitation of uniform sampling: while it provides coverage beyond the deterministic top- set, it ignores the highly non-uniform distribution of residual attention mass7. As shown in Figure 1, score-guided importance sampling (the principle that SSA uses) consistently achieves lower relative error than uniform sampling. Motivated by this observation, we introduce Stratified Sparse Attention (SSA), a unified framework that combines deterministic retrieval of high-confidence heavy hitters with score-guided stochastic exploration of the remaining context. Rather than treating all residual tokens equally, SSA uses proxy attention scores to preferentially explore promising regions while preserving stochastic coverage of the long tail. This enables the sparse attention budget to better capture the attention mass that would otherwise be lost under aggressive sparsity. We evaluate SSA across diverse models, including Llama-3.1-8B-Instruct [12], Qwen3.5-4B, Qwen3.5-9B, Ministral-3-3B-Instruct-2517, and Ministral-3-8B-Instruct-2517 [26], and across RULER [16], LongBench [2], LOFT [22], and AIME [28]. Across these evaluations, SSA consistently improves over deterministic, sampling-based, and hybrid sparse-attention baselines, substantially narrowing the gap to dense attention at extreme sparsity. Our contributions can be summarized as follows:

Figure 1. Relative error when varying the top-:sampling budget allocation at sparsity (left) and varying sparsity with a fixed 3:2 top-:sampling budget split (right).
I. Unified Attention Paradigm: We introduce a unified sparse-attention framework that partitions tokens into deterministic and stochastic strata using a generic proxy score. By varying how tokens are retained or sampled, the framework recovers top-, top-, and hybrid top-+sampling as special cases of importance-sampling-inspired sparse attention.
II. Theoretical Guarantees: We provide rigorous bounds for our proposed algorithm, characterizing how closely it approximates dense attention under a limited attention budget.
III. Efficient Kernel Support: We develop efficient CUDA/Triton kernels that realize the computational benefits of our approach in practice, delivering end-to-end decoding speedups over dense attention.
Related Work
In the context of SSA, the extensive prior work can be organized into three broad and comprehensive research directions:
Head-level compression and KV eviction: One line of work reduces KV-cache overhead by sharing or compressing KV heads. Multi-Query Attention (MQA) [37] shares a single KV head across all query heads, while Grouped-Query Attention (GQA) [1] and Multi-Head Latent Attention (MLA) [7] provide more flexible compression to balance efficiency and model quality. A complementary line of work dynamically evicts less important KV entries during inference. Methods such as SnapKV [24], DynamicKV [49], KVZip [19], KeyDiff [30], CurDKV [34], and CapKV [44] use different importance signals and eviction policies to reduce cache size and subsequent attention computation. These approaches are complementary to sparse attention: KV compression reduces the tokens or representations retained across decoding steps, whereas sparse attention dynamically selects which retained tokens to access for each query. The two can therefore be composed to further reduce memory and decoding costs.
Approximate top-/top- methods: A substantial body of sparse-attention work focuses on finding the tokens with the largest attention scores. Methods such as Quest [39], PQCache [46], SqueezedAttention [14], Adamas [43], SOCKET [18], Sketch-and-Walk [21], RetrievalAttention [27], Loki [38], HashAttention [8], and Double Sparsity [45] employ different proxy scores or retrieval mechanisms to approximate the top- tokens under dense attention. These methods are effective at recovering high-attention “heavy hitters,” but a fixed top- selection discards all tokens outside the retrieval set. Consequently, when non-negligible attention mass is distributed across the residual tail, or when approximation error causes relevant tokens to fall just below the top- boundary, this discarded mass can create a substantial gap from dense attention at aggressive sparsity. Tactic [50] extends this retrieval paradigm from top- to top- selection by modeling the decay of attention scores with a power-law distribution and estimating the number of highest-scoring tokens required to satisfy a target attention-mass threshold.
Sampling-based and Hybrid methods: MagicPig [6] addresses the limitations of deterministic top- attention by using LSH [17] to approximately sample tokens and importance correction to estimate dense attention. vAttention [9] combines deterministic and stochastic selection through a verified hybrid estimator that retains top- tokens while uniformly sampling from the residual KV cache. KNN-Attention [13] also explores top- plus sampling via lazy Gumbel sampling, but primarily targets training rather than inference acceleration for existing models. Unlike uniform hybrid sampling, which treats all residual tokens equally, SSA uses approximate attention scores to guide stochastic selection toward tokens more likely to carry residual attention mass (see Figure 1).
Background and Motivation
Sparse Attention
We begin by describing the dense attention computation. For clarity, we consider a single query attending to a KV cache and .
Full Scaled Dot-Product Attention (SDPA): Let be the similarity score between and , and with be the corresponding attention weights where . We write SDPA output as
Sparse Attention with deterministic top- Selection: Let heavy set denote a deterministic top- subset from the cached tokens. Sparse attention over the set is defined as . While deterministic top- selection concentrates computation on tokens deemed most relevant, tokens outside do not contribute to the sparse output.
Sparse Attention with Importance Sampling: Let sampled set be a non-empty random set of selected tokens. For each token , let indicate whether it is selected, and let be its inclusion probability. Importance-based sparse attention estimates the dense output by weighting each selected token by the inverse of its inclusion probability:
The factors account for differences in how likely tokens are to be selected. The estimator in eq. (2) is an instance of inverse-probability weighting. We next recall the standard draw-based formulation of importance sampling.
Importance Sampling
Importance sampling [41] is a Monte Carlo technique for estimating a quantity using samples drawn from a proposal distribution. Given a target distribution and a function , consider the expectation . Instead of sampling directly from , importance sampling draws samples from a proposal distribution and rewrites the expectation as . This yields the Monte Carlo estimator
The ratio is the importance weight, which corrects for sampling from rather than . When places greater probability on samples with large contributions to the expectation, importance sampling can achieve lower variance than uniform sampling with the same sample budget.
Introducing Stratified Sparse Attention (SSA)
As already mentioned, deterministic top- attention [11, 47] can omit meaningful attention mass outside the selected set. Uniform sampling on residual tokens provides broader coverage, but does not use information about which remaining tokens are more likely to matter. We introduce Stratified Sparse Attention (SSA), a unified framework that retains tokens with high proxy scores and samples the residual tokens according to those scores. SSA divides a fixed attention budget between two well-known complementary objectives: exploitation, by deterministically retaining high-confidence heavy hitters, and exploration, by sampling the residual context according to proxy attention scores. This score-aware stratification preserves heavy hitters while providing meaningful stochastic coverage toward more promising residual tokens. We next formalize the SSA mechanism described Algorithm 1.
Final Algorithm
SSA operates in three stages that divide the sparse-attention budget between deterministic exploitation and stochastic exploration.
(i) Proxy-based budget allocation (Steps 1-4): SSA converts the proxy scores into probabilities and finds such that . Tokens satisfying form the deterministically retained heavy set . The remaining is allocated to importance sampling from the residual set . Thus, the proxy distribution determines the split between deterministic allocation and residual sampling automatically; SSA does not require a separate choice of heavy-set size.
(ii) Score-guided residual sampling (Steps 5-10): SSA normalizes the proxy probabilities over to obtain proposal probabilities , makes multinomial draws with replacement, and retains the unique keys in . Let , and define to indicate whether token is selected. Its inclusion probability is . For , . For , the token is selected if it appears in at least one of the draws, giving .
(iii) Exact scoring and correction (Steps 11-15): For each token in , SSA computes its exact score and corrected weight . It returns the normalized weighted sum . Since repeated draws are retained only once, .
Algorithm 1 Stratified Sparse Attention (SSA)
1: Input: Proxy scores , query , keys , values , total budget
2:
3: Find s.t.
4: Define heavy set , residual set , heavy size , sampling budget
5: Normalize the proposal over : for
6: Draw with replacement:
7:
8: for
9:
10: for
11: for do
12:
13:
14: end for
15: return
Theoretical Insights
We now characterize how accurately SSA approximates dense attention. Our analysis of Algorithm 1 is designed for the budget parameter . When , every token is retained (see step 3), so SSA trivially returns dense attention exactly. The residual set is then empty and requires no sampling analysis. For , the residual set is nonempty i.e., . Let be the dense attention weights from § 3, and denote the spectral norm of the value matrix. In addition, we introduce the following quantities for our analysis,
where is the true attention mass left for sampling, while measures how well the residual proposal covers that mass. For finite proxy scores, and hence for every . Since , the largest ratio must satisfy . The equality holds precisely when every ratio is equal to one, i.e., for all .
The budget-allocation rule also limits the effect of duplicate residual draws. Indeed, steps 3–4 of Algorithm 1 give as each heavy token contributes 1 to the budget equation, and each residual token contributes . Since , it follows that . Combining this with gives for every . Here is the expected number of times token appears among the draws. The largest expected multiplicity among the residual tokens is therefore defined as
A small value of corresponds to a diffuse proposal with few repetitions, whereas a value closer to one indicates a more concentrated proposal and a greater possibility of repeated draws.
Now, to use the proxy-quality parameter in the error bound, we need to relate the proposal probability to the inclusion probability used by Algorithm 1. A residual token is retained if it appears in at least one of the draws, so . To account for duplicate draws, we define
The following lemma quantifies their effect on the inclusion probabilities.
Lemma 1. Let , let for , and let and be defined above. For every , . Consequently, .
Now, we are ready to use the lemma to bound SSA’s approximation error.
Theorem 2. For any , let . If , then, with probability at least over the residual sampling,
Since , deduplication contributes only a universal constant factor to the approximation and sample-complexity bounds. The following corollary gives a direct guarantee and a sufficient sample size that automatically ensures .
Corollary 3. Consider Algorithm 1 with an integer budget and finite attention and proxy scores. Let . If , then, with probability at least ,
Remark 4. Note that the approximation error in Theorem 2 scales as . The residual mass decreases when the retained heavy tokens capture more of the true attention mass, while increases when the proxy underestimates an important residual token. Increasing the residual budget reduces the stochastic error at the standard Monte Carlo rate . For a fixed total budget, SSA therefore balances the reduction in obtained from retaining more heavy tokens against the larger sampling budget obtained from retaining fewer of them.
Remark 5. In both Theorem 2 and Corollary 3, we express the bounds using . The proofs only require a bound on the individual value-vector norms, so the same results hold with in its place, without changing the constants.
Kernel Design
At long contexts, decode attention is memory-bandwidth bound because each step reads the entire KV cache from HBM [35, 20]. SSA reduces this memory traffic by selecting a sparse subset of tokens before loading their KV states. While Algorithm 1 determines the division between the heavy and residual strata adaptively, our optimized GPU implementation uses a fixed heavy fraction. Developing an equally efficient implementation of the adaptive algorithm remains future work. As shown in Table 4, the practical fixed-budget variant closely matches the performance of the theoretical formulation. The residual proposal, inclusion-probability correction, and resulting attention estimator remain unchanged. Our SSA decode step consists of four stages, where only the first three scan the full context using a few bytes per token.
| Model | Sparsity | SSA-Theory | SSA-Practical |
| Llama-3.1-8B | 50× | 81 | 83 |
| Llama-3.1-8B | 20× | 88 | 88 |
| Ministral-3-8B | 50× | 82 | 84 |
| Ministral-3-8B | 20× | 89 | 88 |
Table 4. Comparison of theoretical and practical SSA variants on average RULER-HARD-32K performance.
Proxy scoring: Each key is represented by a 16-byte PQ code (16 subspaces, 256 centroids) [46], compared to 1 KiB for its fp16 key-value pair at head dimension 256. For each query, a lookup table computes the proxy score for every token. Scores are scaled and masked for sink and local tokens within the same kernel, avoiding an additional pass.
Heavy-set selection: We select using radix top- [36], which returns an unsorted index set since the estimator in eq. (2) is invariant to the ordering of selected tokens.
Residual sampling: Direct sampling from the full residual distribution becomes expensive at long context lengths, as constructing and sampling from the distribution requires processing probabilities across the entire residual KV cache. To reduce this overhead, we use a hierarchical sampler that progressively narrows the search space. Each draw first selects a 1024-token chunk, then a 32-token sub-tile, and finally scans at most 32 tokens to select a key. We remove duplicate samples with a per-row hash table and reweight each unique sample by . In practice, we clamp at to avoid excessively large weights, at the cost of introducing a small bias. Finally, we use a counter-based random number generator to obtain fresh samples across replays while retaining compatibility with CUDA graph capture.
Sparse decode: The final stage gathers the keys and values in from the paged KV cache and evaluates eq. (2) using an online softmax. To exploit more parallelism, we divide each query head across multiple thread blocks and combine their partial softmax results using a numerically stable log-sum-exp reduction. At 1M context and batch size 1, using 64 splits is 1.58–1.71× faster than using 32 splits across sparsity levels. Increasing the number of splits to 128 or 256, however, reduces performance because the additional parallelism no longer offsets the increased launch and merge overhead.
Experiments
We conduct an extensive evaluation of SSA against Oracle-top-, deterministic top-, pure sampling, and hybrid baselines across multiple datasets, models, context lengths, and generation lengths. In addition, note that we slightly overload the notation . In Algorithm 1 and the theoretical analysis, denotes the number of heavy tokens, whereas in the implementation and experimental discussion, denotes the fraction of the total budget assigned to the heavy set. We describe the evaluation setup below.
Setup
Baselines: We compare SSA against three representative sparse-attention baselines: vAttention [9], PQCache [46], and Oracle-top-. Oracle-top- performs exact attention-score computation before selecting the top- tokens and is therefore impractical for acceleration; we include it as an upper-bound reference for deterministic top- selection. For all methods, we use 128 sink tokens and 128 local tokens, along with the hyperparameters recommended by the respective authors. Additional comparisons with MagicPig [6], HashAttention [8], Double Sparsity [45], and Quest [39] are provided in Table 5 in the Appendix. These results motivate our use of PQCache, the strongest approximate top-$k baseline in this comparison, to construct SSA’s proposal distribution throughout our experiments.
Datasets and Models: We evaluate SSA on four benchmark suites: RULER (32K-128K) [16], LongBench (10K-16K) [2], LOFT (32K-128K) [22], and AIME (32K token generation) [28]. Our evaluation spans five models: Llama-3.1-8B-Instruct [12], Qwen3.5-4B and Qwen3.5-9B [40], and Ministral-3-3B-Instruct-2517 and Ministral-3-8B-Instruct-2517 [26]. Dataset subsets and additional evaluation details are provided in Table 6 in Appendix.
| Dataset | # Samples | Subsets |
| RULER-HARD | 100 | fwe, qa1, qa2, niah_multikey_2, niah_multikey_3, vt |
| LongBench | 200 | NrtvQA, Qasper, MF-en, HotpotQA, 2WikiMQA, Musique, DuReader, GovRep, QMSum, MultiNews, VCSum, TREC, TriviaQA, SAMSum, PCount, PR-en, LCC, RBP |
| LOFT | 100 | HotpotQA, Musique, NQ, Qampari, Quest |
| AIME | 16 | – |
Table 6. Evaluation datasets and subsets used in our experiments.
Effectiveness of SSA
RULER-HARD: Table 1 reports average RULER-HARD scores at attention sparsity. SSA consistently outperforms both PQ and vAttention(PQ) across all models and context lengths. Since these methods use the same PQ scores and attention budget, the comparison highlights the benefit of allocating part of the budget to score-guided sampling rather than exclusively to top- retrieval or uniform sampling. The gains are particularly pronounced when deterministic top- struggles. At 32K, SSA improves Llama-3.1-8B from 72.51 (PQ) to 83.67, approaching the dense score of 88.76. Similarly, on Ministral-3-3B, SSA improves the score from 70.81 to 82.05, compared with 86.69 for dense attention. Oracle-top-, which selects tokens using exact attention scores, remains stronger at 128K for Llama-3.1-8B and Ministral-3-3B, and across all context lengths for Ministral-3-8B. On Qwen3.5-4B and Qwen3.5-9B, all sparse methods remain within two points of dense attention.
| Model | Method | 32K | 64K | 128K |
| Llama-3.1-8B | Dense | 88.76 | 86.52 | 71.26 |
| Llama-3.1-8B | PQ | 72.51 | 67.53 | 39.73 |
| Llama-3.1-8B | vAttn (PQ) | 66.71 | 66.22 | 39.45 |
| Llama-3.1-8B | Oracle-top- | 78.80 | 71.91 | 56.10 |
| Llama-3.1-8B | SSA | 83.67 | 77.09 | 47.53 |
| Ministral-3-3B | Dense | 86.69 | 82.19 | 81.49 |
| Ministral-3-3B | PQ | 70.81 | 69.88 | 66.48 |
| Ministral-3-3B | vAttn (PQ) | 69.26 | 65.77 | 63.06 |
| Ministral-3-3B | Oracle-top- | 72.81 | 75.09 | 71.87 |
| Ministral-3-3B | SSA | 82.05 | 75.70 | 69.65 |
| Ministral-3-8B | Dense | 89.33 | 86.13 | 81.45 |
| Ministral-3-8B | PQ | 81.83 | 78.02 | 62.99 |
| Ministral-3-8B | vAttn (PQ) | 78.69 | 75.19 | 63.78 |
| Ministral-3-8B | Oracle-top- | 86.61 | 83.41 | 75.83 |
| Ministral-3-8B | SSA | 84.17 | 79.91 | 69.25 |
| Qwen3.5-4B | Dense | 91.95 | 91.11 | 89.45 |
| Qwen3.5-4B | PQ | 91.22 | 90.72 | 88.72 |
| Qwen3.5-4B | vAttn (PQ) | 90.56 | 90.61 | 89.28 |
| Qwen3.5-4B | Oracle-top- | 91.39 | 90.39 | 89.39 |
| Qwen3.5-4B | SSA | 91.45 | 90.83 | 89.50 |
| Qwen3.5-9B | Dense | 93.45 | 92.22 | 91.28 |
| Qwen3.5-9B | PQ | 92.00 | 91.08 | 90.95 |
| Qwen3.5-9B | vAttn (PQ) | 91.67 | 91.30 | 90.61 |
| Qwen3.5-9B | Oracle-top- | 92.56 | 92.28 | 91.39 |
| Qwen3.5-9B | SSA | 93.33 | 92.36 | 91.45 |
Table 1. Average RULER-HARD performance at 50× attention sparsity across models and context lengths. Full per-task results are provided in the Appendix.
AIME 2025: Table 3 reports avg@16 accuracy for long-form generation. SSA remains robust as sparsity increases, with particularly large gains in the aggressive-sparsity regime. On Qwen3.5-9B at sparsity, SSA achieves 59.8, compared with 48.3 for oracle top-, 36.7 for PQ, and 35.8 for vAttention(PQ). At sparsity, SSA retains an accuracy of 51.5, while vAttention(PQ) drops to 3.5. At lower sparsity, vAttention(PQ) performs better at and at on Qwen3.5-4B. We further study the effect of the heavy fraction in Table 13. Hybrid allocations with achieve 61.0-64.0, substantially outperforming both pure sampling (), which achieves 40.2-42.5, and pure top-
| Sparsity | Qwen3.5-9B Oracle-top- | PQ | vAttn(PQ) | SSA | Qwen3.5-4B Oracle-top- | PQ | vAttn(PQ) | SSA | Method | 50 | 20 |
| Dense | 66.3 | 54.2 | Dense | 41.56 | 41.56 | ||||||
| 5 | 63.8 | 63.5 | 65.4 | 61.0 | 49.8 | 49.4 | 54.4 | 52.7 | PQ | 40.60 | 40.98 |
| 10 | 59.4 | 53.8 | 62.7 | 64.0 | 47.9 | 41.5 | 51.9 | 51.0 | vAttn (PQ) | 40.39 | 41.47 |
| 20 | 55.4 | 49.4 | 58.3 | 63.5 | 42.7 | 33.8 | 50.2 | 53.1 | SSA | 40.92 | 41.56 |
| 50 | 48.3 | 36.7 | 35.8 | 59.8 | 36.5 | 25.4 | 27.5 | 50.0 | Oracle-top- | 41.25 | 41.40 |
| 100 | 42.5 | 28.1 | 3.5 | 51.5 | 31.9 | 13.1 | 1.7 | 42.5 |
Table 3. AIME 2025 avg@16 accuracy (left). LongBench performance with Qwen3.5-27B (right).
A fraction of the sparse attention budget is allocated to deterministic heavy hitters, while the remaining is allocated to importance sampling. Thus, corresponds to pure importance sampling and corresponds to PQCache (pure top- retrieval).
| Heavy Fraction | 20× | 10× |
| 0.0 | 40.2 | 42.5 |
| 0.2 | 61.0 | 63.8 |
| 0.4 | 63.5 | 64.0 |
| 0.6 | 62.7 | 62.7 |
| 0.8 | 63.8 | 63.1 |
| 1.0 (PQ) | 49.4 | 53.8 |
Table 13. Ablation on the heavy-hitter fraction for SSA on AIME 2025.
(), which achieves 49.4-53.8. These results demonstrate the benefit of combining deterministic retrieval with score-guided importance sampling, particularly under aggressive sparsity.
LOFT and LongBench: On LOFT with Qwen3.5-9B and Qwen3.5-4B (see Figure 2), SSA has the lowest attention error among the non-oracle methods at every context length and sparsity level, while subspan-EM varies by at most 0.04 across methods (see Figure 5). On LongBench with Qwen3.5-27B (Table 3), all sparse methods stay within one point of dense attention at both 50 and 20 sparsity.

(a) (a) Qwen3.5-4B: Error

(b) (b) Qwen3.5-9B: Error
Figure 2. Average attention error across different context lengths and sparsity levels for Qwen3.5-9B and Qwen3.5-4B on LOFT [22].

Figure 5. Average Subspan-EM and error across different context lengths and sparsity levels on LOFT.
Decode Efficiency
Sparse attention accelerates decoding only when its selection overhead is smaller than the memory traffic it saves. We evaluate this trade-off for SSA across context lengths and batch sizes, and separately measure the sampling overhead absent in top- methods.
Efficiency analysis: SSA becomes increasingly advantageous as context length and batch size grow. At batch size 1, SSA is slower than FlashInfer at 128K, achieving approximately 0.60-0.74 its speed. As context length increases, this overhead is increasingly amortized, and SSA reaches 1.79, 1.39, and 1.07 speedups at 1M for 50, 20, and 10 sparsity, respectively (see Figure 3a). The gains further increase with batch size, reaching at batch 16 for sparsity (see Figure 3b); our kernel optimizations are particularly important at batch 1, improving SSA by - over the reference implementation (Table 2). Finally, although residual sampling introduces overhead absent from top- methods, our two-level sampler reduces this cost by - over chunk-only routing as the number of draws increases (see Figure 3c), keeping sampling latency at - ms at 1M context and across the evaluated sparsity levels.
| Sparsity | Batch | Latency (ms) | SSA speedup | |||
| FlashInfer | Reference | SSA | vs. FlashInfer | vs. reference | ||
| 1 | 1.41 | 2.99 | 0.79 | 1.79× | 3.80× | |
| 8 | 11.90 | 7.18 | 4.27 | 2.78× | 1.68× | |
| 16 | 24.47 | 12.57 | 8.26 | 2.96× | 1.52× | |
| 1 | 1.41 | 3.34 | 1.01 | 1.40× | 3.32× | |
| 8 | 11.91 | 8.74 | 5.76 | 2.07× | 1.52× | |
| 16 | 24.53 | 15.51 | 11.32 | 2.17× | 1.37× | |
| 1 | 1.42 | 3.83 | 1.30 | 1.10× | 2.95× | |
| 8 | 12.01 | 11.06 | 7.91 | 1.52× | 1.40× | |
| 16 | 24.55 | 19.82 | 15.81 | 1.55× | 1.25× |
Table 2. Kernel optimizations make SSA faster than dense decoding even at batch size 1. We report decode-time attention-layer latency at 1M context length on a single H200 GPU. Reference implements the same algorithm without the kernel optimizations described in § 4.3. At batch size 1, it reaches only 0.37–0.47× the speed of FlashInfer and surpasses FlashInfer only at batch size 8. In contrast, optimized SSA is faster than FlashInfer across all measured batch sizes and sparsity levels. FlashInfer latencies across the two runs agree within 1.2%.

Figure 3. SSA accelerates decode at long contexts, with larger gains at higher batch sizes. Decode attention speedup on a single H200 (16 query heads, 4 KV heads, head dimension 256, fp16 KV). (a) At batch size 1, SSA overtakes FlashInfer beyond 256K context and reaches 1.79 speedup at 1M and 50 sparsity. (b) At 1M context, speedup increases with batch size, reaching 2.96 at batch 16 and 50 sparsity. (c) Overhead of two-level residual sampling relative to 1,024-token chunk-only sampling as the number of draws increases.

Figure 4. Illustration of Stratified Sparse Attention algorithm.
Conclusion
We introduce Stratified Sparse Attention (SSA), a unified framework encompassing top-, pure sampling, and hybrid sparse attention while substantially outperforming existing methods and reducing the accuracy gap to dense attention. SSA is compatible with any approximate top- method that provides proxy scores, allowing it to directly benefit from advances in approximate retrieval. An important direction for future work is to make SSA verifiable by incorporating user-controlled guarantees on approximation quality.
Acknowledgments
The work was primarily supported by Rice Ken Kennedy Institute (K2I) Generative AI Cluster Funding. The Sky Computing Lab is supported by gifts from Accenture, Algorithmic SuperIntelligence Labs, Amazon, AMD, Anyscale, Broadcom, cmpnd, Google, IBM, Intel, Intesa Sanpaolo, Lambda, Lightspeed, Mirendil, NVIDIA, Samsung SDS, and VESSL.
Appendix
Proof of Lemma 1
Proof. Token is included if it appears in at least one of the independent draws, so
By the union bound,
For the lower bound, gives
The function is decreasing for . Since ,
This proves the two-sided bound on .
Finally, the definition of gives . Combining this with the lower bound on yields
Proof of Theorem 2
We first establish the following dimension-free bounded-differences inequality used in the proof.
Lemma 6 (Vector-valued bounded differences). Let be independent random variables, and let be a measurable function taking values in . Suppose that changing only the f$ by at most in Euclidean norm i.e.,
for every and every pair of input sequences differing only in coordinate , where and . Then, for every ,
Proof. Reveal the variables one at a time and define
Here
The sequence is a vector-valued martingale.
We first bound its increments. Fix the first variables and let
Averaging over the same future variables preserves the bounded-differences condition:
Let be an independent copy of , independent of all the original variables. Since and averages over the variable, Jensen’s inequality gives
The Euclidean specialization of the martingale inequality in [32 Theorem 3.5], applied to , therefore yields
Substituting and proves the claim.
Now, we are ready to prove Theorem 2.
Proof of Theorem 2. We consider the sparse regime with an integer budget and finite attention and proxy scores. The case can be handled by evaluating dense attention exactly. Recall that and be the heavy and residual sets produced by SSA, and let and . As shown in § 4.2, and . Since the proxy scores are finite, for every .
Let denote the independent residual draws:
For each residual token, define its occupancy indicator
We know that its inclusion probability is given by , so . Heavy tokens are retained deterministically and have inclusion probability one.
Note that although the residual indicators are dependent, they are deterministic functions of the independent draws . We therefore apply Lemma 6 to these draws.
Write
Define the estimated denominator and numerator by
The SSA output is therefore
Since and all weights are positive, for every realization of the residual draws.
If , all value vectors vanish, and , so the theorem is immediate. Therefore, we assume .
By Lemma 1,
For brevity, define
Thus for every .
Next, we define
The contributions from are evaluated exactly and cancel in . Consequently,
Since ,
Consider two draw sequences and differing only in coordinate , where the draw changes from to . Only and can change, and each changes by at most one. Therefore,
Applying Lemma 6 with and gives, for every ,
Taking , we obtain, for every ,
Substituting eq. (6) yields
Now, we define
Because and , we have
It follows that
Again using , we obtain
Let denote the standard basis vector of . Since the value vectors are the rows of , for every ,
Moreover, is a convex combination of the value vectors, so
Therefore,
Now consider draw sequences and that differ only in one draw, changed from to . As before, only and can change. Hence,
Applying Lemma 6 with and gives, for every ,
Taking gives, for every ,
Equivalently,
Now, fix the failure probability and set
Then . By eq. (11), with probability at least ,
Similarly, by eq. (17), with probability at least ,
A union bound shows that both inequalities hold simultaneously with probability at least . By the definition of ,
Consequently,
On the simultaneous concentration event, the assumption implies
Therefore,
This proves eq. (3) with probability at least .
Proof of Corollary 3
Proof. Let
The assumed lower bound on gives
Under the Algorithm 1 allocation rule, , so . Since
we have
Thus the denominator-stability condition in Theorem 2 holds. The numerator of the bound in Theorem 2 equals . Therefore, with probability at least ,
Additional Experiments
| Sparsity | Context | Method | FWE | VT | NM2 | NM3 | QA1 | QA2 | Avg. |
| 32K | Dense | 93.33 | 99.2 | 100 | 100 | 88 | 52 | 88.76 | |
| 32K | PQ | 77.67 | 95.4 | 67 | 71 | 76 | 48 | 72.51 | |
| 32K | vAttn (PQ) | 83.67 | 94.6 | 52 | 58 | 66 | 46 | 66.71 | |
| 32K | Oracle-top- | 81.00 | 97.8 | 87 | 76 | 79 | 52 | 78.80 | |
| 32K | SSA | 91.00 | 98.0 | 83 | 92 | 85 | 53 | 83.67 | |
| 64K | Dense | 86.33 | 98.8 | 98 | 99 | 84 | 53 | 86.52 | |
| 64K | PQ | 80.00 | 92.2 | 65 | 50 | 71 | 47 | 67.53 | |
| 64K | vAttn (PQ) | 83.33 | 94.0 | 40 | 68 | 67 | 45 | 66.22 | |
| 64K | Oracle-top- | 79.67 | 95.8 | 78 | 56 | 77 | 45 | 71.91 | |
| 64K | SSA | 85.33 | 96.2 | 67 | 84 | 77 | 53 | 77.09 | |
| 128K | Dense | 73.33 | 66.2 | 91 | 67 | 83 | 47 | 71.26 | |
| 128K | PQ | 66.00 | 39.4 | 27 | 15 | 57 | 34 | 39.73 | |
| 128K | vAttn (PQ) | 71.67 | 55.0 | 21 | 20 | 41 | 28 | 39.45 | |
| 128K | Oracle-top- | 61.00 | 66.6 | 71 | 32 | 66 | 40 | 56.10 | |
| 128K | SSA | 73.00 | 54.2 | 30 | 30 | 59 | 39 | 47.53 | |
| 32K | PQ | 87.33 | 98.6 | 97 | 93 | 84 | 52 | 85.32 | |
| 32K | vAttn (PQ) | 93.33 | 99.4 | 97 | 99 | 84 | 52 | 87.46 | |
| 32K | Oracle-top- | 90.33 | 98.8 | 100 | 99 | 84 | 52 | 87.36 | |
| 32K | SSA | 93.67 | 99.0 | 97 | 100 | 87 | 54 | 88.45 | |
| 64K | PQ | 86.33 | 96.2 | 91 | 91 | 77 | 55 | 82.76 | |
| 64K | vAttn (PQ) | 86.00 | 98.4 | 87 | 98 | 79 | 57 | 84.23 | |
| 64K | Oracle-top- | 85.33 | 98.0 | 94 | 95 | 81 | 52 | 84.22 | |
| 64K | SSA | 85.33 | 98.6 | 94 | 99 | 81 | 54 | 85.32 | |
| 128K | PQ | 69.00 | 65.8 | 66 | 46 | 68 | 34 | 58.13 | |
| 128K | vAttn (PQ) | 73.33 | 63.6 | 61 | 51 | 69 | 39 | 59.49 | |
| 128K | Oracle-top- | 67.00 | 63.2 | 85 | 51 | 72 | 42 | 63.37 | |
| 128K | SSA | 75.00 | 69.0 | 70 | 63 | 76 | 44 | 66.17 |
Table 7. Performance on RULER-HARD with Llama-3.1-8B.
| Sparsity | Context | Method | FWE | VT | NM2 | NM3 | QA1 | QA2 | Avg. |
| 32K | Dense | 96.33 | 91.8 | 98 | 99 | 79 | 56 | 86.69 | |
| 32K | PQ | 92.67 | 60.2 | 91 | 56 | 73 | 52 | 70.81 | |
| 32K | vAttn (PQ) | 90.33 | 72.2 | 67 | 77 | 65 | 44 | 69.26 | |
| 32K | Oracle-top- | 93.67 | 62.2 | 99 | 55 | 75 | 52 | 72.81 | |
| 32K | SSA | 95.67 | 88.6 | 92 | 90 | 72 | 54 | 82.05 | |
| 64K | Dense | 74.33 | 99.8 | 93 | 96 | 75 | 55 | 82.19 | |
| 64K | PQ | 72.67 | 94.6 | 77 | 51 | 69 | 55 | 69.88 | |
| 64K | vAttn (PQ) | 76.00 | 95.6 | 54 | 75 | 52 | 42 | 65.77 | |
| 64K | Oracle-top- | 75.33 | 98.2 | 89 | 68 | 68 | 52 | 75.09 | |
| 64K | SSA | 75.00 | 99.2 | 76 | 87 | 67 | 50 | 75.70 | |
| 128K | Dense | 92.33 | 98.6 | 95 | 87 | 66 | 50 | 81.49 | |
| 128K | PQ | 77.67 | 99.2 | 66 | 43 | 66 | 47 | 66.48 | |
| 128K | vAttn (PQ) | 89.33 | 98.0 | 54 | 42 | 54 | 41 | 63.06 | |
| 128K | Oracle-top- | 88.00 | 98.2 | 79 | 51 | 66 | 49 | 71.87 | |
| 128K | SSA | 91.67 | 98.2 | 60 | 67 | 60 | 41 | 69.65 | |
| 32K | PQ | 93.33 | 67.6 | 98 | 86 | 79 | 54 | 79.66 | |
| 32K | vAttn (PQ) | 95.33 | 90.8 | 97 | 98 | 76 | 52 | 84.86 | |
| 32K | Oracle-top- | 96.00 | 73.0 | 99 | 93 | 75 | 52 | 81.33 | |
| 32K | SSA | 95.67 | 94.2 | 99 | 97 | 79 | 56 | 86.81 | |
| 64K | PQCache | 77.00 | 98.4 | 87 | 84 | 70 | 56 | 78.73 | |
| 64K | vAttn (PQ) | 73.00 | 99.8 | 86 | 96 | 73 | 53 | 80.13 | |
| 64K | Oracle | 77.00 | 99.2 | 93 | 91 | 67 | 52 | 79.87 | |
| 64K | SSA | 75.33 | 99.8 | 86 | 96 | 73 | 56 | 81.02 | |
| 128K | PQ | 88.33 | 99.2 | 71 | 65 | 70 | 50 | 73.92 | |
| 128K | vAttn (PQ) | 89.33 | 98.4 | 59 | 77 | 65 | 44 | 72.12 | |
| 128K | Oracle-top- | 91.00 | 98.4 | 85 | 75 | 68 | 50 | 77.90 | |
| 128K | SSA | 90.33 | 98.6 | 75 | 81 | 67 | 46 | 76.32 |
Table 8. Performance on RULER-HARD with Ministral-3-3B.
| Sparsity | Method | NrtvQA | Qasper | MF-en | MF-zh | HotpotQA | 2WikiMQA | Musique | DuReader | GovRep | QMSum |
| 50× | Dense | 20.49 | 29.64 | 38.94 | 42.97 | 34.83 | 34.64 | 26.69 | 25.92 | 31.91 | 21.96 |
| 50× | PQ | 20.13 | 28.69 | 38.60 | 42.01 | 33.27 | 31.92 | 20.61 | 25.54 | 31.92 | 21.64 |
| 50× | vAttn(PQ) | 21.97 | 25.33 | 39.38 | 43.53 | 32.00 | 30.44 | 21.45 | 26.91 | 30.68 | 22.42 |
| 50× | SSA | 20.42 | 27.51 | 38.87 | 42.13 | 34.64 | 32.79 | 24.88 | 24.82 | 31.96 | 22.72 |
| 50× | Oracle-top- | 20.51 | 28.97 | 38.22 | 42.12 | 34.79 | 33.77 | 22.50 | 25.76 | 32.86 | 22.52 |
| 20× | PQ | 20.61 | 29.55 | 38.41 | 41.76 | 34.51 | 33.38 | 23.90 | 25.74 | 31.63 | 22.31 |
| 20× | vAttn(PQ) | 21.55 | 27.17 | 40.14 | 43.67 | 33.39 | 34.18 | 25.65 | 26.70 | 32.20 | 22.27 |
| 20× | SSA | 20.90 | 28.80 | 39.73 | 42.91 | 34.41 | 33.97 | 25.24 | 25.93 | 31.36 | 22.58 |
| 20× | Oracle-top- | 20.74 | 29.28 | 38.68 | 42.87 | 34.90 | 34.57 | 23.46 | 25.82 | 32.77 | 21.97 |
| Sparsity | Method | MultiNews | VCSUM | TREC | TriviaQA | SAMSum | PCount | PRe-en | PRe-zh | LCC | RB-P | Avg. |
| 50× | Dense | 23.33 | 14.50 | 72.50 | 89.65 | 45.63 | 5.16 | 88.12 | 57.33 | 67.96 | 59.12 | 41.56 |
| 50× | PQ | 24.37 | 14.50 | 71.25 | 89.68 | 45.92 | 6.37 | 87.40 | 56.60 | 66.65 | 54.97 | 40.60 |
| 50× | vAttn(PQ) | 23.17 | 14.62 | 71.25 | 89.04 | 43.76 | 6.85 | 85.25 | 59.21 | 66.46 | 53.98 | 40.39 |
| 50× | SSA | 23.08 | 14.35 | 72.50 | 89.77 | 44.32 | 5.16 | 86.25 | 59.69 | 64.55 | 58.01 | 40.92 |
| 50× | Oracle-top- | 24.62 | 14.66 | 72.50 | 89.66 | 46.91 | 5.28 | 87.81 | 53.90 | 68.56 | 59.06 | 41.25 |
| 20× | PQ | 24.20 | 14.79 | 70.00 | 89.46 | 45.83 | 5.10 | 89.06 | 54.21 | 67.87 | 57.24 | 40.98 |
| 20× | vAttn(PQ) | 23.41 | 15.05 | 75.00 | 90.52 | 45.12 | 4.68 | 86.88 | 57.23 | 66.02 | 58.56 | 41.47 |
| 20× | SSA | 24.01 | 14.67 | 72.50 | 90.18 | 46.93 | 4.76 | 88.12 | 56.81 | 66.85 | 60.47 | 41.56 |
| 20× | Oracle-top- | 24.75 | 14.29 | 71.25 | 89.66 | 46.25 | 5.26 | 87.71 | 55.04 | 68.84 | 59.90 | 41.40 |
Table 9. Performance on LongBench with Qwen3.5-27B (10K-16K context).
| Context | Method | FWE | VT | NM2 | NM3 | QA1 | QA2 | Avg. |
| 32K | Dense | 99.67 | 100 | 100 | 100 | 89 | 63 | 91.95 |
| 32K | PQ | 97.33 | 100 | 100 | 100 | 88 | 62 | 91.22 |
| 32K | vAttn (PQ) | 96.33 | 100 | 100 | 100 | 89 | 58 | 90.56 |
| 32K | Oracle-top- | 99.33 | 100 | 100 | 100 | 88 | 61 | 91.39 |
| 32K | SSA | 99.67 | 100 | 100 | 100 | 89 | 60 | 91.45 |
| 64K | Dense | 99.67 | 100 | 100 | 100 | 88 | 59 | 91.11 |
| 64K | PQ | 98.33 | 100 | 100 | 100 | 88 | 58 | 90.72 |
| 64K | vAttn (PQ) | 99.67 | 100 | 100 | 100 | 87 | 57 | 90.61 |
| 64K | Oracle-top- | 99.33 | 100 | 100 | 100 | 86 | 57 | 90.39 |
| 64K | SSA | 99.00 | 100 | 100 | 100 | 88 | 58 | 90.83 |
| 128K | Dense | 96.67 | 100 | 100 | 100 | 84 | 56 | 89.45 |
| 128K | PQ | 95.33 | 100 | 100 | 100 | 82 | 55 | 88.72 |
| 128K | vAttn (PQ) | 96.67 | 100 | 100 | 100 | 82 | 57 | 89.28 |
| 128K | Oracle-top- | 97.33 | 100 | 100 | 100 | 82 | 57 | 89.39 |
| 128K | SSA | 97.00 | 100 | 100 | 100 | 82 | 58 | 89.50 |
Table 10. Performance on RULER-HARD with Qwen3.5-4B at 50× sparsity.
| Context | Method | FWE | VT | NM2 | NM3 | QA1 | QA2 | Avg. |
| 32K | Dense | 99.67 | 100 | 100 | 100 | 93 | 68 | 93.45 |
| 32K | PQ | 94.00 | 100 | 100 | 100 | 91 | 67 | 92.00 |
| 32K | vAttn (PQ) | 98.00 | 100 | 100 | 100 | 89 | 63 | 91.67 |
| 32K | Oracle-top- | 98.33 | 100 | 99 | 100 | 91 | 67 | 92.56 |
| 32K | SSA | 100.00 | 100 | 100 | 100 | 93 | 67 | 93.33 |
| 64K | Dense | 99.33 | 100 | 100 | 100 | 88 | 66 | 92.22 |
| 64K | PQ | 95.67 | 99.8 | 100 | 100 | 86 | 65 | 91.08 |
| 64K | vAttn (PQ) | 98.00 | 99.8 | 100 | 99 | 88 | 63 | 91.30 |
| 64K | Oracle-top- | 98.67 | 100 | 100 | 100 | 89 | 66 | 92.28 |
| 64K | SSA | 99.33 | 99.8 | 100 | 100 | 89 | 66 | 92.36 |
| 128K | Dense | 99.67 | 100 | 100 | 100 | 87 | 61 | 91.28 |
| 128K | PQ | 97.67 | 100 | 98 | 100 | 88 | 62 | 90.95 |
| 128K | vAttn (PQ) | 98.67 | 100 | 98 | 100 | 84 | 63 | 90.61 |
| 128K | Oracle-top- | 99.33 | 100 | 99 | 100 | 88 | 62 | 91.39 |
| 128K | SSA | 99.67 | 100 | 100 | 100 | 88 | 61 | 91.45 |
Table 11. Performance on RULER-HARD with Qwen3.5-9B at sparsity.
| Context | Sparsity | Method | FWE | VT | NM2 | NM3 | QA1 | QA2 | Avg. |
| 32K | 50× | Dense | 94.00 | 100.00 | 99.00 | 100.00 | 80.00 | 63.00 | 89.33 |
| 32K | 50× | PQ | 88.00 | 100.00 | 97.00 | 67.00 | 80.00 | 59.00 | 81.83 |
| 32K | 50× | vAttn (PQ) | 89.33 | 98.80 | 85.00 | 87.00 | 64.00 | 48.00 | 78.69 |
| 32K | 50× | SSA | 94.00 | 100.00 | 88.00 | 91.00 | 74.00 | 58.00 | 84.17 |
| 32K | 50× | Oracle-top- | 90.67 | 100.00 | 99.00 | 90.00 | 81.00 | 59.00 | 86.61 |
| 64K | 50× | Dense | 81.00 | 99.80 | 100.00 | 100.00 | 75.00 | 61.00 | 86.13 |
| 64K | 50× | PQ | 84.33 | 99.80 | 89.00 | 71.00 | 68.00 | 56.00 | 78.02 |
| 64K | 50× | vAttn (PQ) | 81.33 | 99.80 | 71.00 | 87.00 | 63.00 | 49.00 | 75.19 |
| 64K | 50× | SSA | 81.67 | 99.80 | 80.00 | 95.00 | 69.00 | 54.00 | 79.91 |
| 64K | 50× | Oracle-top- | 84.67 | 99.80 | 100.00 | 82.00 | 75.00 | 59.00 | 83.41 |
| 128K | 50× | Dense | 92.67 | 100.00 | 100.00 | 90.00 | 62.00 | 44.00 | 81.45 |
| 128K | 50× | PQ | 79.33 | 99.60 | 63.00 | 32.00 | 63.00 | 41.00 | 62.99 |
| 128K | 50× | vAttn (PQ) | 89.67 | 100.00 | 36.00 | 61.00 | 59.00 | 37.00 | 63.78 |
| 128K | 50× | SSA | 90.67 | 99.80 | 50.00 | 71.00 | 62.00 | 42.00 | 69.25 |
| 128K | 50× | Oracle-top- | 85.00 | 100.00 | 93.00 | 67.00 | 64.00 | 46.00 | 75.83 |
| 32K | 20× | PQ | 92.33 | 100.00 | 99.00 | 97.00 | 83.00 | 60.00 | 88.56 |
| 32K | 20× | vAttn (PQ) | 95.00 | 100.00 | 96.00 | 100.00 | 78.00 | 61.00 | 88.33 |
| 32K | 20× | SSA | 93.33 | 100.00 | 97.00 | 99.00 | 77.00 | 63.00 | 88.22 |
| 32K | 20× | Oracle-top- | 92.00 | 100.00 | 99.00 | 98.00 | 78.00 | 63.00 | 88.33 |
| 64K | 20× | PQ | 83.67 | 99.80 | 99.00 | 97.00 | 74.00 | 60.00 | 85.58 |
| 64K | 20× | vAttn (PQ) | 83.33 | 99.80 | 94.00 | 99.00 | 72.00 | 57.00 | 84.19 |
| 64K | 20× | SSA | 81.67 | 99.80 | 95.00 | 100.00 | 73.00 | 58.00 | 84.58 |
| 64K | 20× | Oracle-top- | 83.00 | 99.80 | 100.00 | 95.00 | 71.00 | 60.00 | 84.80 |
| 128K | 20× | PQ | 85.33 | 100.00 | 88.00 | 80.00 | 66.00 | 44.00 | 77.22 |
| 128K | 20× | vAttn (PQ) | 91.67 | 99.80 | 77.00 | 89.00 | 62.00 | 43.00 | 77.08 |
| 128K | 20× | SSA | 93.33 | 99.80 | 81.00 | 89.00 | 62.00 | 42.00 | 77.86 |
| 128K | 20× | Oracle-top- | 90.67 | 100.00 | 99.00 | 84.00 | 64.00 | 44.00 | 80.28 |
Table 12. Performance on RULER-HARD with Ministral-3-8B.
References
- [1]J. Ainslie, J. Lee-Thorp, M. de Jong, Y. Zemlyansky, F. Lebron, and S. Sanghai. GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints. In The 2023 Conference on Empirical Methods in Natural Language Processing, 2023.arxiv.org/abs/2305.13245
- [2]Y. Bai, X. Lv, J. Zhang, H. Lyu, J. Tang, Z. Huang, Z. Du, X. Liu, A. Zeng, L. Hou, Y. Dong, J. Tang, and J. Li. LongBench: A Bilingual, Multitask Benchmark for Long Context Understand- ing. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics, Aug. 2024.arxiv.org/abs/2308.14508
- [3]W. Cao, X. Yin, B. Dhingra, and S. Zhou. Coding Agents are Effective Long-Context Processors. arXiv preprint arXiv:2603.20432, 2026.arxiv.org/abs/2603.20432
- [4]M. Chen, L. Wang, and B. Qu. The Horizon Gap: Planning, Memory, Execution, Training, and Evaluation for Long-Horizon LLM Agents. arXiv preprint arXiv:2608.06663, 2026.arxiv.org/abs/2608.06663
- [5]X. Chen, X. Hu, Y. Huang, H. Jiang, W. Ji, Y. Jiang, Y. Jiang, B. Liu, H. Liu, X. Li, X. Lian, G. Meng, X. Peng, H. Sun, L. Shi, B. Wang, C. Wang, J. Wang, T. Wang, J. Xuan, X. Xia, Y. Yang, Y. Yang, L. Zhang, Y. Zhou, and L. Zhang. Deep learning-based software engineering: Progress, challenges, and opportunities. CoRL, abs/2410.13110, 2024.DOI
- [6]Z. Chen, R. Sadhukhan, Z. Ye, Y. Zhou, J. Zhang, N. Nolte, Y. Tian, M. Douze, L. Bottou, Z. Jia, and B. Chen. MagicPIG: LSH Sampling for Efficient LLM Generation. In International Conference on Learning Representations, 2025.arxiv.org/abs/2410.16179
- [7]DeepSeek-AI. DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model. arXiv preprint arXiv:2405.04434, 2024.arxiv.org/abs/2405.04434
- [8]A. Desai, S. Yang, A. Cuadron, A. Klimovic, M. Zaharia, J. E. Gonzalez, and I. Stoica. HashAttention: Semantic Sparsity for Faster Inference. In International Conference on Machine Learning, 2025.arxiv.org/abs/2412.14468
- [9]A. Desai, K. K. Agrawal, S. Yang, A. Cuadron, L. G. Schroeder, M. Zaharia, J. E. Gonzalez, and I. Stoica. vAttention: Verified Sparse Attention via Sampling. In The Fourteenth International Conference on Learning Representations, 2026. URL https://openreview.net/forum?id=zzTDuILys0.
- [10]A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, J. Uszkoreit, and N. Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021.
- [11]S. Ge, Y. Zhang, L. Liu, M. Zhang, J. Han, and J. Gao. Model Tells You What to Discard: Adaptive KV Cache Compression for LLMs. In International Conference on Learning Representations, 2024.arxiv.org/abs/2310.01801
- [12]A. Grattafiori, A. Dubey, A. Jauhri, A. Pandey, A. Kadian, A. Al-Dahle, A. Letman, A. Mathur, A. Schelten, A. Vaughan, et al. The Llama 3 Herd of Models. arXiv preprint arXiv:2407.21783, 2024.arxiv.org/abs/2407.21783
- [13]T. Haris. kNN Attention Demystified: A Theoretical Exploration for Scalable Transformers. In The Thirteenth International Conference on Learning Representations, 2025.arxiv.org/abs/2411.04013
- [14]C. R. C. Hooper, S. Kim, H. Mohammad zadeh, M. Maheswaran, S. Zhao, J. Paik, M. W. Mahoney, K. Keutzer, and A. Gholami. Squeezed Attention: Accelerating Long Context Length LLM Inference. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics, 2025.arxiv.org/abs/2411.09688
- [15]X. Hou, Y. Zhao, Y. Liu, Z. Yang, K. Wang, L. Li, X. Luo, D. Lo, J. Grundy, and H. Wang. Large Language Models for Software Engineering: A Systematic Literature Review. ACM Trans. Softw. Eng. Methodol., 33(8), 2024.arxiv.org/abs/2308.10620
- [16]C.-P. Hsieh, S. Sun, S. Kriman, S. Acharya, D. Rekesh, F. Jia, Y. Zhang, and B. Ginsburg. RULER: What’s the Real Context Size of Your Long-Context Language Models? In First Conference on Language Modeling (COLM), 2024.
- [17]P. Indyk and R. Motwani. Approximate Nearest Neighbors: Towards Removing the Curse of Dimensionality. In Proceedings of the thirtieth annual ACM symposium on Theory of computing, pages 604–613, 1998.
- [18]S. Joshi, A. Chowdhury, W. Bollinger, A. Kanakamedala, E. Singh, H. A. D. Le, A. Desai, and A. Shrivastava. SOCKET: Soft Collision Kernel EsTimator for Sparse Attention. arXiv preprint arXiv:2602.06283, 2026.arxiv.org/abs/2602.06283
- [19]J.-H. Kim, J. Kim, S. Kwon, J. W. Lee, S. Yun, and H. O. Song. KVzip: Query-Agnostic KV Cache Compression with Context Reconstruction. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025.arxiv.org/abs/2505.23416
- [20]W. Kwon, Z. Li, S. Zhuang, Y. Sheng, L. Zheng, C. H. Yu, J. E. Gonzalez, H. Zhang, and I. Stoica. Efficient Memory Management for Large Language Model Serving with PagedAttention. In Proceedings of the 29th Symposium on Operating Systems Principles, 2023.arxiv.org/abs/2309.06180
- [21]H. A. D. Le, S. Joshi, Z. Yang, Z. Xu, and A. Shrivastava. Scout before you attend: Sketch-and-walk sparse attention for efficient LLM inference. In Forty-third International Conference on Machine Learning, 2026.
- [22]J. Lee, A. Chen, Z. Dai, D. Dua, D. S. Sachan, M. Boratko, Y. Luan, S. M. R. Arnold, V. Perot, S. Dalmia, H. Hu, X. Lin, P. Pasupat, A. Amini, J. R. Cole, S. Riedel, I. Naim, M.-W. Chang, and K. Guu. Can Long-Context Language Models Subsume Retrieval, RAG, SQL, and More? arXiv preprint arXiv:2406.13121, 2024.arxiv.org/abs/2406.13121
- [23]Y. Li, S. Wang, H. Ding, and H. Chen. Large language models in finance: A survey. In Proceedings of the 4th ACM International Conference on AI in Finance, 2023. doi: 10.1145/3604237.3626869.DOI
- [24]Y. Li, Y. Huang, B. Yang, B. Venkitesh, A. Locatelli, H. Ye, T. Cai, P. Lewis, and D. Chen. SnapKV: LLM Knows What You are Looking for Before Generation. In The Thirty-eighth Annual Conference on Neural Information Processing Systems, 2024.arxiv.org/abs/2404.14469
- [25]X. Lin, Y. Zhang, S. Ge, L. Ren, B. Patra, V. Chaudhary, H. Peng, and X. Song. S2-ATTENTION: HARDWARE-AWARE CONTEXT SHARDING AMONG ATTENTION HEADS. In Sparsity in LLMs (SLLM): Deep Dive into Mixture of Experts, Quantization, Hardware, and Inference, 2025. URL https://openreview.net/forum?id=Ah1E339I7o.arxiv.org/abs/2407.17678
- [26]A. H. Liu, K. Khandelwal, S. Subramanian, V. Jouault, A. Rastogi, A. Sadé, A. Jeffares, A. Jiang, A. Cahill, A. Gavaudan, A. Sablayrolles, A. Héliou, et al. Ministral 3. arXiv preprint arXiv:2601.08584, 2026.arxiv.org/abs/2601.08584
- [27]D. Liu, M. Chen, B. Lu, H. Jiang, Z. Han, Q. Zhang, Q. Chen, C. Zhang, B. Ding, K. Zhang, C. Chen, F. Yang, Y. Yang, and L. Qiu. RetrievalAttention: Accelerating Long-Context LLM Inference via Vector Retrieval. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025.arxiv.org/abs/2409.10516
- [28]Mathematical Association of America. American Invitational Mathematics Examination (AIME) 2025. https://maa.org/maa-invitational-competitions/, 2025. Accessed: 2026-05-20.
- [29]M. Pagliardini, D. Paliotta, M. Jaggi, and F. Fleuret. Fast attention over long sequences with dynamic sparse flash attention. In Advances in Neural Information Processing Systems, volume 36, pages –, 2023.DOI
- [30]J. Park, D. Jones, M. J. Morse, R. Goel, M. Lee, and C. Lott. KeyDiff: Key Similarity-Based KV Cache Eviction for Long-Context LLM Inference in Resource-Constrained Environments. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025.arxiv.org/abs/2504.15364
- [31]W. Peebles and S. Xie. Scalable Diffusion Models with Transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2023.arxiv.org/abs/2212.09748
- [32]I. Pinelis. Optimum bounds for the distributions of martingales in banach spaces. The Annals of Probability, 22(4):1679–1706, 1994. doi: 10.1214/aop/1176988477.DOI
- [33]L. Ruan and Q. Jin. Survey: Transformer based Video-Language Pre-training. AI Open, 3:1–13, 2022. https://www.sciencedirect.com/science/article/pii/S2666651022000018.arxiv.org/abs/2109.09920
- [34]A. Sengupta, S. Chaudhary, and T. Chakraborty. Value-Guided KV Compression for LLMs via Approximated CUR Decomposition. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025.arxiv.org/abs/2509.15038
- [35]J. Shah, G. Bikshandi, Y. Zhang, V. Thakkar, P. Ramani, and T. Dao. FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision. In The Thirty-eighth Annual Conference on Neural Information Processing Systems, 2024.arxiv.org/abs/2407.08608
- [36]A. Shanbhag, H. Pirk, and S. Madden. Efficient top-k query processing on massively parallel hardware. In Proceedings of the 2018 International Conference on Management of Data, SIGMOD ’18. Association for Computing Machinery, 2018. ISBN 9781450347037. URL https://doi.org/10.1145/3183713.3183735.
- [37]N. Shazeer. Fast transformer decoding: One write-head is all you need. arXiv preprint arXiv:1911.02150, 2019.arxiv.org/abs/1911.02150
- [38]P. Singhania, S. Singh, S. He, S. Feizi, and A. Bhatele. Loki: Low-rank Keys for Efficient Sparse Attention. In Advances in Neural Information Processing Systems, 2024.arxiv.org/abs/2406.02542
- [39]J. Tang, Y. Zhao, K. Zhu, G. Xiao, B. Kasikci, and S. Han. QUEST: Query-Aware Sparsity for Efficient Long-Context LLM Inference. In International Conference on Machine Learning, 2024.arxiv.org/abs/2406.10774
- [40]Q. Team. Qwen3.5: Accelerating productivity with native multimodal agents, February 2026. URL https://qwen.ai/blog?id=qwen3.5.
- [41]S. T. Tokdar and R. E. Kass. Importance sampling: a review. Wiley Interdisciplinary Reviews: Computational Statistics, 2, 2010.DOI
- [42]J. S. Vitter. Random sampling with a reservoir. ACM Transactions on Mathematical Software (TOMS), 11(1), 1985.DOI
- [43]S. Yan, G.-Q. Jiang, Y. Zhang, X. Ma, R. Zhu, C. Cao, and J. Xu. Adamas: Hadamard Sparse Attention for Efficient Long-Context Inference. arXiv preprint arXiv:2510.18413, 2025.arxiv.org/abs/2510.18413
- [44]J. Yang, C. Tang, L. Zhen, and J. Lv. Rethinking KV cache eviction via a unified information-theoretic objective. In Forty-third International Conference on Machine Learning, 2026.
- [45]S. Yang, Y. Sheng, J. E. Gonzalez, I. Stoica, and L. Zheng. Post-Training Sparse Attention with Double Sparsity. arXiv preprint arXiv:2408.07092, 2024.arxiv.org/abs/2408.07092
- [46]H. Zhang, X. Ji, Y. Chen, F. Fu, X. Miao, X. Nie, W. Chen, and B. Cui. PQCache: Product Quantization-based KVCache for Long Context LLM Inference. Proceedings of the ACM on Management of Data, 3(3):1–30, 2025.arxiv.org/abs/2407.12820
- [47]Z. Zhang, Y. Sheng, T. Zhou, T. Chen, L. Zheng, R. Cai, Z. Song, Y. Tian, C. Ré, C. W. Barrett, Z. Wang, and B. Chen. H₂O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models. In Advances in Neural Information Processing Systems, 2023.DOI
- [48]X. Zhou, Z. Sun, and G. Li. DB-GPT: Large Language Model Meets Database. Data Science and Engineering, 9:102 – 111, 2024.DOI
- [49]X. Zhou, W. Wang, M. Zeng, J. Guo, X. Liu, L. Shen, M. Zhang, and L. Ding. DynamicKV: Task-Aware Adaptive KV Cache Compression for Long Context LLMs. arXiv preprint arXiv:2412.14838, 2024.arxiv.org/abs/2412.14838
- [50]K. Zhu, T. Tang, Q. Xu, Z. Jin, Y. Gu, Z. Zeng, R. Kadekodi, L. Zhao, A. Li, A. Krishnamurthy, and B. Kasikci. Tactic: Adaptive Sparse Attention with Clustering and Distribution Fitting for Long-Context LLMs. In The Fourteenth International Conference on Learning Representations, 2026.arxiv.org/abs/2502.12216