Stratified Sparse Attention: Reducing the Sparse-to-Dense Gap at Extreme Sparsity
Authors: Sahil Joshi, Prithvi Dixit, Aryan Katiyar, Agniva Chowdhury, Joseph E. Gonzalez, Anshumali Shrivastava, Aditya Desai, Kumar Krishna Agrawal
Organizations: Department of Computer Science, Rice University, TX, USA. · Department of Electrical Engineering and Computer Sciences, UC Berkeley, CA, USA. · Department of Computer Science, Stanford University, CA, USA. · Department of Computer Science and Engineering, Indian Institute of Technology Bombay, India.
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-k 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-k, top-p, and hybrid top-k+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 50× attention sparsity, recovering 94% and 85% of dense-attention performance, respectively. With optimized CUDA kernels, SSA achieves up to 2.96× 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.
Figures & tables
Figure 1: Relative L2 error when varying the top- k :sampling budget allocation at 50× sparsity (left) and varying sparsity with a fixed 3:2 top- k :sampling budget split (right).
Figure 2: Average attention error across different context lengths and sparsity levels for Qwen3.5-9B and Qwen3.5-4B on LOFT [ 22 ] .
Table 3
Latency (ms)
SSA speedup
Sparsity
Batch
FlashInfer
Reference
SSA
vs. FlashInfer
vs. reference
50 ×
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 ×
20 ×
1
1.41
3.34
1.01
1.40 ×
3.32 ×
8
11.91
8.74
5.76
2.07 ×
1.52 ×
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 Section 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 m increases.
Figure 4: Illustration of Stratified Sparse Attention algorithm.
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 5: Average Subspan-EM and error across different context lengths and sparsity levels on LOFT.
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
Appendix
Table 4: Comparison of theoretical and practical SSA variants on average RULER-HARD-32K performance.
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
Appendix
Table 5: Average performance on RULER-HARD-32K across different models at 50 × sparsity.
Table 6: Evaluation datasets and subsets used in our experiments.
Sparsity
Context
Method
FWE
VT
NM2
NM3
QA1
QA2
Avg.
50 ×
32K
Dense
93.33
99.2
100
100
88
52
88.76
PQ
77.67
95.4
67
71
76
48
72.51
vAttn (PQ)
83.67
94.6
52
58
66
46
66.71
Oracle-top- k
81.00
97.8
87
76
79
52
78.80
SSA
91.00
98.0
83
92
85
53
83.67
64K
Dense
86.33
98.8
98
99
84
53
86.52
Appendix
Table 7: Performance on RULER-HARD with Llama-3.1-8B.
Sparsity
Context
Method
FWE
VT
NM2
NM3
QA1
QA2
Avg.
50 ×
32K
Dense
96.33
91.8
98
99
79
56
86.69
PQ
92.67
60.2
91
56
73
52
70.81
vAttn (PQ)
90.33
72.2
67
77
65
44
69.26
Oracle-top- k
93.67
62.2
99
55
75
52
72.81
SSA
95.67
88.6
92
90
72
54
82.05
64K
Dense
74.33
99.8
93
96
75
55
82.19
Appendix
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
PQ
20.13
28.69
38.60
42.01
33.27
31.92
20.61
25.54
31.92
21.64
vAttn(PQ)
21.97
25.33
39.38
43.53
32.00
30.44
21.45
26.91
30.68
22.42
SSA
20.42
27.51
38.87
42.13
34.64
32.79
24.88
24.82
31.96
22.72
Oracle-top- k
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
Appendix
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
PQ
97.33
100
100
100
88
62
91.22
vAttn (PQ)
96.33
100
100
100
89
58
90.56
Oracle-top- k
99.33
100
100
100
88
61
91.39
SSA
99.67
100
100
100
89
60
91.45
64K
Dense
99.67
100
100
100
88
59
91.11
Appendix
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
PQ
94.00
100
100
100
91
67
92.00
vAttn (PQ)
98.00
100
100
100
89
63
91.67
Oracle-top- k
98.33
100
99
100
91
67
92.56
SSA
100.00
100
100
100
93
67
93.33
64K
Dense
99.33
100
100
100
88
66
92.22
Appendix
Table 11: Performance on RULER-HARD with Qwen3.5-9B at 50 × 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
PQ
88.00
100.00
97.00
67.00
80.00
59.00
81.83
vAttn (PQ)
89.33
98.80
85.00
87.00
64.00
48.00
78.69
SSA
94.00
100.00
88.00
91.00
74.00
58.00
84.17
Oracle-top- k
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
Appendix
Table 12: Performance on RULER-HARD with Ministral-3-8B.
Heavy Fraction h
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
Appendix
Table 13: Ablation on the heavy-hitter fraction h for SSA on AIME 2025. A fraction h of the sparse attention budget is allocated to deterministic heavy hitters, while the remaining 1−h is allocated to importance sampling. Thus, h=0 corresponds to pure importance sampling and h=1 corresponds to PQCache (pure top- k retrieval).
University College London, London, UK · Shenzhen Institutes of Advanced Technology, Chinese Academy of Sciences (CAS), Shenzhen 518055, China · The Chinese University of Hong Kong +1