POEM: Output-Relative Block-Sparse Attention for Long-Context Prefilling
Analyze & explore related research in Conceptio
Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.
POEM: O UTPUT-R ELATIVE B LOCK -S PARSE ATTENTION FOR L ONG -C ONTEXT P REFILLING Haoyi Wu1,∗
Yunkai Dang1,∗
Wanyu Zhang1
Lei Wang3
Wenbin Li1,2,†
1
State Key Laboratory of Novel Software Technology, Nanjing University, Nanjing, China Shenzhen Research Institute of Nanjing University, Shenzhen, China 3 University of Wollongong, Australia
arXiv:2611.13578v1 [cs.CR] 10 Nov 2026
2
A BSTRACT As large language models (LLMs) evolve to support increasingly long contexts, accelerating prefilling without compromising output accuracy becomes a critical challenge. Block-sparse attention addresses this by retaining only the most important key-value blocks, but existing importance proxies often discard blocks and cause output errors. These proxies generally estimate a block’s contribution to the dense attention output (i.e., attention-weighted value), implicitly assuming that removing the block loses exactly this contribution. In this work, we show that this assumption does not hold because attention renormalization amplifies the retained blocks’ contributions. As a result, the output error depends not only on the removed attention mass but also on the distance between the removed block’s output and the dense output. We call the distance output deviation and empirically find that it varies by over 20× even among blocks with comparable attention mass, so existing proxies often discard blocks whose large output deviation leads to large output errors. To address this gap, we propose Prefilling via Output Error Minimization (POEM), a training-free method that combines each block’s contribution and output deviation into an output-relative score, reducing the output error of each head. To connect the head-level optimization to the model’s predictions, we derive a bound on the prediction divergence that weights each head’s output error by its sensitivity, which guides POEM to calibrate the retention threshold of each head. On long-context benchmarks, POEM maintains accuracy parity with dense attention while achieving up to a 6.5× attention speedup over FlashAttention-2.
1
I NTRODUCTION
Large language models (LLMs) (Brown et al., 2020; Touvron et al., 2023) have achieved striking advances in recent years, demonstrating strong performance across a wide range of tasks. These advances have enabled their deployment in increasingly ambitious applications, from scientific discovery (Novikov et al., 2025; Yamada et al., 2025) to autonomous agents (Wang et al., 2023; Zhang et al., 2026). Such applications often demand processing information across extremely long sequences such as extensive scientific corpora and long-horizon task trajectories (Bai et al., 2025). However, as context lengths continue to grow, the quadratic cost of self-attention (Vaswani et al., 2023) makes prefilling prohibitively expensive, rendering attention the dominant computational bottleneck in LLM inference (Fu, 2024). To alleviate this bottleneck, recent studies have developed efficient attention mechanisms (Yuan et al., 2025; Hatamizadeh et al., 2026; Sun et al., 2025), ranging from sparsifying token interactions to reformulating attention with subquadratic alternatives. Among these mechanisms, block-sparse attention is particularly attractive, as it retains exact attention over the relevant regions while entirely skipping the rest. Block-sparse attention (Child et al., 2019) operates by partitioning the key–value sequence into fixed-size blocks, retaining only important blocks for each query, and computing exact attention over the retained subset. A key challenge is to accurately identify the most important blocks without computing the full attention matrix (Roy et al., 2021). Recent works on block-sparse attention have explored a wide range of strategies. Some * ∗ Equal contribution. ††
Corresponding author: liwenbin@nju.edu.cn.
1
a) keep all blocks output deviation
Dense output ��
b) remove near block B3
�′� Oi
Renormalized output �′� Small output shift
c) remove far block B1
Oi �′�
Attention Mass Proxy
high-deviation mode
Oi
B1
100
B2
similar mass >20x deviation
10 1
B3 B4
low-deviation mode
Output deviation
attention mass
Vfar
B2
B1
Oi
Output-Relative Proxy B3
Vnear
Renormalized output �′� Large output shift
B4
B3
Vnear
B2 B4 B1
Vfar
Figure 1: Through experiments, we observe that blocks with similar attention mass can differ by over 20× in output deviation. Removing a high-deviation block (B1) shifts the attention output far more than removing a low-deviation one (B3) of comparable mass. We therefore combine attention mass with output deviation into our output-relative proxy. V denotes the exact output of a block. methods incorporate block selection into model training (Yuan et al., 2025; Lu et al., 2026) or train auxiliary gates to predict block importance (Gao et al., 2024b). However, these methods incur additional training costs, complicating their application to existing pretrained LLMs. To avoid this overhead, training-free methods instead estimate block importance using lightweight proxies (Lai et al., 2025). These methods select blocks by measuring their contribution to dense attention. Most of them estimate attention mass (Jiang et al., 2024; Lai et al., 2025; Xu et al., 2025; Wang et al., 2026a), while STEM (Niu et al., 2026) further incorporates value to account for differences in value contributions. Nevertheless, a block’s contribution to dense attention is not equivalent to the output shift by its removal. When a block is dropped, softmax renormalization amplifies the contributions of the retained blocks, compensating for part of the removed blocks’ contribution. So what determines whether a removed block’s contribution is easily compensated? As Figure 1 (left) illustrates, if a block’s output lies close to the dense output, renormalization amplifies the retained blocks’ contributions while largely preserving the output direction, resulting in only a small output shift. However, if the block’s output points away from the dense output, the same amplification cannot compensate for its removal, and the output shifts substantially. We call the distance between a block’s output and the dense output the block’s output deviation. Empirically, we observe that output deviation varies by more than 20× across blocks of comparable attention mass, forming distinct low-deviation and high-deviation modes (center). Therefore, existing proxies that rely on block contribution alone cannot distinguish safely removable blocks from critical ones. To address this gap, we propose Prefilling via Output Error Minimization (POEM), a training-free block-sparse attention method. (1) Output-relative block selection: Motivated by the renormalization analysis above, we derive a head-level output-relative score that combines each block’s attention mass with the deviation of its output from the dense head output. A two-stage pipeline makes this score practical: mass estimates identify a candidate pool at low cost, and the output-relative score then selects the final blocks within it. To connect this head-level optimization to model predictions, we derive a theoretical bound on predictive divergence that weights each head’s output error by its sensitivity. This bound motivates (2) Offline threshold calibration: POEM calibrates a separate retention threshold for each head group according to its sensitivity. Because calibrating every head group independently would be prohibitively expensive, POEM ranks heads by sensitivity and jointly calibrates similarly ranked heads via an efficient batched bisection procedure. Experiments on LongBench (Bai et al., 2024) and RULER (Hsieh et al., 2024) using Llama-3.18B (Grattafiori et al., 2024), Qwen3-8B, and Qwen3-14B (Yang et al., 2025) show that POEM maintains accuracy comparable to that of full attention at high sparsity. On RULER at 128K context, POEM achieves a 2.4-point gain over our mass-only baseline, demonstrating the effectiveness of the output-relative score. POEM also achieves the lowest attention latency among the compared methods, achieving up to a 6.5× speedup over FlashAttention-2 (Dao, 2024) at a 128K context. Our contributions can be summarized as: • We propose POEM, a training-free block-sparse attention method that combines attention mass with output deviation for output-relative block selection, optimizing output error within heads.
2
• To bridge head-level optimization and model-level prediction, we derive a bound on output divergence in terms of head error weighted by sensitivity, motivating our offline threshold calibration. • Across three LLMs on LongBench and RULER, POEM almost matches full-attention accuracy at high sparsity and achieves up to a 6.5× attention speedup at 128K prefill.
2
R ELATED W ORK
Training-free sparse attention. Training-free methods use the sparsity already present in pretrained attention. Prefilling must select blocks for every query position, so the selector itself has to be cheap yet accurate. To score blocks, SALE (Ji et al., 2025) uses low-bit estimates, Sketch&Walk (Le et al., 2026) propagates randomized sketches across layers, UniSparse (Liu et al., 2025b) compresses and routes at multiple granularities, and Prism (Wang et al., 2026a) keeps high-frequency positional signals with spectral-aware scores. Other work lowers cost elsewhere: SpargeAttention (Zhang et al., 2025) co-designs the selector with the kernel, Pbs-Attn (Wang et al., 2026b) packs important tokens into fewer blocks, and ProxyAttn (Wang et al., 2026c) lets a few representative heads score for the rest. These selectors rank blocks mainly by attention mass, and STEM (Niu et al., 2026) adds value norms to estimate how much each block contributes to dense attention. POEM instead aims to minimize the output error caused by removal, combining attention mass and output deviation together to select the blocks. Training-based sparse attention. Training-based methods learn sparsity patterns during pretraining or adaptation. More recent designs include Native Sparse Attention (Yuan et al., 2025), which combines compression, selection, and local attention; MoBA (Lu et al., 2026), which routes each query to its top-k blocks. InfLLM-V2 (Zhao et al., 2026), which switches between dense and sparse attention depending on sequence length, and HiLS (Hu et al., 2026), which learns hierarchical retrieval from the language-modeling loss. SeerAttention (Gao et al., 2024b) instead trains block-level gates on a frozen backbone for prefilling, and SeerAttention-R (Gao et al., 2025) extends them to decoding. The selectors also differ in supervision: DeepSeek Sparse Attention (Liu et al., 2025a) uses a token-level indexer with attention scores, whereas SAS (Li et al., 2026) ranks context with the language-modeling loss. All of these methods train either the model or an auxiliary selector, while POEM is training-free and applies directly to pretrained models at no additional training cost.
3
P RELIMINARIES
Attention and block-sparse formulation. Let Q, K, V ∈ RN ×dh be the query, key, and value matrices with row vectors q, k, v, where N is the sequence length and dh the head dimension. Under causal masking, the attention weight and output are defined for each query position as follows: √ i X exp(qi k⊤ t / dh ) Ait = Pi , oi = Ait vt . (1) √ ⊤ u=1 exp(qi ku / dh ) t=1 Block-sparse attention (Xu et al., 2025) partitions KV sequences into B blocks {Bb }B b=1 and restricts each query i to a retained block set S ⊆ {1, . . . , B}. For block b, define the block i P P P attention mass mib = t∈Bb Ait and the block output v̄ib = m−1 A v , so that o = i t∈Bb it t b mib v̄ib . Given ib P the discarded mass δi = b∈S m , the renormalised sparse output and the projected output of a ib / i layer ℓ with H heads are respectively given by the following expressions: P H X mib v̄ib (h) ei = b∈Si o , oout = oℓ,h WO,ℓ , (2) ℓ 1 − δi h=1 (h) dh ×d where WO,ℓ ∈ R projects the output oℓ,h of head h to the model dimension d.
4
M ETHOD
In this section, we first present the output-relative block score (Section 4.1). We then introduce a hierarchical error decomposition (Section 4.2) that connects predictive divergence to head output error, followed by the offline headwise threshold calibration (Section 4.3). Finally, we summarize the resulting POEM pipeline with two stages (Section 4.4) and show it in Figure 2. 3
Query B1
STAGE 1 B2
B1
K
B3
K
K
B4
B5
K
K
B2
QK block scoring
B3
Conservative Top-p1
B4
B3 B1
B2
B3
B4
B5
B1
Sparse Attention Matrix
p2,1 Head 1 Head 2
p
2,2
···
B5
Headwise Threshold
Output Deviation B1
B4
B2 B3
Output
STAGE 2
Attention Mass
B2
p2,n
B4 Head n
Rerank
= deleted
Figure 2: Overview of POEM. Stage 1 preselects candidate blocks using coarse attention mass. Stage 2 reranks candidates with output-relative scores and selects blocks using calibrated headwise thresholds. p1 is the Stage 1 threshold, and p2,h is the calibrated threshold for head h. 4.1
O UTPUT- RELATIVE BLOCK SELECTION
A central design question for training-free blocksparse attention is how to reliably select signifi- Table 1: Comparison of proxies. ∗ means cant blocks under a fixed budget while preserving antidiagonal scoring, and v max denotes the the dense output. Existing methods such as MIn- maximum value norm within the block. ference (Jiang et al., 2024), FlexPrefill (Lai et al., 2025), and XAttention (Xu et al., 2025) score each Method Value- OutputProxy Score Aware Relative block solely by the attention mass. STEM (Niu et al., ⊤ qk 2026) furthermore augments the QK score with the MInference √ ✗ ✗ d largest value norm inside the block, which makes the qk⊤ √ ✗ ✗ proxy value-aware. However, all of existing meth- FlexPrefill d qk⊤ ∗ ods overlook the effect of renormalization, leaving XAttention √ ✗ ✗ d out output deviation, except POEM. POEM’s proxy qk⊤ ∗ √ STEM + β ReLU(log v max ) ✓ ✗ scores each block by combining attention mass with d ⊤ q qk ∗ output deviation, making the proxy both value-aware POEM √ b + β log v + √ C − o ✓ ✓ d d and output-relative, as summarized in Table 1. This subsection then introduces POEM’s output-relative proxy and describes how it is ultimately used in the complete POEM pipeline. From output error to block importance. Our objective is to select a subset of blocks Si that ei and the dense output oi . As defined in minimizes the output error between the sparse output o Section 3, we express this objective as the following subset selection problem: P b∈S / i mib (v̄ib − oi ) 2 P ei ∥2 = min min ∥oi − o . (3) Si Si 1 − b∈S / i mib The numerator couples all discarded blocks inside a single norm, so the objective cannot be decomposed into independent per-block scores. To measure each block’s contribution to the output error, we apply the triangle inequality and obtain: P / i mib ∥v̄ib − oi ∥2 P ei ∥2 ≤ b∈S . (4) ∥oi − o 1 − b∈S / i mib Let p denote thePoverall mass threshold used to determine the retained block set. Under a fixed threshold p, 1 −P b∈S / i mib remains almost constant around p. Thus, minimizing the bound reduces to minimizing b∈S / i mib ∥v̄ib − oi ∥2 . We therefore adopt iib = mib ∥v̄ib − oi ∥2 as the importance proxy of block b, which combines attention mass and output deviation multiplicatively. An approximation to the block score. To obtain a proxy compatible with existing top-p kernels, we apply a logarithmic transformation to Iib and express it as the sum of two terms. To avoid the expensive computation of the exact block output, we approximate it with a first-order Taylor expansion, yielding the selection score sib used for practical candidate ranking: q̄i k̄⊤ sib = √ b + log ∥v̄ib − oi ∥2 , dh 4
q̄i v̄ib ≈ v̄b + √ Cb , dh
(5)
P where v̄b denotes the pooled value vector in block b, nb = |Bb |, and Cb = n1b t∈Bb (kt −k̄b )⊤ (vt − v̄b ) is the key–value covariance of block b. Appendix A provides the theoretical derivations, Appendix B develops the selection score, and Appendix C provides the experimental configuration. √ Two-stage selection. Computing the magnitude q̄i Cb / dh over all query–key block pairs requires O(n2 ) computation, which is unaffordable. To avoid unnecessary computation on negligible blocks, we restrict this calculation to a small subset of potentially important blocks, which we call the candidate pool. Therefore, we design a selector with two stages. Stage 1 selects the candidates, and Stage 2 further selects significant blocks using output deviation. Given an overall mass target p, Stage 1 applies Pa conservative threshold p1 ≥ p to retain candidates while forming the coarse bi = reference o b≤i aib v̄b as a prior for output oi , where aib is the pooled attention weight of query i over its visible blocks. Stage 2 sets p2 = p/p1 as its threshold, reranks candidates by the output-relative score, and applies p2 to their renormalized attention weights, retaining nominal mass p under the assumption that discarded blocks remain negligible. Appendix B provides the output reference construction and complete selection procedure. Appendix D verifies the Stage 1 candidatepool coverage, while Appendix E analyzes the auxiliary memory overhead across sequence lengths. Output-relative score. To adjust the strength of the output-deviation term and better approximate the actual block importance Iib , we introduce a scalar β on the log term to balance attention mass and output deviation. This gives POEM’s selection proxy for practical candidate reranking: q̄i k̄⊤ q̄i bi . sib = √ b + β log v̄b + √ Cb − o dh dh 2
(6)
The first term estimates block-level attention strength, while the second estimates the approximate bi . Following XAttention (Xu et al., 2025), we estimate the first block output’s deviation from o term by antidiagonal scoring. These two magnitudes combine to form our output-relative scorer. Table 2 compares the reconstruction errors of the three se- Table 2: Layer and logit output errors lection scores at the same density. POEM consistently out- on LongBench, using Qwen3-8B. performs the mass-only baseline and STEM’s value-aware Layer 5 Layer 15 Final proxy at all three evaluated layers and at the final logits, Method Layer 35 logits (×10−4 ) (×10−2 ) supporting the superiority of the output-relative proxy for only 3.27 1.24 5.88 2.86 block selection. Appendix C provides the detailed evalu- Mass STEM 3.27 1.23 5.88 2.85 ation configuration, including the matched block density POEM 3.25 1.22 5.79 2.74 setting and definitions of the layer and logit reconstruction errors. Figure 4(d) examines the end-to-end impact of the output-relative proxy. 4.2
H IERARCHICAL E RROR D ECOMPOSITION
To keep the sparse output close to the dense output at the model level, we hierarchically decompose the prediction error and relate it to head-level reconstruction error. Our overall objective is to select attention blocks that minimize the discrepancy between dense and sparse prediction distributions under a fixed block budget, which can be formalized as the following constrained objective: min dKL pd ∥ ps (S) . (7) S: |S|=k
Here, S is the selected block set of size k, pd and ps (S) are the prediction distributions under dense and sparse attention, dKL (· ∥ ·) is the Kullback–Leibler (KL) divergence. The objective is defined on the predictions, whereas block selection is made separately for each head, so we bridge this gap by decomposing the prediction error first into layer-level and then into head-level output errors. Step 1: Prediction to layer output. The objective in Eq. 7 is defined on the final predictions, but what block selection actually changes is the attention output of a single layer, so we begin by e ℓ denote the tracing how a perturbation of that output propagates to the predictions. Let Oℓ and O e ℓ − Oℓ for the layer-output attention outputs of layer ℓ under dense and sparse attention, ∆Oℓ := O perturbation and ϵℓ := vec(∆Oℓ ) for its vectorization. A first-order expansion of the downstream network gives the change in the final logits z as ∆z = Jℓ→z ϵℓ + O ∥ϵℓ ∥22 , where Jℓ→z is the Jacobian from the vectorized layer output to the logits. The perturbed logits shift the prediction 5
distribution from pd = softmax(z) to ps = softmax(z + ∆z), and because the KL divergence attains its minimum at ∆z = 0, its expansion in ∆z has no constant or first-order term, dKL (pd ∥ ps ) = 12 ∆z⊤ F ∆z + O ∥∆z∥32 , F := Diag(pd ) − pd (pd )⊤ , (8) where F is the softmax Fisher matrix, which captures how strongly each direction of logit change perturbs the prediction distribution. We further bound the quadratic form by the spectral norms of F and Jℓ→z , yielding the scalar upper bound dKL (pd ∥ ps ) ≤ cℓ ∥∆Oℓ ∥2F + O ∥∆Oℓ ∥3F , cℓ := 21 ∥F∥2 ∥Jℓ→z ∥22 , (9) where the constant cℓ measures how sensitive the predictions are to this layer’s output. The full derivation is provided in the theoretical appendix. The layer output still aggregates the contributions of all attention heads, so Step 2 splits this layer-level error further into per-head output errors. Step 2: Layer to head. Block selection operates per attention head, so the layer-level bound must be eℓ,h denote carried one step further, down to the heads that compose the layer output. Let oℓ,h and o eℓ,h − oℓ,h be its output error. head h’s dense and sparse outputs before projection, and let ∆oℓ,h := o Since Eq. 2 writes the layer output as a sum of projected head outputs, the perturbation decomposes P (h) as ∆Oℓ = h ∆oℓ,h WO , and applying the triangle and Cauchy–Schwarz inequalities gives X 2 (h) 2 2 ∥∆Oℓ ∥F ≤ H WO ∥∆oℓ,h ∥F , (10) 2
h (h)
where H is the number of heads and WO is the row block of the output projection for head h. This bound isolates each head’s contribution through its projection norm and output error. Combining this inequality with Eq. 9 bounds the predictive divergence by a weighted sum of head-level errors. The two factors motivate the two components of POEM. Output-relative block selection (Section 4.1) targets the per-head error ∥∆oℓ,h ∥F . Headwise threshold calibration (Section 4.3) accounts for the (h) unequal head sensitivities represented by the projection weights ∥WO ∥22 in the resulting predictivedivergence bound across all attention heads within the layer. 4.3
O FFLINE THRESHOLD CALIBRATION
Error-ranked batch bisection. Offline calibration replaces the shared p2 = p/p1 with a headwise threshold p2,h , where p2,h is the Stage 2 threshold of head h. Following GQA’s KV grouping (Ainslie et al., 2023) and KV-cache compression methods (Cai et al., 2025; Rehg, 2024), we jointly calibrate groups of heads that share KV projections. To avoid calibrating groups individually, Algorithm 2 in Appendix F sorts groups by their estimated output-distribution error and tests them in batches, starting from all groups. Each trial lowers the batch thresholds. If the score on the search set does not decrease, the reduction is accepted for the entire batch. Otherwise, the batch is bisected and the half with lower error is retried first in subsequent calibration. The calibration ends when all groups have been processed or the predefined maximum number of steps is reached. 4.4 POEM: O UTPUT-R ELATIVE B LOCK -S PARSE ATTENTION We integrate the output-relative selection score and the offline threshold calibration together Algorithm 1 POEM: Output-Relative Block-Sparse Attention into POEM, a unified training-free framework. 1: Input: Q, K, V. Figure 2 summarizes the execution order, and 2: Parameters: p1 , β, {p2,h }h , pooling stride B. Algorithm 1 gives the detailed inference pro- 3: Output: Sparse outputs oei,h . 4: for each head h (using head-local Q, K, V) do cedure. First, POEM selects candidates by 5: Cache block covariances Cb . lightweight attention mass alone to quickly 6: for each query block i do # Stage 1 construct the candidate pool and compute the 7: 8: ai ← Pool(Q, K, stride = B). ▷ # Antidiagonal bi for subsequent output- 9: Ci ← TopP(a output reference o i , p1 ). P relative ranking. Second, POEM computes the 10: obi ← b≤i aib v̄b . # Stage 2 output-relative score in Eq. (6) within the candi- 11: 12: Compute sib over b ∈ Ci using Eq. 6. date pool, which combines attention mass with 13: Rerank(sib , Ci ). ▷ # Mass threshold output deviation to account for each block’s im- 14: Si ← ThresholdP(Ci , p2,h ). ei,h ← Attention(Qi , K, V; Si ). o portance in reconstructing the output. For a 15: 16: end for head h, POEM reranks the blocks in the can- 17: end for didate pool by the output-relative score and applies the calibrated threshold p2,h to the reordered sequence, where p2,h is the calibrated threshold.
6
5
E XPERIMENTS
Baselines. We compare POEM with dense FlashAttention-2 (Dao, 2024) and four training-free sparse prefilling baselines under the same FlashAttention-2 backend: MInference (Jiang et al., 2024) (official sparse-head configuration), FlexPrefill (Lai et al., 2025) (B = 128, γ = 0.9, τ = 0.1), XAttention (Xu et al., 2025) (τ = 0.9), and STEM (Niu et al., 2026) (B = 128, µ = 0.7, β = 0.2, kstart = 0.2Nblk for 8–16K inputs and 0.1Nblk beyond 16K, with a minimum budget of 54 blocks). We use each baseline’s released or recommended configuration without taskspecific retuning. SpargeAttention (Zhang et al., 2025) is excluded because its online P V skipping falls outside this shared-backend block-selection comparison and its controlled evaluation scope. Implementation details. We implement all experiments in PyTorch on an NVIDIA A100 GPU. After block selection, FlashAttention-2 computes attention over the retained blocks. Following XAttention and STEM, we retain local and sink blocks for stability: four local and four sink blocks for Llama-3.1-8B (Grattafiori et al., 2024), and one of each for Qwen3-8B/14B (Yang et al., 2025). In Stage 1, we estimate block attention mass from low-precision query and key vectors to select the candidate pool. In Stage 2, we compute output-relative scores within the candidate pool. We set the output-relative deviation coefficient to β = 0.3 for Qwen3-14B and Llama-3.1-8B, and to β = 0.2 for Qwen3-8B. For Qwen-family models, we use YaRN (Peng et al., 2026) to extend their context windows to 128K, enabling long-context evaluation. We set the overall mass target to p = 0.9 and use the Stage 1 threshold p1 = 0.94, yielding p2 = p/p1 for Stage 2. Table 3: LongBench and RULER results on three models. Best in bold, second best underlined. Model
LongBench
Method
RULER
S-Doc M-Doc Summ. FSL Synth. Code Avg.
4K
8K
16K
32K
64K 128K Avg.
Dense MInference FlexPrefill Llama-3.1-8B XAttention STEM POEM
28.57 28.38 24.25 27.51 27.20 26.82
25.75 25.44 22.61 23.55 24.33 23.98
25.45 25.28 25.14 25.51 25.41 25.44
63.61 63.31 62.24 63.82 62.56 64.04
65.83 65.12 19.56 55.83 64.32 65.71
33.06 40.38 95.26 94.29 93.58 87.99 84.85 77.87 88.97 31.16 39.78 95.43 94.25 93.44 87.56 83.21 71.51 87.57 35.01 31.47 93.67 93.63 93.84 87.90 84.83 72.43 87.71 35.77 38.66 95.09 94.39 93.27 88.95 82.45 70.09 87.38 32.74 39.43 95.27 94.50 93.12 88.21 82.94 70.33 87.40 35.00 40.16 95.01 94.32 93.20 88.79 82.74 72.38 87.74
Qwen3-8B
Dense MInference FlexPrefill XAttention STEM POEM
14.48 13.97 12.87 13.36 14.13 13.65
13.12 12.73 12.11 12.77 13.00 13.12
22.14 21.45 21.47 21.38 21.39 21.62
60.59 58.06 61.44 58.72 57.79 58.56
66.51 65.75 42.87 63.54 65.62 62.97
12.54 31.56 95.18 92.51 89.81 86.78 79.55 75.29 86.52 12.02 30.66 94.83 92.55 89.41 85.68 76.12 70.89 84.91 14.64 27.57 90.94 87.85 87.45 85.12 78.94 73.98 84.05 14.42 30.70 94.56 90.80 87.92 84.54 78.02 71.70 84.59 12.46 30.73 94.67 90.43 87.61 85.09 77.42 71.24 84.41 15.08 30.83 94.27 91.32 88.11 85.30 77.92 72.71 84.94
Qwen3-14B
Dense MInference FlexPrefill XAttention STEM POEM
15.55 15.50 15.09 15.37 15.35 15.36
12.62 12.51 13.05 13.11 12.82 13.21
21.92 21.76 21.77 21.82 21.71 21.83
62.41 62.04 61.15 60.94 60.86 62.12
66.83 65.58 48.12 65.42 66.92 65.92
53.30 38.77 95.61 93.83 93.27 93.16 90.45 84.01 91.72 51.40 38.13 95.34 93.28 91.16 90.11 87.44 80.46 89.63 50.95 35.02 93.43 92.74 92.30 91.13 87.41 80.64 89.60 52.67 38.22 95.19 93.02 91.23 89.89 87.36 80.33 89.50 51.77 38.24 95.78 92.85 91.08 89.92 87.22 80.01 89.48 53.61 38.68 95.23 93.12 91.60 89.95 87.64 80.51 89.68
Comparison on LongBench and RULER. Table 3 compares POEM with dense attention and four training-free sparse baselines, including MInference, FlexPrefill, XAttention, and STEM, on LongBench and RULER, covering models from different families and at different scales: Llama-3.1-8B and Qwen3-8B/14B. On LongBench, POEM ranks first among all sparse methods on every model, narrowing the gap to dense attention to as little as 0.09 points on Qwen3-14B. On RULER, POEM achieves the best average score across all three evaluated models. Across the two benchmarks, POEM is the only sparse method that consistently matches or outperforms every baseline on all model configurations. We attribute this robustness to the output-relative block scoring and headwise threshold calibration, which together better reconstruct the dense attention output. Effect of output-relative reranking. To examine whether output deviation provides a selection signal beyond attention mass, we conduct a block-level diagnostic using exact quantities computed with the dense output oi . Figure 3 (a) shows the distribution of exact block attention mass mib , which is concentrated near zero and already provides strong discrimination between blocks. Figure 3 (b) plots the output deviation ∥v̄ib − oi ∥2 , which is divided into two distinct modes. The low7
deviation mode corresponds to blocks whose values already lie close to the dense output, whereas the high-deviation mode contains blocks that would shift the output substantially if removed. Figure 3 (c) displays the importance factor Iib = mib ∥v̄ib − oi ∥2 , which POEM’s practical score in Eq. 6 approximates. Incorporating the deviation reshapes the distribution relative to mass alone: blocks that rank high by mass but contribute values close to the output are lowered, while blocks with moderate mass but large deviation gain relative importance. As Figure 3 (d) shows, this change of distribution alters the selected block set in more than 74% of all heads, indicating that output deviation provides an important complementary signal for reliable block selection. 15
25
10.0 7.5
Heads (%)
Share of blocks (%)
30 10.0
7.5
10 5.0
5.0 5
2.5
2.5
0.0
0
−2
10
−2
10
(a) Attention mass
−1
10
10
−4
10
(b) Output deviation
15 10 5
0.0
0
74% of heads affected
20
−3
10
10
−2
−1
10
(c) Important factor
0
0
5
10
15
20
25
(d) Replaced blocks (%)
Figure 3: (a) Distribution of exact block attention mass mib . (b) Distribution of output deviation ∥v̄ib − oi ∥2 . (c) Distribution of exact importance Iib = mib ∥v̄ib − oi ∥2 . (d) Percentage of blocks replaced per head after output-relative reranking, 74% of heads are affected. Module ablation. Table 4 separately ablates covariance correction and the output reference on Qwen3-8B. Removing ei- Table 4: PG19 ablation at 32k with ther component worsens perplexity, confirming that covariance 0.1 density on Qwen3-8B. improves block-output estimation, while the output reference enables output-relative deviation. Table 5 presents the module Variant Word PPL ∆ PPL ablation on RULER at 128K context for Llama-3.1-8B, where 43.65 +0.00 we gradually add each component of POEM to a baseline that POEM 44.01 +0.36 selects blocks by mass alone. Incorporating the output devi- w/o cov. 43.95 +0.30 ation into the block score yields a broad improvement, lift- w/o output ing the average from 69.94 to 72.14 at almost the same budget (19.50% vs. 19.56%). Further adding threshold calibration gives this score a slight increase (72.38) while reducing the density from 19.56% to 18.53%, confirming that calibration can leverage differences in head sensitivity. Table 5: POEM module ablation on RULER at 128K. Best results are in bold, and second-best results are underlined. Retrieval
Method S1
S2
S3
MHT
MK1 MK2 MK3
MV
MQ
VT
Agg.
QA
CWE FWE QA1
Overall
QA2
Avg.
Baseline 100.00 99.00 100.00 92.00 62.00 43.00 93.75 97.75 68.20 0.10 73.00 44.42 36.00 + output deviation 100.00 99.00 100.00 93.00 69.00 48.00 95.75 98.25 71.00 0.10 73.67 52.08 38.00 + threshold calibration 100.00 98.00 100.00 94.00 70.00 46.00 95.75 98.50 74.80 0.20 73.00 54.75 36.00
69.94 72.14 72.38
Budget 19.50% 19.56% 18.53%
Ablation studies. We conduct ablation studies on the output-relative coefficient β, total threshold p, stage 1 threshold p1 , and different scoring proxies on LongBench, RULER, and PG19 (Rae et al., 2019). Figures 4(b)–(d) use Llama 3.1-8B. Figure 4 (a) shows that performance peaks at β = 0.3 for Qwen 3-14B and Llama 3-8B, and at 0.2 for Qwen 3-8B. Larger values degrade performance, suggesting that moderate deviation weighting improves selection but excessive weighting introduces noise from the attention mass. Figure 4 (b) plots the gain against added latency as p increases on RULER. The gain increases from p = 0.8 to p = 0.9, but drops at p = 0.95 despite the higher latency, showing that p = 0.9 provides the best trade-off among the evaluated settings. Figure 4 (c) varies the Stage-1 threshold p1 under p = 0.9. PG19 perplexity decreases as p1 grows from 0.90 to 0.94, since a larger candidate pool gives the output-relative proxy more room to improve upon mass-only selection. Beyond 0.94, however, the coarse attention score used in Stage-1 admit increasingly unreliable blocks into the pool, and because the final retention threshold p is held fixed, 8
these blocks displace trustworthy candidates and thus worsen the perplexity. Figure 4 (d) confirms our output-relative proxy’s consistent superiority over mass-only and STEM scoring at matched PG19 densities. Details for all ablations are provided in Appendix C.3.
0.0
p=0.85
Word PPL
Score gain
Δ score from β = 0
0.1
4
0.2
0.3
0.4
29.93
100
0.5
10
(a) Coefficient β
15
20
25
29.91
30
50 100 75
p=0.80 p=0.95
0.1
29.94
29.92
3 −0.1 0.0
Baseline STEM POEM
200
5
0.2
350
29.95
p=0.90
Word PPL
Llama3.1-8B Qwen3-8B Qwen3-14B
0.3
50 0.2
0.90 0.91 0.92 0.93 0.94 0.95
(c) Stage-1 keep ratio p1
(b) Added time (ms)
0.4
0.6
(d) Block density
Figure 4: POEM ablations: (a) output-relative weight. (b) score–time trade-off. (c) Stage-1 mass threshold. (d) PG19 perplexity vs density for different scoring proxies. Total efficiency analysis. Figure 5 compares the total attention run time of five state-of-the-art methods against the FlashAttention-2 baseline, from 16k to 128k, on Qwen3-8B. In these methods, POEM maintains fastest in all the length. At the length of 128k tokens, POEM even accelerates Flashattention-2 by 6.5×, from 928.0 ms to 143.9 ms, saving a massive amount of time.
0
0
16K
0
32K
0
64K
111.9/143.9
188.2/436.0
120.6/295.5
500
227.6/262.0
203.2/223.7
1000
928.0/928.0
55.7/123.6
POEM
41.2/51.7
75.0/93.1
100
STEM
43.7/89.2
200.3/200.3
97.3/108.3
31.0/42.2
FlexPrefill
200 13.4/17.6
30
XAttention
18.0/37.1
49.1/56.0
46.7/46.7
MInference
14.7/27.0
4.2/6.7
4.8/8.2
10
60
8.2/14.7
9.1/17.2
17.0/20.3
20
11.3/11.3
Single-layer latency (ms)
Dense FA2
128K
Figure 5: Attention latency (kernel/total). Dark/light segments show kernel/selector time. POEM is fastest throughout, reaching 6.5× speedup over dense FA2 at 128K. Latency breakdown of POEM. Furthermore, we analysis the detailed attention execution composition of POEM in Figure 6. The results show that the two-stage selection process of POEM is modest. As length increasing, the selection process consistently accounts for only a small part of the total time of attention execution. The attention kernel time takes the majority, accounting for around 80% of the total times when lengths exceeds 64k. We conduct this study on Qwen3-8B. FlashAttention-2
Stage 1 select
16K
46.7
15% 3.0% 18.9%
63% 0
5
Stage 2 select
76% 10
0
9%
17.6 20
128K 200.3
10% 1.5% 12.4%
6.7
Sparse attention
64K
11.3
FA-2
POEM
Covariance
32K
928.0
0.8% 10.4%
11% 0.6% 10.4%
80% 51.7 40
0
78% 143.9
100
200
0
500
1000
Figure 6: Latency breakdown of POEM. Selection overhead remains modest across context lengths, while sparse attention dominates the execution time at long contexts.
6
C ONCLUSION
We showed that the output error of sparse attention grows not only with the attention mass of the removed blocks but also with their output deviation from the dense attention output. POEM therefore scores blocks by both quantities and achieves the best accuracy among sparse attention methods with up to a 6.5× attention speedup over FlashAttention-2 at 128K tokens. Future work could estimate block outputs more accurately before attention and extend the output-relative criterion to KV cache eviction during decoding and to trainable sparse attention. 9
AI U SE S TATEMENT Generative AI tools were used to assist with drafting and language editing of this manuscript, including improvements to clarity, grammar, and organization. They were not treated as sources of scientific evidence: technical statements, citations, equations, and reported results were checked by the authors against the cited literature, mathematical derivations, implementation, and experimental records. All AI-assisted text was reviewed and revised by the authors. The authors take full responsibility for the final content of the paper, including all text, claims, and artifacts produced with the assistance of generative AI. E THICS S TATEMENT This work studies the efficiency of long-context language-model inference using publicly available pretrained models and established benchmark datasets; it does not involve human participants, newly collected personal data, or interaction with deployed users. Because POEM approximates dense attention, it can change model outputs in ways that are not fully captured by aggregate benchmark scores, potentially increasing factual errors or amplifying biases already present in the underlying models and data. We therefore do not recommend deploying the method in safety-critical or highstakes settings without application-specific evaluation and safeguards. Although sparse attention may reduce the memory and computation required for inference, the experiments themselves consume GPU resources. Users of the method remain responsible for complying with the licenses and usage conditions of the underlying models and datasets. R EPRODUCIBILITY S TATEMENT Section 4 specifies the two-stage POEM algorithm, its output-relative objective, selection metric, and hyperparameters. The models, datasets, baselines, hardware, attention implementation, evaluation framework, and shared evaluation settings are documented in Section 5 and Appendix C.4. Appendix A provides the detailed derivation of the sparse-attention output error and the pooled approximation used by POEM. The experiments use publicly available model checkpoints and benchmarks, and all methods are evaluated using the same examples and decoding settings. To support independent reproduction, the implementation, evaluation commands, configuration files, software versions, and random seeds will be included in the anonymized supplementary material.
R EFERENCES Joshua Ainslie, James Lee-Thorp, Michiel De Jong, Yury Zemlyanskiy, Federico Lebrón, and Sumit Sanghai. Gqa: Training generalized multi-query transformer models from multi-head checkpoints. In Proceedings of the 2023 conference on empirical methods in natural language processing, pp. 4895–4901, 2023. Yongqi An, Chang Lu, Kuan Zhu, Tao Yu, Chaoyang Zhao, Hong Wu, Ming Tang, and Jinqiao Wang. Rest-kv: Robust kv cache eviction with layer-wise output reconstruction and spatialtemporal smoothing. arXiv preprint arXiv:2605.08840, 2026. Yushi Bai, Xin Lv, Jiajie Zhang, Hongchang Lyu, Jiankai Tang, Zhidian Huang, Zhengxiao Du, Xiao Liu, Aohan Zeng, Lei Hou, et al. Longbench: A bilingual, multitask benchmark for long context understanding. In Proceedings of the 62nd annual meeting of the association for computational linguistics (volume 1: Long papers), pp. 3119–3137, 2024. Yushi Bai, Shangqing Tu, Jiajie Zhang, Hao Peng, Xiaozhi Wang, Xin Lv, Shulin Cao, Jiazheng Xu, Lei Hou, Yuxiao Dong, et al. Longbench v2: Towards deeper understanding and reasoning on realistic long-context multitasks. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 3639–3664, 2025. Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020. 10
Zefan Cai, Wen Xiao, Hanshi Sun, cheng Luo, Yikai Zhang, Ke Wan, Yucheng Li, Yeyang Zhou, LiWen Chang, Jiuxiang Gu, Zhen Dong, Animashree Anandkumar, Abedelkadir Asi, and Junjie Hu. R-kv: Redundancy-aware kv cache compression for reasoning models. In D. Belgrave, C. Zhang, H. Lin, R. Pascanu, P. Koniusz, M. Ghassemi, and N. Chen (eds.), Advances in Neural Information Processing Systems, volume 38, Main Conference, pp. 60980–61005. Curran Associates, Inc., 2025. doi: 10.52202/085713-2038. Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers. arXiv preprint arXiv:1904.10509, 2019. Tri Dao. Flashattention-2: Faster attention with better parallelism and work partitioning. In International Conference on Learning Representations, volume 2024, pp. 35549–35562, 2024. Yao Fu. Challenges in deploying long-context transformers: A theoretical peak performance analysis. arXiv preprint arXiv:2405.08944, 2024. Leo Gao, Jonathan Tow, Baber Abbasi, Stella Biderman, Sid Black, Anthony DiPofi, Charles Foster, Laurence Golding, Jeffrey Hsu, Alain Le Noac’h, Haonan Li, Kyle McDonell, Niklas Muennighoff, Chris Ociepa, Jason Phang, Laria Reynolds, Hailey Schoelkopf, Aviya Skowron, Lintang Sutawika, Eric Tang, Anish Thite, Ben Wang, Kevin Wang, and Andy Zou. The language model evaluation harness, 07 2024a. Yizhao Gao, Zhichen Zeng, Dayou Du, Shijie Cao, Peiyuan Zhou, Jiaxing Qi, Junjie Lai, Hayden Kwok-Hay So, Ting Cao, Fan Yang, et al. Seerattention: Learning intrinsic sparse attention in your llms. arXiv preprint arXiv:2410.13276, 2024b. Yizhao Gao, Shuming Guo, Shijie Cao, Yuqing Xia, Yu Cheng, Lei Wang, Lingxiao Ma, Yutao Sun, Tianzhu Ye, Li Dong, et al. Seerattention-r: Sparse attention adaptation for long reasoning. arXiv preprint arXiv:2506.08889, 2025. Raghavv Goel, Junyoung Park, Mukul Gagrani, Dalton Jones, Matthew Morse, Harper Langston, Mingu Lee, and Chris Lott. Caote: Kv cache selection for llms via attention output error-based token eviction. arXiv preprint arXiv:2504.14051, 2025. Aaron Grattafiori, Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Alex Vaughan, et al. The llama 3 herd of models. arXiv preprint arXiv:2407.21783, 2024. Ali Hatamizadeh, Yejin Choi, and Jan Kautz. Gated deltanet-2: Decoupling erase and write in linear attention. arXiv preprint arXiv:2605.22791, 2026. Cheng-Ping Hsieh, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, Yang Zhang, and Boris Ginsburg. Ruler: What’s the real context size of your long-context language models? arXiv preprint arXiv:2404.06654, 2024. Xiang Hu, Xinyu Wei, Hao Gu, Minshen Zhang, Tian Liang, Huayang Li, Lei Zhu, Yan Wang, Sirui Han, Yushi Bai, et al. Hierarchical sparse attention done right: Toward infinite context modeling. arXiv preprint arXiv:2607.02980, 2026. Xiaodong Ji, Hailin Zhang, Fangcheng Fu, and Bin Cui. Sale: Low-bit estimation for efficient sparse attention in long-context llm prefilling. arXiv preprint arXiv:2505.24179, 2025. Huiqiang Jiang, Yucheng Li, Chengruidong Zhang, Qianhui Wu, Xufang Luo, Surin Ahn, Zhenhua Han, Amir H Abdi, Dongsheng Li, Chin-Yew Lin, et al. Minference 1.0: Accelerating pre-filling for long-context llms via dynamic sparse attention. Advances in Neural Information Processing Systems, 37:52481–52515, 2024. Xunhao Lai, Jianqiao Lu, Yao Luo, Yiyuan Ma, and Xun Zhou. Flexprefill: A context-aware sparse attention mechanism for efficient long-sequence inference. arXiv preprint arXiv:2502.20766, 2025. Hoang Anh Duy Le, Sahil Joshi, Zeyu Yang, Zhaozhuo Xu, and Anshumali Shrivastava. Scout before you attend: Sketch-and-walk sparse attention for efficient llm inference. arXiv preprint arXiv:2602.07397, 2026. 11
Zhiwei Li, Lei Zhu, Hao Gu, Xiang Hu, Yan Wang, Haitao Mi, Sirui Han, Leo Liang, and Zhijiang Guo. Sas: Simple attention sparsification via end-to-end optimization of context ranking. arXiv preprint arXiv:2609.13141, 2026. Aixin Liu, Aoxue Mei, Bangcai Lin, Bing Xue, Bingxuan Wang, Bingzheng Xu, Bochao Wu, Bowei Zhang, Chaofan Lin, Chen Dong, et al. Deepseek-v3. 2: Pushing the frontier of open large language models. arXiv preprint arXiv:2512.02556, 2025a. Siran Liu, Zane Cao, and Yongchao He. A unified sparse attention via multi-granularity compression. arXiv preprint arXiv:2512.14082, 2025b. Enzhe Lu, Zhejun Jiang, Jingyuan Liu, Yulun Du, Tao Jiang, Chao Hong, Shaowei Liu, Weiran He, Enming Yuan, Yuzhi Wang, et al. Moba: Mixture of block attention for long-context llms. Advances in Neural Information Processing Systems, 38:17790–17815, 2026. Lin Niu, Xin Luo, Linchuan Xie, Yifu Sun, Guanghua Yu, Jianchen Zhu, and S. Kevin Zhou. Stem: Rethinking causal information flow in sparse attention. arXiv preprint arXiv:2603.06274, 2026. Alexander Novikov, Ngân Vũ, Marvin Eisenberger, Emilien Dupont, Po-Sen Huang, Adam Zsolt Wagner, Sergey Shirobokov, Borislav Kozlovskii, Francisco JR Ruiz, Abbas Mehrabian, et al. Alphaevolve: A coding agent for scientific and algorithmic discovery. arXiv preprint arXiv:2506.13131, 2025. Bowen Peng, Jeffrey Quesnelle, Honglu Fan, and Enrico Shippole. Yarn: Efficient context window extension of large language models, 2026. Jack W Rae, Anna Potapenko, Siddhant M Jayakumar, Chloe Hillier, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. arXiv preprint arXiv:1911.05507, 2019. Isaac Rehg. Kv-compress: Paged kv-cache compression with variable compression rates per attention head. arXiv preprint arXiv:2410.00161, 2024. Aurko Roy, Mohammad Saffar, Ashish Vaswani, and David Grangier. Efficient content-based sparse attention with routing transformers. Transactions of the Association for Computational Linguistics, 9:53–68, 2021. doi: 10.1162/tacl a 00353. Yutao Sun, Zhenyu Li, Yike Zhang, Tengyu Pan, Bowen Dong, Yuyi Guo, and Jianyong Wang. Efficient attention mechanisms for large language models: A survey. arXiv preprint arXiv:2507.19595, 2025. Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. LLaMA: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023. Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need, 2023. Guanzhi Wang, Yuqi Xie, Yunfan Jiang, Ajay Mandlekar, Chaowei Xiao, Yuke Zhu, Linxi Fan, and Anima Anandkumar. Voyager: An open-ended embodied agent with large language models. arXiv preprint arXiv:2305.16291, 2023. Xinghao Wang, Pengyu Wang, Xiaoran Liu, Fangxu Liu, Jason Chu, Kai Song, and Xipeng Qiu. Prism: Spectral-aware block-sparse attention, 2026a. Xinghao Wang, Pengyu Wang, Dong Zhang, Chenkun Tan, Shaojun Zhou, Zhaoxiang Liu, Shiguo Lian, Fangxu Liu, Kai Song, and Xipeng Qiu. Sparser block-sparse attention via token permutation, 2026b. Yixuan Wang, Huang He, Siqi Bao, Hua Wu, Haifeng Wang, Qingfu Zhu, and Wanxiang Che. Proxyattn: Guided sparse attention via representative heads, 2026c. 12
Ruyi Xu, Guangxuan Xiao, Haofeng Huang, Junxian Guo, and Song Han. Xattention: Block sparse attention with antidiagonal scoring. arXiv preprint arXiv:2503.16428, 2025. Yutaro Yamada, Robert Tjarko Lange, Cong Lu, Shengran Hu, Chris Lu, Jakob Foerster, Jeff Clune, and David Ha. The ai scientist-v2: Workshop-level automated scientific discovery via agentic tree search. arXiv preprint arXiv:2504.08066, 2025. An Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chengen Huang, Chenxu Lv, et al. Qwen3 technical report. arXiv preprint arXiv:2505.09388, 2025. Jingyang Yuan, Huazuo Gao, Damai Dai, Junyu Luo, Liang Zhao, Zhengyan Zhang, Zhenda Xie, Yuxing Wei, Lean Wang, Zhiping Xiao, et al. Native sparse attention: Hardware-aligned and natively trainable sparse attention. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 23078–23097, 2025. Jenny Zhang, Shengran Hu, Cong Lu, Robert Lange, and Jeff Clune. Darwin gödel machine: openended evolution of self-improving agents. In International Conference on Learning Representations, volume 2026, pp. 104223–104294, 2026. Jintao Zhang, Chendong Xiang, Haofeng Huang, Jia Wei, Haocheng Xi, Jun Zhu, and Jianfei Chen. Spargeattention: Accurate and training-free sparse attention accelerating any model inference. arXiv preprint arXiv:2502.18137, 2025. Weilin Zhao, Zihan Zhou, Chaojun Xiao, Yuxuan Li, Yanghao Li, Yudi Zhang, Weilun Zhao, Zhen Li, Yuxiang Huang, Ao Sun, et al. Infllm-v2: Dense-sparse switchable attention for seamless short-to-long adaptation. In International Conference on Learning Representations, volume 2026, pp. 69374–69390, 2026.
A
T HEORETICAL A NALYSIS AND P ROOFS
This section separates the theoretical steps in POEM’s motivation: a local upper bound relating predictive divergence to layer-output error, an exact identity for sparse-attention output error, and the first-order approximation that makes block scoring tractable. Algorithmic conventions, experimental protocols, and efficiency accounting are deferred to later sections so that each derivation states only the claim, assumptions, proof, and scope that it needs. Throughout the appendices, bold uppercase letters denote matrices, bold lowercase letters denote vectors, and plain lowercase letters denote scalars. Calligraphic letters denote sets or structured collections, and operator names retain their conventional notation. An index identifying a block, head, or token does not remove boldface when the indexed object is still a matrix or vector; scalar coordinates are written in plain type. A.1
D ERIVATION OF THE P REDICTION - TO -L AYER -O UTPUT B OUND
The objective in Eq. 7 is defined on the final prediction distribution, whereas sparse block selection directly changes an intermediate attention output. This derivation connects these two quantities. We first propagate a layer-output perturbation to the final logits and then expand the predictive KL divergence around the dense logits. The resulting upper bound relates final prediction error to layeroutput reconstruction error, providing the first step of the hierarchical decomposition in Section 4.2. Proposition (prediction-to-layer-output bound). For a fixed query block i, suppose only layer ℓ is perturbed and the downstream map from its projected attention output to the logits is locally twice differentiable. Then, in a neighborhood of the dense computation path, the predictive KL divergence satisfies Eq. A.12; in particular, its leading term is at most quadratic in the Frobenius norm of the layer-output perturbation. Assumptions. We apply sparse attention only at layer ℓ and keep all other layers dense. The downstream logit map is twice continuously differentiable, with bounded first and second derivatives 13
near the dense output, and the perturbation is small enough for the Taylor expansions below. For query block i, define the attention-output perturbation and its vectorization as e ℓ,i − Oℓ,i , ∆Oℓ,i = O
εℓ,i = vec(∆Oℓ,i ),
so that ∥εℓ,i ∥2 = ∥∆Oℓ,i ∥F . For compactness, write xℓ,i = vec(Oℓ,i ) and let fℓ→z denote the downstream network from this vectorized attention output to the final logits. Thus, zdi = fℓ→z (xℓ,i ), Proof. gives
zsi = fℓ→z (xℓ,i + εℓ,i ),
∆zi = zsi − zdi .
From output perturbations to logits. Writing zic for coordinate c of zi , Taylor’s theorem 1 ∆zic = ∇fℓ→z,c (xℓ,i )⊤ εℓ,i + ε⊤ Hℓ→z,c (xℓ,i + θc εℓ,i )εℓ,i , 2 ℓ,i
θc ∈ (0, 1),
(A.1)
where Hℓ→z,c is the Hessian of the cth logit with respect to the vectorized attention output. If these Hessians are bounded in a neighborhood of the dense path, stacking Eq. A.1 over all logits gives ∆zi = Jℓ→z,i εℓ,i + rℓ,i , ∥rℓ,i ∥2 = O ∥εℓ,i ∥22 , (A.2) where Jℓ→z,i is the Jacobian of fℓ→z evaluated on the dense computation path. For notational convenience, the Jacobian is taken with respect to the vectorized attention output. The local KL expansion. Let zdi be the dense logits and define pdi = softmax(zdi ),
psi = softmax(zdi + ∆zi ),
∆lipred = dKL (pdi ∥ psi ).
To calculate this KL divergence explicitly, define the log-partition function ! X a(z) = log exp(zc ) .
(A.3)
c
Because log[softmax(z)]c = zc − a(z), we have X ∆lipred = pdic log pdic − log psic c
=
X
pdic −∆zic + a(zdi + ∆zi ) − a(zdi )
c
= a(zdi + ∆zi ) − a(zdi ) − (pdi )⊤ ∆zi ,
(A.4)
where the last equality uses c pdic = 1. Differentiating the same log-partition expression once and then once more keeps the calculation in one chain: P
exp(zc ) ∂a(z) =P = pc , ∂zc j exp(zj )
∂ 2 a(z) = pc I[c = d] − pd , ∂zc ∂zd
∇a(zdi ) = pdi ,
∇ a(zdi ) = Diag(pdi ) − pdi (pdi )⊤ = Fi .
(A.5)
2
Expanding the log-partition function in Eq. A.4 therefore gives 1 a(zdi + ∆zi ) = a(zdi ) + (pdi )⊤ ∆zi + ∆z⊤ Fi ∆zi + O ∥∆zi ∥32 . 2 i
(A.6)
The constant terms cancel in Eq. A.4, and its linear term cancels the explicit term −(pdi )⊤ ∆zi . Hence, 1 3 ∆lipred = ∆z⊤ (A.7) i Fi ∆zi + O ∥∆zi ∥2 , 2 This calculation also shows directly why the first-order term vanishes and why the quadratic term is governed by the softmax Fisher matrix Fi . 14
Bounding the quadratic term. Substituting Eq. A.2 into Eq. A.7, the quadratic term can be expanded as 1 ⊤ 1 ∆z Fi ∆zi = (Jℓ→z,i εℓ,i + rℓ,i )⊤ Fi (Jℓ→z,i εℓ,i + rℓ,i ) 2 i 2 1 1 ⊤ ⊤ = ε⊤ J⊤ Fi Jℓ→z,i εℓ,i + ε⊤ (A.8) ℓ,i Jℓ→z,i Fi rℓ,i + rℓ,i Fi rℓ,i . 2 ℓ,i ℓ→z,i 2 Locally, Jℓ→z,i and Fi are bounded, while ∥rℓ,i ∥2 = O(∥εℓ,i ∥22 ). The second and third terms in Eq. A.8 are therefore respectively O(∥εℓ,i ∥32 ) and O(∥εℓ,i ∥42 ). Moreover, ∥∆zi ∥2 = O(∥εℓ,i ∥2 ), so the remainder in Eq. A.7 is also O(∥εℓ,i ∥32 ). Collecting these terms yields 1 ⊤ 3 (A.9) ∆lipred = ε⊤ ℓ,i Jℓ→z,i Fi Jℓ→z,i εℓ,i + O ∥εℓ,i ∥2 . 2 This expression connects the layer-output perturbation to the final predictive divergence through the downstream Jacobian and the softmax Fisher matrix. Assume locally that ∥Jℓ→z,i ∥2 ≤ lℓ,i ,
∥Fi ∥2 ≤ κi .
Since Fi is positive semidefinite, the leading quadratic term satisfies ⊤ ⊤ ε⊤ ℓ,i Jℓ→z,i Fi Jℓ→z,i εℓ,i = (Jℓ→z,i εℓ,i ) Fi (Jℓ→z,i εℓ,i )
≤ ∥Fi ∥2 ∥Jℓ→z,i εℓ,i ∥22 ≤ ∥Fi ∥2 ∥Jℓ→z,i ∥22 ∥εℓ,i ∥22 2 ≤ κi lℓ,i ∥εℓ,i ∥22 .
(A.10)
Thus, 1 2 κi l ∥εℓ,i ∥22 + O ∥εℓ,i ∥32 . 2 ℓ,i 2 e ℓ,i − Oℓ,i ∥F , we obtain Defining cℓ,i = 12 κi lℓ,i and using ∥εℓ,i ∥2 = ∥O 3 2 pred e e ∆li . ≤ cℓ,i Oℓ,i − Oℓ,i + O Oℓ,i − Oℓ,i ∆lipred ≤
F
F
(A.11)
(A.12)
From the layer bound to head errors. Let H be the number of heads and ∆Oℓ,i,h the matrix of head-h output perturbations over query block i. The projected perturbation satisfies ∆Oℓ,i = PH (h) h=1 ∆Oℓ,i,h WO . Submultiplicativity and the triangle inequality first give X (h) ∥∆Oℓ,i ∥F ≤ ∥WO ∥2 ∥∆Oℓ,i,h ∥F . h
Applying Cauchy–Schwarz to this sum then gives X (h) ∥∆Oℓ,i ∥2F ≤ H ∥WO ∥22 ∥∆Oℓ,i,h ∥2F .
(A.13)
h
Substituting this inequality into the leading term of Eq. A.12 yields the weighted head-error bound in Section 4.2. Together, the two bounds link the final predictive divergence to the reconstruction errors of individual attention heads and show where head-dependent weights enter the decomposition. A.2
E XACT S PARSE -ATTENTION O UTPUT E RROR
We now work within one attention head and retain the original token-level causal mask inside each block. The main text writes a single query row with scalar mass mib , conditional block output v̄ib , and dense output oi . Here a query block contains several such rows: mib stacks their masses, Dib = Diag(mib ) applies them rowwise, Wib stacks the corresponding conditional block outputs, and Odense stacks the dense outputs. Thus each row of Eq. A.18 reduces to the scalar-query identity i used in the main text; the matrix notation introduces no different objective. For query block i, let Aib denote the dense attention-score submatrix associated with key block b. Define mib = Aib 1,
Dib = Diag(mib ), 15
Wib = D−1 ib Aib Vb .
(A.14)
Here, mib collects the scalar block masses of all query rows in query block i. For a zero-mass row, we define the corresponding row of Wib as zero rather than inverting a zero diagonal entry. Such a row contributes nothing to Dib Wib . Since each dense attention row sums to one, its output decomposes as X X Odense = Aib Vb = Dib Wib . (A.15) i b≤i
b≤i
Let Ti and Ri be the retained and removed block sets, respectively, and define X Dib . DiR =
(A.16)
b∈Ri
Recomputing softmax over the retained tokens divides each query row by its retained probability mass. Therefore, X −1 Dib Wib . (A.17) Osparse (Ti ) = (I − DiR ) i b∈Ti
Substituting Eq. A.15 gives the exact output error Ei (Ti ) = Odense − Osparse (Ti ) i i X −1 Dib Wib − Odense . = (I − DiR ) i
(A.18)
b∈Ri
The single-token form of Eq. A.18 has also been used to score cached tokens in KV-cache eviction (Goel et al., 2025; An et al., 2026). For multiple removed blocks, submultiplicativity and the triangle inequality give X −1 ∥Ei (Ti )∥F ≤ (I − DiR ) Dib Wib − Odense . (A.19) i F 2
b∈Ri
Eq. A.19 shows that each removed block affects the output error through both its attention mass and output deviation. We therefore rank blocks by the mass-weighted output deviation mib ∥v̄ib − oi ∥2 , retaining blocks with larger estimated effects on the attention output. A.3
A PPROXIMATION FOR B LOCK O UTPUT
POEM approximates each block output by applying a first-order Taylor expansion at the pooled query. The corresponding diagnostic and complexity analysis appear in Sections D and E. The derivation below follows the row-vector convention of the main text. Accordingly, its QK logit is qk⊤ and its covariance correction is qC. A first-order block-output approximation. For a fully visible key block Bb of size nb , define 1 X 1 X 1 X k̄b = kt , v̄b = vt , Cb = (kt − k̄b )⊤ (vt − v̄b ). (A.20) nb nb nb t∈Bb t∈Bb t∈Bb √ For the pooled query q̄i , let at = q̄i (kt − k̄b )⊤ / dh . Subtracting the common block-mean logit P does not change the softmax, and the centered logits satisfy t at = 0. Introduce X exp(uat ) αt (u) = P , g(u) = αt (u)vt . (A.21) r∈Bb exp(uar ) t∈Bb
The parameter u interpolates between uniform weights at u = 0 and the within-block softmax at u = 1. At u = 0, αt (0) = 1/nb and g(0) = v̄b . Moreover, ! X ′ αt (u) = αt (u) at − αr (u)ar , (A.22) r∈Bb
αt′ (0) =
1 nb
1 X at − ar nb r 16
! =
at . nb
(A.23)
Therefore, 1 X at vt nb t " # q̄i 1 X q̄i =√ (kt − k̄b )⊤ (vt − v̄b ) = √ Cb . n dh dh b t
g′ (0) =
(A.24)
(A.25)
The first-order Taylor expansion g(1) ≈ g(0) + g′ (0) gives q̄i bib . g(1) ≈ v̄b + √ Cb =: v dh
(A.26)
The omitted terms are second order in the centered logits at . When their within-block spread is moderate, these terms are typically small and are therefore omitted; Section D.1 evaluates the resulting approximation directly. All configured local blocks, including the diagonal query–key block, are mandatory and are retained without using this approximation for selection. The pooled-query estimate is applied only to the remaining optional key blocks, which precede the local window and are fully visible to every token in query block i. For these optional blocks, all tokens in query block i use the mean query q̄i during scoring instead of their individual queries. After selection, the final sparse-attention kernel still applies the exact token-level causal mask. The diagnostic in Section D.1 measures the effects of query pooling and the first-order truncation.
B
A LGORITHM AND I MPLEMENTATION D ETAILS
This section connects the selection formula to the exact operations used by Algorithm 1. B.1
F ROM B LOCK E STIMATES TO THE S ELECTION S CORE
√ pool A coarse global-output reference. The pooled QK term in Eq. 6 is zib = q̄i k̄⊤ b / dh . Following the main text, the implementation approximates this term with the antidiagonal scorer; denote its pool AD output by zbib ≈ zib . All optional blocks evaluated by the scorer are fully visible, fixed-size key blocks; boundary and local blocks are mandatory and do not participate in the optional-block ranking. Consequently, the block cardinality is constant over the scored blocks and no block-dependent cardinality term is needed. Normalizing the antidiagonal estimates over visible blocks gives the pooled weights aib used by Stage 1 and by the coarse output reference: AD exp(b zib ) , AD ) zic c≤i exp(b
aib = P
bi = o
X
aib v̄b ,
value bi ∥2 . rib = ∥b vib − o
(B.1)
b≤i
bi aggregates all visible pooled values and contains no query-conditioned covariance correcHere o tion; only the Stage 2 candidate block outputs include that correction. Taking the logarithm of the separable importance proxy for positive masses gives log mib + log ∥v̄ib − oi ∥2 . Substituting the pooled QK term for the first component and the approximated output deviation for the second, and introducing β yields the score in the main text. Using the antidiagonal approximation to the pooled QK term, the implementation evaluates AD value sib = zbib + β log rib ,
(B.2)
which is the operational form of Eq. 6 after replacing its pooled QK term by the antidiagonal estimate value and substituting rib from Eq. B.1. Thus the implementation uses antidiagonal scoring to estimate the first term displayed in the main text; it does not replace that term by the logarithm of a separate Stage 1 mass estimator. Ranking, mass accumulation, and mandatory blocks. Stage 1 selects the shortest prefix of blocks in descending aib order whose cumulative estimated mass reaches p1 of the total visible mass, then takes the union with the mandatory sink/local set Mi . Stage 2 initializes Si = Mi , 17
credits the masses of mandatory blocks toward the target, and evaluates and sorts by sib only the remaining optional candidates Ci \ Mi . It appends them until X X aib . (B.3) aib ≥ p2,g(h) b∈Ci
b∈Si
The combined score thus determines only the insertion order; the quantity accumulated against the threshold is the original pooled weight aib , not a renormalized softmax of the combined score. Mandatory blocks are never duplicated; if their mass alone meets the target, no optional block is added. Block discreteness may still cause overshoot. Note that this criterion covers pooled attention mass and does not guarantee coverage under exact dense attention. The final sparse attention is recomputed from the original token-resolution Q/K/V tensors.
C
E XPERIMENTAL S ETUP
This section collects the model, dataset, and controlled-diagnostic protocols; later diagnostic sections refer back to these populations rather than mixing their setup with the theoretical derivations. C.1
R ECONSTRUCTION -E RROR E VALUATION S ETUP
Table 2 compares block-scoring proxies on LongBench prompts, each containing exactly 8,192 tokens, using Qwen3-8B. All methods use the same antidiagonal QK scorer and the pooled weights obtained by normalizing its scores. The comparison varies only the selection score: pooled attention mass alone, a STEM-style value-magnitude score with β = 0.2, and POEM’s output-relative score with β = 0.2. This controlled comparison is distinct from running each method’s complete native implementation. Fixed selection budget. Blocks contain 128 tokens. Each query/head retains at most 16 visible blocks, corresponding to 2,048 tokens; if fewer than 16 blocks are visible, all are retained. This is a fixed-count diagnostic, not the top-p protocol used for the main task results. Layer and logit metrics. For the layer-5, layer-15, and layer-35 columns, only the specified decoder layer is sparsified and all other layers remain dense. We measure hidden-state MSE immediately after that layer over all 8, 192 × 4, 096 elements, then average the per-text MSE over the 30 paired texts. Layer indices are one-based. The “Final logits” column instead sparsifies all 36 decoder layers and measures raw-logit MSE after the final normalization and language-model head over all prompt positions and vocabulary entries. It is neither a KL divergence nor an isolated attention-head error. C.2
E XACT-S CORE R ERANKING D IAGNOSTIC
Figure 3 uses Llama-3.1-8B-Instruct on RULER examples. For every evaluated block, we compute the exact dense attention mass mib , conditional block output v̄ib , dense head output oi , and exact importance Iib = mib ∥v̄ib − oi ∥2 . Panel (d) compares mass-only selection with exact outputrelative reranking at the same retention setting and reports the fraction of evaluated heads for which the selected block set changes. This diagnostic is separate from the benchmark scores in Table 3. C.3
A BLATION E XPERIMENTAL S ETUP
The ablations vary one factor at a time while keeping the remaining model and selector settings fixed as described in the main text and the reproducibility configuration below. Output-deviation weight. Figure 4(a) sweeps β ∈ {0, 0.1, 0.2, 0.3, 0.4, 0.5} for Llama-3.1-8B, Qwen3-8B, and Qwen3-14B, and reports the score change relative to β = 0 for each model. Overall threshold and latency. Figure 4(b) uses Llama-3.1-8B on RULER and sweeps the overall retention threshold over five levels, p ∈ {0.75, 0.80, 0.85, 0.90, 0.95}. At each level, we record the RULER score and selection latency under the same evaluation setting. The plot reports the increment 18
associated with raising p to the labeled level, rather than the absolute result at that level. Specifically, the point labeled p = 0.80 reports the score difference between p = 0.80 and p = 0.75, together with the corresponding latency difference; the points labeled 0.85, 0.90, and 0.95 are defined analogously relative to their immediately preceding levels. The five evaluated thresholds therefore produce four plotted transitions. The p = 0.75 result serves as the reference for the first transition and is not shown as a separate point. Stage 1 threshold. Figure 4(c) uses Llama-3.1-8B on PG19, fixes the overall target at p = 0.90, and sweeps p1 ∈ {0.90, 0.91, 0.92, 0.93, 0.94, 0.95}. All other settings are fixed, and each point reports word perplexity under the corresponding candidate-pool threshold. Scoring proxy and density. Figure 4(d) uses Llama-3.1-8B on PG19 and compares mass-only, STEM, and POEM scoring at matched block densities. Each point reports word perplexity, with the inputs and density fixed across the three selection scores. Component ablation. Table 4 evaluates Qwen3-8B on 20 books from the PG19 test split, using 32K-token inputs and a fixed attention density of approximately 0.1. The same books and density are used for POEM, the variant without covariance correction, and the variant without the outputrelative reference. Word perplexity is computed over this fixed 20-book evaluation population. C.4
M ODELS , DATASETS , AND E VALUATION S COPE
Backbones and context lengths. We evaluate Llama-3.1-8B (Grattafiori et al., 2024) and Qwen38B/14B (Yang et al., 2025). Model parameters remain frozen. The long-context Qwen runs use YaRN (Peng et al., 2026) to extend the 32K context window to 128K tokens; this setting should not be inferred for every 8K diagnostic. Datasets and reporting. LongBench (Bai et al., 2024) contains 21 tasks in six categories; we use each prescribed metric and report the unweighted macro average of category scores. RULER (Hsieh et al., 2024) is reported at 4K, 8K, 16K, 32K, 64K, and 128K and is averaged uniformly over lengths. PG19 (Rae et al., 2019) supplies long-form text for perplexity ablations and selected block diagnostics. Task evaluation uses lm-evaluation-harness (Gao et al., 2024a); component diagnostics use the explicit samples, precision, thresholds, and aggregation rules stated with each diagnostic and are not pooled into the task benchmarks. C.5
R EPRODUCIBILITY C ONFIGURATION
All models are inference-only and retain their released weights. Experiments use PyTorch on an NVIDIA A100, 128-token query/key blocks, antidiagonal scoring with B1 = 16 in Stage 1 and B2 = 8 in Stage 2, and FlashAttention-2 for the final token-resolution attention. Llama-3.1-8B uses four sink and four local blocks; Qwen3-8B/14B use one of each. Stage 1 uses p1 = 0.94. The output-deviation coefficient is 0.3 for Llama-3.1-8B and Qwen3-14B and 0.2 for Qwen3-8B. Before calibration, p2 = 0.90/0.94; calibrated groups use 0.81/0.94. The logarithm floor is 10−6 . The diagnostic subsections additionally state model trajectory, activation precision, prompt length, sample count, layer indexing, candidate definition, and aggregation unit. A reproduction artifact should preserve the ordered example identifiers and tokenized lengths for every diagnostic and for the two calibration manifests in Section F; this prevents nominally identical datasets from silently producing different subsets after tokenization or filtering.
D
A PPROXIMATION AND P RESELECTION D IAGNOSTICS
We first test whether the two output estimates are faithful to their distinct targets, and then test the operational question for preselection: whether the mass-only candidate pool excludes blocks that an all-visible output-relative selector would retain. The block-output and global-output plots use different units and populations and are therefore complementary diagnostics, not a head-to-head comparison. 19
Llama-3.1-8B 1.00 0.50
Cosine similarity
0.00 -0.50 -1.00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
26
27
28
29
27
28
29
30
31
32
35
36
Qwen3-8B 1.00 0.50 0.00 -0.50 -1.00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
30
31
32
33
34
Layer id
bib and the exact token-level causal Figure 7: Cosine similarity between the first-order estimate v exact block output vib . White bars mark weighted medians. D.1
B LOCK -O UTPUT A PPROXIMATION
Block-output diagnostic: reference and evaluation population. We use 30 shared LongBench text identities for Llama-3.1-8B and Qwen3-8B, tokenize them separately for each model, and retain 8,192 tokens without a chat template. Activations follow the dense BF16 model trajectory. All layers, 32 query heads, and 64 query blocks are evaluated. Blocks contain 128 tokens. Within each layer, every text/head/query-block row has equal total weight, divided equally among its evaluated key blocks. Layers are indexed from one in the figure. For query block Qi and key block Bb , the reference is √ P ⊤ 1 X u∈Bb , u≤t exp(qt ku / dh )vu exact √ P vib = . ⊤ |Qi | u∈Bb , u≤t exp(qt ku / dh ) t∈Q
(D.1)
i
√ bib = v̄b + q̄i Cb / dh using cosine similarity: We compare the reference with v cib =
exact ⊤ bib (vib v ) exact ∥b vib ∥2 ∥vib ∥2
(D.2)
for each text, layer, head, and query–key block pair. Equal row weighting prevents query blocks with more evaluated key blocks from dominating the distribution. Block-output cosine similarity. Figure 7 shows high cosine similarity for most evaluated blocks. The weighted median exceeds 0.9 in 31 of 32 Llama layers and 29 of 36 Qwen layers. The median is lower in Llama’s first layer (0.805), several early Qwen layers, and Qwen layer 34. Thin lower tails also indicate poorly aligned pairs in otherwise well-aligned layers. These results support the firstorder estimate as a useful block-level signal while identifying layer-dependent limitations. Cosine similarity measures direction, not vector-magnitude error; it does not by itself bound the error in the block-output norm or guarantee that approximate scores preserve the exact block ranking. D.2
ACCURACY OF THE G LOBAL O UTPUT E STIMATE
bi anchors the output deviation used for block selection. To examine how The global reference o much information this inexpensive estimate retains about the final attention output, we compare it with the dense attention output before the multi-head output projection. bi on 30 LongBench Reference and aggregation. Figure 8 evaluates the raw pooled reference o texts of 8,192 tokens and 128-token blocks. The output is estimated using the Stage 1 procedure with p1 = 0.94. Let X contain all text–block pairs. For each layer ℓ and query head h, we compute 20
one cosine similarity by summing the dot products and squared norms over all pairs in X before taking their ratio: P dense b⊤ global ℓhx oℓhx x∈X o q cℓh = qP . (D.3) P 2 dense ∥2 ∥b o ∥ ∥o ℓhx 2 2 x∈X x∈X ℓhx Thus, each layer contributes 32 head-level cosine values to the violin plot. Llama-3.1-8B 1.00 0.50
Cosine similarity
0.00 -0.50 -1.00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
26
27
28
29
27
28
29
30
31
32
35
36
Qwen3-8B 1.00 0.50 0.00 -0.50 -1.00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
30
31
32
33
34
Layer id
Figure 8: Head-level cosine similarity between the Stage 1 global-output estimate and the dense attention output across layers. Results and interpretation. Every layer has a positive median pooled cosine. The layer medians range from 0.399 to 0.873 for Llama and from 0.510 to 0.914 for Qwen, with stronger alignment across many middle layers. Several layers have a broad spread across heads, and some heads have negative pooled cosine. These results show that the low-cost estimate captures a meaningful portion of the dense output information and can serve as a coarse prior for block selection. However, the variation across layers and heads also shows that this prior is only approximate and provides limited output information in the less-aligned cases. D.3
S TAGE 1 C ANDIDATE -P OOL C OVERAGE
Stage 1 selects candidates using attention mass alone, whereas Stage 2 combines routing relevance with value-dependent output deviation. We first answer the operational question—whether preselection excludes blocks that the combined score would retain—and then use the component distributions to explain the observed coverage. Diagnostic setup. All four figures in this section use Llama-3.1-8B at layers 5, 15, 25, and 31 (zero-based), evaluated on two fixed PG19 texts at nested input lengths of 16K, 32K, 48K, and 64K. The activations follow the same dense BF16 trajectory. Each layer/length combination contains 512 query rows: two texts, 32 heads, and eight sampled query-block rows per text and head. We retain the diagnostic’s native antidiagonal QK scores, their normalized pooled weights, covariancecorrected value deviations, and frozen output-reference calibration. The distribution plots apply no additional per-row, per-head, or per-layer normalization to these recorded deviations. Keeping the sampled inputs and layer indices aligned makes it possible to compare the mass profiles, deviation distributions, and selection coverage within this diagnostic. Core coverage result. Figure 9 uses an all-visible Stage 2 reference: output-relative selection is applied to all causally visible blocks with a raw mass target of 0.90 and β = 0.6. The reference is full fixed while p1 changes. With Si,h denoting the reference selection and Ci,h (p1 ) the mass-only pool, P full i,h |Si,h \ Ci,h (p1 )| P . (D.4) rmiss (p1 ) = full i,h |Si,h | 21
The missed fraction is 0.973–2.383% at p1 = 0.90, 0.029–0.224% at p1 = 0.92, and at most 0.035% at p1 = 0.94. Thus the deployed conservative pool covers at least 99.96% of the reference-selected blocks in every measured layer/length combination. p1 = 0.90
16K tokens
p1 = 0.92
32K tokens
p1 = 0.94
48K tokens
64K tokens
Layer 5
2.4 1.2 0.2 0.1
Layer 15
2.4 1.2 0.2 0.1 0 2.4
Layer 25
Missed / full Stage-2 selected (%)
0
1.2 0.2 0.1 0
Layer 31
2.4 1.2 0.2 0.1 0
.90
.92
.94
.90
.92
.94
.90
.92
.94
.90
.92
.94
Stage-1 threshold p1
Figure 9: Layerwise coverage of value-aware selections by mass-only preselection for p1 ∈ {0.90, 0.92, 0.94}. The missed fraction is the pooled count of all-visible reference-selected blocks outside the Stage 1 pool divided by the pooled reference-selected count. At p1 = 0.94, the missed fraction is at most 0.035% across all 16 measured layer/length combinations. Attention mass versus value deviation. Figures 10 and 11 compare two groups defined by cumulative attention mass: the shell between 0.85 and 0.90, and the tail beyond 0.94. The plots cover layers 5, 15, 25, and 31 and input lengths from 16K to 64K (zero-based layer indices). Attention-mass separation. Figure 10 shows a clear and persistent gap between the two groups. Across every sampled layer and context length, the 0.85–0.90 shell retains markedly larger raw Stage 1 block mass over almost the entire within-group rank range. By contrast, the tail beyond 0.94 drops rapidly and approaches zero for a large fraction of its blocks. The same ordering appears from 16K through 64K and from the early layer 5 to the late layer 31, although the precise curve shape changes with depth. This separation means that a tail block begins with a substantial QK-score disadvantage before the value-aware term is applied. Consequently, only tail blocks with unusually large output deviation can plausibly overtake candidates already included in the conservative mass pool. Output-deviation overlap. Figure 11 presents a different pattern. The ranked output-deviation curves of the shell and tail largely overlap in layers 5 and 25, while the tail is only moderately higher through much of layer 15. The strongest difference occurs in layer 31, where the upper portion of the tail has larger deviations than the corresponding shell profile. Even there, the gap contracts toward the lower-ranked portion of the distributions, and the two groups remain on a comparable scale 22
0.85–0.90 shell
Tail after 0.94
Layer 5
0.20 0.15
full range
full range
full range
full range
full range
full range
full range
full range
full range
full range
full range
full range
full range
full range
full range
full range
0.10 0.05
Layer 31
Raw Stage-1 block mass Layer 25 Layer 15
0.00 0.20 0.15 0.10 0.05 0.00 0.20 0.15 0.10 0.05 0.00 0.20 0.15 0.10 0.05 0.00
0
50
16k tokens
100
0
50
100
32k tokens
0
50
100
48k tokens
0
50
100
64k tokens
Rank within each group (%) · largest to smallest
Figure 10: Attention-mass profiles for the 0.85–0.90 cumulative-mass shell and the tail beyond 0.94, sorted independently within each group. The tail has substantially lower raw Stage 1 block mass over most ranks across all sampled layers and context lengths.
over most ranks. Thus, low attention mass does not imply uniformly negligible value deviation, but neither does the tail exhibit a broad value advantage that would generally compensate for the mass gap in Figure 10. Joint interpretation. Together, the two figures motivate the asymmetric two-stage design. Stage 1 uses attention mass to remove a region whose scores are consistently weak, whereas Stage 2 preserves the value term for finer discrimination inside a conservative candidate pool. The figures are distributional rather than paired blockwise comparisons: ranks are computed independently within each group and component, so points at the same horizontal position need not represent the same block. The profiles therefore explain the empirical coverage trend without asserting that mass alone determines the final selection. For positive deviations, a discarded block b can outrank a candidate c under Eq. 6 only if β log
value rib AD AD > zbic − zbib . value ric
(D.5)
AD Here zbib is the antidiagonal estimate of the pooled QK component in the combined log score. For β > 0, a large routing-score gap requires a correspondingly large value-deviation ratio. The observed profiles support using the value term to refine a conservative candidate pool rather than scoring every low-mass block. This explains why the conservative pool has high measured coverage without claiming that attention mass alone is sufficient for the final ranking.
Layerwise distribution of value deviation. Figure 12 separates the all-visible deviation distribution by layer and input length. Each panel pools the visible block observations for its 512 query rows, with equal weight per block observation. The 16 panels contain 2,295,552 observations in total. The vertical axis reports the percentage of observations in each 0.05-wide log10 bin. Common axes retain the original norm scale and all observed values, so both location and spread can be com23
0.85–0.90 shell
Tail after 0.94
Layer 5
3 2 1
Layer 15 Layer 25 Layer 31
Raw value deviation ‖Vi,blk b − Oi ‖ 2
0 4 2 0 5.0 2.5 0.0 15 10 5 0
0
50
16k tokens
100
0
50
100
32k tokens
0
50
48k tokens
100
0
50
100
64k tokens
Rank within each group (%) · largest to smallest
Figure 11: Output-deviation profiles for the 0.85–0.90 cumulative-mass shell and the tail beyond 0.94, sorted independently within each group. The profiles largely overlap except for the upperranked tail in later layers, most notably layer 31.
pared across panels. The distribution includes retained and discarded blocks; it is not conditioned on either stage’s final selection. The typical deviation increases across the four sampled depths. Across the four lengths, the median is 0.787–0.817 in layer 5, 1.202–1.267 in layer 15, 1.765–1.779 in layer 25, and 2.076–2.085 in layer 31. Within each layer, the largest median is less than 6% above the smallest across these lengths. The late layer also has a broader right tail: its 95th percentile is 6.864–7.180, compared with at most 3.501 in the other three layers. Nevertheless, deviations above 10 account for only 0.037–0.050% of layer-31 observations and do not occur in the other plotted layers. These layerwise views explain why a pooled histogram can obscure meaningful depth-dependent differences. They also clarify the role of the value term: most blocks have moderate deviations, while a small tail can receive substantially higher scores. Whether such a block should survive depends jointly on its deviation and attention mass, as expressed by Eq. D.5. A marginal deviation histogram alone cannot establish that preselection preserves the desired blocks; the following coverage test evaluates that question using the joint score. The threshold effect is consistent across the four depths, including layer 31 with its broader deviation tail. The length dependence is not strictly monotone: for example, at p1 = 0.90, layer 15 reaches 2.378% at 32K and decreases to 2.053% at 64K. Hence the observed coverage is better summarized by its range across layers and lengths than by assuming that longer inputs necessarily cause more omissions. Together, the profiles and coverage measurements support using a conservative mass-only pool before applying the more expensive output-relative score. The profiles identify the large mass gap that a tail block must overcome, while the coverage test directly counts the exceptions under the combined score. The diagnostic uses β = 0.6, rather than the model-specific coefficients of the main benchmark. Its two-text coverage result does not guarantee zero omissions on other inputs, nor does a small missed-block fraction alone bound output error: missed blocks can differ in their individual contributions. 24
Layer 5
16K tokens
32K tokens
48K tokens
64K tokens
20 10
Layer 15
20 10 0
Layer 25
Blocks per log bin (%)
0
20 10
Layer 31
0
20 10 0
0.5
1
2
5
10
0.5
1
2
5
10
0.5
1
2
5
10
0.5
1
2
5
10
Raw value deviation (L2 norm; logarithmic scale)
Figure 12: Layerwise distributions of raw value-deviation norms over all visible blocks. Rows show Llama-3.1-8B layers 5, 15, 25, and 31 (zero-based); columns show four input lengths. Each panel pools two PG19 texts, 32 heads, and eight query rows per text and head, with equal weight per visible block observation. The horizontal axis is logarithmic, and bins have width 0.05 in log10 deviation. All panels share the same axes, without additional per-head or per-row normalization. Layer 31 has a broader right tail, while each layer’s central distribution varies modestly across lengths.
E
RUNTIME AND M EMORY A NALYSIS
E.1
B LOCK -O UTPUT E STIMATOR FLOP S
The relevant baseline is the exact token-level block output in Eq. D.1. Let X nib = |{u ∈ Bb : u ≤ t}|
(E.1)
t∈Qi
be the number of visible query–key pairs. Counting a multiply–add as two FLOPs, exact QK products and value accumulation cost fexact (i, b) = 4nib dh , (E.2) where nib = bq bk for a fully visible block. A cached covariance descriptor requires one matrix– vector product and one vector addition, fTaylor = 2d2h + dh .
(E.3)
For a fully visible block, the fraction of per-candidate arithmetic retained by the estimator is therefore 2dh + 1 2dh + 1 fTaylor = , saving = 1 − . (E.4) fexact 4bq bk 4bq bk 25
When bq = bk = dh = d, exact block computation is O(d3 ) whereas the estimate is O(d2 ) per candidate. At d = 128, Eq. E.4 gives a 99.61% reduction in per-candidate arithmetic. The covariance costs 2bk d2h + O(bk dh + d2h ) to construct, but it is computed once per KV-head/keyblock descriptor and reused across the corresponding query heads and query blocks. Query pooling likewise costs 2bq dh once per query block. If P candidate pairs reuse U unique descriptors across Q query blocks, the estimator requires P (2d2h + dh ) + U 2bk d2h + O(bk dh + d2h ) + 2Qbq dh (E.5) P FLOPs, compared with 4dh (i,b) nib for exact token-level block outputs. The descriptor and pooling terms are therefore amortized as their reuse increases. For a causal diagonal block, Eq. E.2 uses the actual smaller nib , so its saving is lower than the full-block expression. These counts exclude memory traffic, kernel launches, Stage 1, and the final sparse attention. End-to-end measurements appear in Figures 5 and 6. E.2
M EMORY OVERHEAD OF Q/K C OPIES AND C OVARIANCE
We first calculate the storage required by the auxiliary tensors used for low-precision scoring and block-output approximation. These tensors consist of low-precision Q/K copies and a blockwise key–value covariance cache. In practice, our implementation stores the Q/K copies in INT8 and the covariance cache in BF16. We then measure the actual instantaneous memory overhead of the INT8 Q/K copies and covariance cache. Storage calculation. For batch size one, sequence length n divisible by block size b = 128, head dimension dh , hq query heads, and hkv KV heads, let btot = ⌈n/b⌉. An INT8 entry occupies one byte, and a BF16 covariance entry occupies two bytes. The buffer sizes are mcopies = ndh (hq + hkv ) bytes,
mcov = 2hkv btot d2h bytes.
(E.6)
The covariance cache is shared by query heads using the same KV head. At 128K with dh = 128, hq = 32, and hkv = 8, the Q and K copies require 512 and 128 MiB, respectively, and the covariance cache requires 256 MiB. Verification with real model activations. We replay saved dense-trajectory Q/K/V activations from Qwen3-8B (YaRN ×4, layer index 18) for four fixed inputs: two PG19 texts and two InfiniteBench inputs (code debugging and key–value retrieval). The actual INT8 quantization and BF16 covariance routines are executed on an NVIDIA A100 80GB at 16K, 32K, 64K, and 128K, with batch size one. After warm-up, we measure the actual instantaneous memory increase produced by the INT8 Q/K copies and covariance cache during complete POEM execution. Table 6: Predicted and measured auxiliary tensor storage (MiB). The actual INT8 copies and BF16 covariance cache match their shape-based predictions on all four inputs at each length. Q/K measurements also include the small FP32 quantization-scale tensors. Q/K copies
Covariance
Length
Predicted payload
Measured with scales
Predicted
Measured
16K 32K 64K 128K
80 160 320 640
80.020 160.039 320.078 640.156
32 64 128 256
32 64 128 256
Table 6 confirms that these buffers occupy the predicted storage in the implementation. The measured Q/K difference is exactly the FP32 scale storage, 4(hq + hkv )btot bytes; at 128K it is 0.15625 MiB. All 48 component checks (Q copy, K copy, and covariance across 16 input/length combinations) match the tensor payload plus its returned metadata exactly. Instrumented and uninstrumented complete POEM calls produce bitwise-identical attention outputs on all 16 cases. Both terms grow linearly with n for fixed block size and head geometry. Their payload sizes sum to 896 MiB at 128K, but this sum is not a claim about the complete model’s peak GPU memory. 26
The INT8 copies are temporary Stage 1 tensors, while covariance is constructed for Stage 2; their lifetimes need not overlap. This accounting is limited to the two buffer families and excludes the original Q/K/V activations and other attention workspaces. End-to-end peak GPU memory. We additionally record the peak allocated GPU memory during full-model prefilling. Table 7 shows that the runtime memory peaks of POEM and dense attention are nearly identical. Even at 128K tokens, POEM increases the peak by only 2.005 MiB. Table 7: End-to-end peak allocated GPU memory during full-model prefilling. The increase is computed from the unrounded measurements. Length
Dense (GiB)
POEM (GiB)
Increase (MiB)
16K 32K 64K 128K
19.147 23.030 30.796 46.329
19.147 23.031 30.797 46.331
0.033 0.127 0.503 2.005
The model-level peak is determined by the allocation of MLP activations. When this peak is reached, the temporary low-precision Q/K copies and the covariance cache used by POEM have already been released. These buffers therefore do not overlap with the dominant MLP allocation, explaining why their standalone storage does not translate into a comparable increase in the end-to-end peak memory.
F
O FFLINE T HRESHOLD C ALIBRATION
Algorithm 2 expands the error-ranked batch-bisection procedure in Section 4.3. A group is a layerspecific set of query heads sharing KV projections. Its members share one threshold. To keep calibration notation consistent with the main configuration, let θg = p1 p2,g denote the group’s overall estimated mass target; the candidate-relative threshold used by Algorithm 1 is p2,g = θg /p1 . Groups are ordered by increasing error in a single-group perturbation diagnostic, with all other groups kept at the reference setting. This ordering prioritizes groups expected to tolerate a smaller budget. Data partition. Calibration uses two fixed, disjoint manifests: Drank for the dense-logit cache and single-group KL probes, and Dsearch for accepting or rejecting threshold changes. The benchmark test instances reported in Section 5 belong to neither manifest and are evaluated only after thresholds are frozen. The example identifiers, tokenized lengths, sampled prediction positions, and random seed must be stored with the released configuration so that the split can be reconstructed exactly. Definition of the group error. We first run dense attention on Drank and cache its final vocabulary logits. Set every group’s overall target to 0.9 and evaluate the resulting sparse model against this dense reference. Writing θ ref = (0.9, . . . , 0.9), define 1 X d(θ) = dKL softmax(zdx,t ) softmax(zsx,t (θ)) , dref = d(θ ref ), (F.1) |I| (x,t)∈I
where I is the fixed set of example–position pairs drawn only from Drank . The softmax is over the vocabulary, with the dense distribution as the first argument of KL, consistent with Eq. 7. For each group g, independently reduce only its threshold by a factor of 0.9 and recompute the full model’s final logits: 0.81, h = g, (g) θh = eg := d(θ (g) ), ∆eg := eg − dref . (F.2) 0.9, h ̸= g, All examples, prediction positions, and other settings stay fixed. Each probe starts from θ ref , so reductions do not accumulate across groups while building this ranking. We order groups by increasing eg ; subtracting the common baseline dref gives the identical ordering by ∆eg . Lower values indicate that the single-group reduction better preserves the dense prediction distribution. This KL error determines the trial order; the task score below determines whether a trial reduction is accepted. 27
Search rule. Initialize every group at τ0 = 0.9 and evaluate its score on Dsearch . Each trial changes only the current batch to ρτ0 , with ρ = 0.9, leaving previously accepted changes in place. Accept a trial if its search-set score does not decrease. If the score decreases, restore the accepted configuration and split the batch into two contiguous halves in the error ordering. The lower-error half is tested first. A rejected singleton retains τ0 . The procedure makes a single reduction decision per group; it does not repeatedly multiply already accepted thresholds by ρ. The search terminates when the stack is empty or when the predefined maximum number of calibration steps Tmax is reached. If the step limit is reached first, groups in the remaining unvisited batches retain their current thresholds. Algorithm 2 Error-Ranked Threshold Calibration Input: Groups G; errors eg from Eq. F.2; initial threshold τ0 ; reduction factor ρ = 0.9; fixed-search-set score s(θ); maximum calibration steps Tmax . Output: Frozen group thresholds θ. 1: G ← SortAscending(G, eg ) 2: θ ← (τ0 , . . . , τ0 ); sbest ← s(θ); Q ← [G] ▷ LIFO stack 3: t ← 0 4: while Q ̸= ∅ and t < Tmax do 5: B ← Pop(Q); θ ′ ← θ 6: t←t+1 7: Set θg′ ← ρτ0 for every g ∈ B 8: s′ ← s(θ ′ ) 9: if s′ ≥ sbest then 10: θ ← θ ′ ; sbest ← s′ 11: else if |B| > 1 then 12: (Blo , Bhi ) ← Bisect(B) 13: Push(Q, Bhi ); Push(Q, Blo ) 14: end if 15: end while 16: return θ
Final configuration and calibration cost. All reported runs use p1 = 0.94, τ0 = 0.90, and ρ = 0.90. Consequently, an unreduced group uses p2,g = 0.90/0.94 ≈ 0.95745, while an accepted reduced group uses p2,g = 0.81/0.94 ≈ 0.86170. The frozen artifact therefore needs only one bit per group in addition to the shared constants: unreduced or reduced. Its practical effect is assessed by the module ablation in Table 5.
28
Related documents
- TERM: Target-Free Jailbreak Defense via Entropy-Guided Residual Modulation#1616830
- Robust Harmful Features Under Jailbreak Attacks: Mechanistic Evidence from Attention Head Specialization in Large Language Models#319615
- Harmful Responses Are Jailbreak Templates: Transferring Autoregressive Jailbreaks to Diffusion Language Models#1424449
- Harmful Responses Are Jailbreak Templates: Transferring Autoregressive Jailbreaks to Diffusion Language Models#1417857
- NonTextual Target Attack#1131416
Retrieved via Conceptio: every document is proof-bundled with source, license, and retrieval metadata.
Read the Docs → · View CLI source on GitHub · Conceptio Open Knowledge Archive