Stem: Rethinking Causal Information Flow in Sparse Attention
Authors: Lin Niu, Xin Luo, Linchuan Xie, Yifu Sun, Guanghua Yu, Jianchen Zhu, S Kevin Zhou
Organizations: Tencent · School of Biomedical Engineering, Division of Life Sciences and Medicine, University of Science and Technology of China, Hefei, Anhui, 230026, China · Suzhou Institute for Advanced Research, University of Science and Technology of China, Suzhou, Jiangsu, 215123, China · School of Biomedical Engineering, Division of Life Sciences and Medicine, University of Science and Technology of China (USTC), China · Medical Imaging, Robotics, Analytic Computing & Learning (MIRACLE) Lab, YRD-RIGHT, USTC Suzhou Institute for Advanced Research, Suzhou, China · Jiangsu Provincial Key Laboratory of Multimodal Digital Twin Technology, USTC, China · Biomedical Basic Research Center (BBRC) of Jiangsu Province, Suzhou, China · State Key Laboratory of Precision and Intelligent Chemistry, USTC
The quadratic computational complexity of self-attention remains a fundamental bottleneck for scaling Large Language Models (LLMs) to long contexts, particularly during the pre-filling phase. In this paper, we rethink the causal attention mechanism from the perspective of information flow. Due to causal constraints, tokens at initial positions participate in the aggregation of every subsequent token. However, existing sparse methods typically apply a uniform top-k selection across all token positions within a layer, ignoring the cumulative dependency of token information inherent in causal architectures. To address this, we propose Stem, a novel, plug-and-play sparsity module aligned with information flow. First, Stem employs the Token Position-Decay strategy, applying position-dependent top-k within each layer to retain initial tokens for recursive dependencies. Second, to preserve information-rich tokens, Stem utilizes the Output-Aware Metric. It prioritizes high-impact tokens based on approximate output magnitude. Extensive evaluations demonstrate that Stem achieves superior accuracy with reduced computation and pre-filling latency.
Figures & tables
Figure 1: Latency comparison (ms) on H20 GPU. Results are reported as Attention Kernel Time/Total Time.
Figure 2: Visualization of recursive error propagation. The diagram depicts the impact of sparsification across layers l→l+2 based on Eq. (1). Red circles indicate sparse tokens, while blue circles indicate dense tokens. Pruning the initial token V1(l+1) triggers a global distortion that affects all tokens in the next layer (dashed red connections), whereas pruning the last token VN(l) results in only a local error confined to the tail.
Figure 3: Sensitivity analysis of token position segments. The X-axis represents the specific token interval subject to sparsification. Y-axis shows head logit MSE loss. Curves compare dynamic ratios vs. fixed budgets.
Figure 4: Pipeline of Stem. The figure illustrates the framework workflow and compares the sparsity budget schedules between the standard Uniform Top- k and our Token Position-Decay strategy.
Method
L5
L15
L25
L35
Head Logits
SAM
1.5e-5
2.0e-4
8.5e-4
6.0e-3
0.3368
OAM
1.4e-5
2.0e-4
8.1e-4
5.2e-3
0.3126
Table 1: Comparison of sparse loss between SAM and OAM.
Method
CC
FSL
MD1
MD2
SUM
SYN
AVG
BUD.
Qwen3-8B
Dense
19.09
63.10
11.23
15.06
20.63
62.92
32.01
100%
MINF
18.91
61.87
10.78
14.46
20.26
55.32
30.27
69%
FLEX
19.75
55.31
10.76
13.49
21.18
50.83
28.55
31%
XATTN
21.03
62.30
11.42
14.64
20.47
52.92
30.46
28%
Stem
19.43
61.84
11.22
14.97
20.21
62.19
31.64
25%
Table 2: LongBench results (%). We compare accuracy on Llama-3.1-8B-Instruct and Qwen3-8B across task families: Code Completion (CC), Few-Shot Learning (FSL), Multi-Document QA (MD1/MD2), Summarization (SUM), and Synthetic (SYN). AVG and BUD denotes the average accuracy and the sparsity budget.
Method
CC
FSL
MD1
MD2
SUM
SYN
AVG
DeepSeek-V3.2
DSA
32.42
41.85
51.83
48.30
22.28
60.35
42.84
+ Stem
32.02
44.03
51.67
48.44
21.97
60.85
43.16
MiniCPM-4.1
InfLLMv2
55.61
53.74
42.83
20.26
17.10
67.00
42.75
+ Stem
55.62
53.65
43.03
20.13
17.13
67.00
42.76
Table 3: Performance on training-based sparse models.
Method
4K
8K
16K
32K
64K
128K
AVG
Bud.
Llama-3.1-8B-Instruct
Dense
95.52
94.06
93.43
88.19
84.86
77.11
88.86
100%
MINF
95.51
93.56
92.70
91.68
80.06
76.67
88.36
55%
FLEX
94.98
93.91
92.68
89.51
82.66
75.40
88.19
27%
XATTN
95.46
93.83
93.65
89.82
81.60
74.35
88.12
26%
Stem
95.17
93.96
93.73
89.92
82.67
75.37
88.47
25%
Table 4: Accuracy (%) and Budget on the RULER benchmark.
Config
CC
FSL
MD1
MD2
SUM
SYN
AVG
Qwen3-8B
Uniform
19.01
58.92
10.91
14.32
20.12
53.23
29.41
+ TPD
19.28
60.81
11.42
15.04
20.46
61.58
31.43
+ TPD + OAM
19.43
61.03
11.34
14.94
20.44
60.92
31.64
Llama-3.1-8B-Instruct
Uniform
34.02
57.26
21.96
28.21
23.61
59.86
37.48
Table 5: Ablation study on LongBench.
Figure 5: Hyperparameter ablation studies on LongBench.
The quadratic complexity of attention imposes severe memory and computational bottlenecks on Large Language Model (LLM) inference. This challenge is particularly acute for emerging agentic applications that require processing multi-million token sequences. We propose STS, a sparse attention mechanism that requires no model retraining. STS leverages the key insight that tokens identified as important by a smaller draft model are highly predictive of important tokens for a larger target model. By integrating into speculative decoding frameworks, STS repurposes the draft model's attention scores to dynamically construct a token-and-head-wise sparsity mask. This mask effectively prunes the expensive attention computation in the target LLM. Our evaluation shows that STS achieves a 2.67x speedup operating at approximately 90% sparsity on representative benchmark NarrativeQA, maintaining negligible accuracy degradation compared to dense attention. STS establishes a new state-of-the-art on the sparsity-accuracy trade-off, outperforming prior techniques by enabling higher sparsity levels for a given accuracy budget.
Ceyu Xu, Jiangnan Yu, Yongji Wu +1
The Hong Kong University of Science and Technology · UC Berkeley
Long-context LLMs increasingly rely on extended, reusable prefill prompts for agents and domain Q&A, pushing attention and KV-cache to become the dominant decode-time bottlenecks. While sparse attention reduces computation and transfer costs, it often struggles to maintain accuracy at high sparsity levels due to the inherent distribution shift between Queries and Keys. We propose Centroid-Scoring Attention (CSAttention), a training-free sparse attention method optimized for high-throughput serving of reusable contexts. CSAttention adopts a storage-for-computation strategy tailored to the offline-prefill/online-decode setting: it front-loads computation into a one-time offline prefill phase that can be amortized across multiple queries, while aggressively optimizing per-step decoding latency. Specifically, CSAttention constructs query-centric lookup tables during offline prefill, whose size remains fixed during decoding, and enables online decoding to replace full-context scans with efficient table lookups and GPU-friendly score accumulation. Extensive experiments demonstrate that CSAttention achieves near-identical accuracy to full attention. Under high sparsity (95%) and long-context settings (32K-128K), CSAttention consistently outperforms state-of-the-art sparse attention methods in both model accuracy and inference speed, achieving up to 4.6x inference speedup over the most accurate baseline at a context length of 128K.
Chuxu Song, Zhencan Peng, Jiuqi Wei +1
Department of Computer Science, Rutgers University · Oceanbase, Ant Group.
Sparse attention can reduce the cost of long-context inference, but most variants introduce new architectural components. We introduce Simplified Sparse Attention (SSA), a simpler approach to sparse attention that requires no architectural changes. Concretely, we first perform continued pretraining on sequences interleaved with gist tokens. We optimize the standard next-token loss as usual, but the gist tokens use an attention mask to restrict what parts of the context the language model can attend to; this teaches the model to pack each chunk's important information into the gist tokens. At inference time, SSA scores chunks via attention between the current query and the small set of gist tokens, selectively unfolding the top-k chunks by reintroducing their corresponding raw tokens. Since the query is scored only against the gist tokens, we avoid the memory-bandwidth cost associated with naive scoring against the full KV cache, without requiring the auxiliary KV cache approach used by sparse attention methods. On LongBench, SSA consistently outperforms compression and inference-time sparse-attention baselines under the same compression ratio. More strikingly, in retrieval-augmented generation, SSA can even outperform full attention after continued pretraining by over 5.7 points. We attribute this to the ability of SSA's selective unfolding, which concentrates attention on the query-relevant chunks and effectively filters out noise. SSA further extends to a hierarchical gist-of-gist variant (H-SSA) that achieves log-linear decoding complexity while maintaining or improving accuracy at high compression ratios up to 32x. The code is available at https://github.com/yuzhenmao/simplified-sparse-attention/.