Manuscript Offprint
arXiv:2611.07232Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
ABSTRACT
At context lengths of about 1M tokens, dense attention is costly in prefill and decoding, and training typically relies on long documents, which become scarcer as the target length increases. Most sparse attention methods score all preceding blocks or tokens, so their selection cost per query is at context length ; hierarchical selection reduces it to , but prior trainable hierarchical methods report accuracy only within their training length. We propose RecSA (Recursive Sparse Attention), which builds a tree over the KV cache in which each node summarizes its subtree with one key and one mean-pooled value. The keys come from one pooler per layer, shared by all levels and distilled from dense attention. Each level above the tokens selects at most candidates, so each query has selection cost and reads entries; the summaries of unselected candidates share one softmax with the exact tokens. Each entry's RoPE position is its index among the candidates of its level, so at any length every relative distance stays within the range seen during training. Initialized from Qwen3-4B and trained on 0.62B tokens at the original model's 32K training length, RecSA outperforms all baselines on RULER at every length from 131K to 2M; at 1M, it scores 60.5, compared with 40.0 for the best baseline, Dense + DCA. With our optimized kernels, RecSA is faster than dense attention in end-to-end prefill and decoding from 64K to 2M; at 524K on one H200 GPU, it accelerates prefill by and decoding by .
1 INTRODUCTION
State-of-the-art language models now support context windows of about 1M tokens (DeepSeek-AI et al., 2026). At such lengths, inference is costly and training data is scarce. In prefill, the computation of dense attention grows quadratically with length, and in decoding, every generated token reads the entire KV cache. Training at the target length relies on sufficiently long documents, which become scarcer as the length increases (Gao et al., 2025a). Some of these models reduce the inference cost with sparse attention (DeepSeek-AI et al., 2026). As language models continue to develop, the context they need is likely to keep growing. Longer contexts call for methods whose inference cost grows slowly with length and that need no training at the target length.
Trainable sparse attention methods such as MoBA (Lu et al., 2025), NSA (Yuan et al., 2025) and DSA (DeepSeek-AI et al., 2025) are trained at the target length. HSA (Hu et al., 2025; Leng et al., 2026; Hu et al., 2026b) and HiLS (Hu et al., 2026a) train only on short sequences, and InfLLM (Xiao et al., 2024a) and InfiniteHiP (Lee et al., 2025b) are training-free; neither group needs long docu-
(a) RULER score

(b) Decoding latency (ms per token)
Figure 1. RULER score and decoding latency from 32K to 2M. (b) End-to-end latency on one H200 GPU with batch size 1; Dense uses FlashAttention in the same framework. At 1M and 2M, host memory holds the exact tokens of RecSA (§4.3) and the part of the Dense KV cache beyond GPU memory; hollow markers indicate offloading. Arrows mark off-scale values. Percentages show the token budget of RecSA as a fraction of the context length.
*Equal contribution ¹University of California, San Diego ²Carnegie Mellon University. Correspondence to: Hao Zhang haozhang@ucsd.edu.
Preprint.
ments to run far beyond the training length. All of these methods score every preceding block or token at the first level, so at context length the selection cost per query is . Hierarchical selection scores a top level of bounded size and then only the children of selected nodes, which reduces this cost to . HiP (Lee et al., 2025a) and PISA (Tang et al., 2026) keep the original position of each key, so beyond the training length the distances to selected keys can exceed those seen in training. Hierarchical selection alone does not remove the need for context extension.
We propose RecSA, a Recursive Sparse Attention mechanism with hierarchical selection. It groups every 16 consecutive KV entries under a parent node and applies the same grouping to parent nodes, building a tree from the bottom up. Each node has one key and one mean-pooled value, which form the summary of its whole subtree. Selection starts at the top level, whose nodes form the first candidate list, and at each level scores every candidate against the query and selects at most of them. Their children form the candidate list of the next level, and this continues until the candidates are exact tokens. Unselected candidates also participate in the attention computation: their summaries and all exact tokens in the last candidate list share one softmax. Whenever the top level exceeds a fixed number of nodes, a level is added above it, so every candidate list has a bounded size, and the selection cost and the number of entries read per query are both . RoPE (Su et al., 2024) is applied to every entry, summaries included, and the position of an entry is its index in the candidate list of its level, with the query at the last index. Every relative distance to the query is thus below 4,096, the maximum size of a candidate list with the default . Longer sequences introduce no distance unseen during training at 32K.
A learnable pooler computes the key of a node from the keys of its children. Each attention layer has one pooler, applied recursively at every level of the tree, so adding a level requires no new parameters. Training starts from a pretrained dense model and has two stages. The first stage freezes the backbone and aligns the softmax over the scores of the candidate nodes at each level with the distribution of dense attention mass over their subtrees. The second stage freezes the pooler and trains the backbone under RecSA to adapt it to sparse attention. Both stages use only sequences at the training length of the original model.
We evaluate RecSA on Qwen3-4B (Yang et al., 2025), whose training length is 32K. The two stages process 0.62B tokens in total. For comparison, we train dense and sparse backbones on the same data and evaluate every backbone with each of two context extension methods, YaRN (Peng et al., 2024) and DCA (An et al., 2024); we also compare with two training-free methods. At every length, the token budget of each sparse method, i.e., the number of
entries a query attends to, is matched to that of RecSA. The evaluation covers synthetic long-context tasks, perplexity on long texts, real-world long-document tasks and short-context benchmarks. At 1M, the token budget of RecSA is only 1.16% of the context, and RecSA scores 60.5 on RULER (Hsieh et al., 2024), compared with 1.6 for Dense + YaRN, as shown in Figure 1a. The strongest of the other baselines, Dense + DCA, scores 40.0 (Table 1). At 32K, RecSA matches Dense + YaRN on RULER; on short-context benchmarks, RecSA performs comparably to the original model.
We implement prefill and decoding for RecSA in Triton (Tillet et al., 2019) and CUDA. In prefill, some existing block-sparse kernels group adjacent queries and load the union of their selected blocks once for the group (Hu et al., 2026a). This sharing reuses each key, already rotated by RoPE, for every query in the group, but in RecSA the index of a key, and hence its rotation, varies with the candidate list of each query. Because RoPE makes the attention score depend on positions only through the relative position, we split the rotation between keys and queries so that the part applied to each key is the same for all queries, and the group still loads each KV block once. On one H200 GPU with batch size 1, RecSA accelerates prefill by and decoding by at 524K, compared with dense FlashAttention (Dao, 2024) in the same framework, and its decoding latency stays nearly constant from 131K to 524K (Figure 1b).
We make the following contributions:
-
We propose RecSA, which combines hierarchical selection over a tree built on the KV cache with summaries for the unselected candidates and candidate-local RoPE (§3.1 and §3.2).
-
We distill the pooler, shared across levels, from dense attention and train RecSA only on sequences of 32K tokens (§3.3 and §3.4).
-
We provide prefill and decoding kernels for RecSA; in prefill, a group of adjacent queries loads each KV block once, although their candidate lists give its keys different positions (§4).
-
On Qwen3-4B, we compare RecSA from 32K to 2M with dense and sparse baselines, trained on the same data or training-free, at matched token budgets (§5).
Length extrapolation. Positional encoding plays an important role in how LLMs generalize beyond their training length. Transformers without explicit positional encodings (NoPE) can generalize better (Kazemnejad et al., 2023), but remain limited by increasing attention dispersion (Wang et al., 2024). Most LLMs, however, use RoPE (Su et al., 2024), which rotates a query at position by and a key at position by , so scores depend only on . Consequently, extrapolation introduces out-of-distribution relative distances (An et al., 2024). YaRN (Peng et al., 2024) mitigates this by rescaling the rotation angles of the low-frequency dimensions, while DCA (An et al., 2024) partitions the sequence into shorter chunks and remaps positions to stay within the training range. Sparse attention also improves extrapolation by limiting attention to relevant parts of a longer context (Xiao et al., 2024a; Leng et al., 2026).
3 RECURSIVE SPARSE ATTENTION
To scale context length without requiring longer training data or incurring quadratic attention costs, we introduce Recursive Sparse Attention (RecSA), as shown in Figure 2. In our model, each KV head is shared by a group of query heads through grouped-query attention (GQA) (Ainslie et al., 2023). We describe one such group for the query at position , using zero-based indices.
3.1 Tree Construction and Hierarchical Selection
Tree construction. Each attention layer maintains one KV tree per KV head. Level 0 holds the key of each token , before RoPE (§3.2), and its value . Each group of consecutive entries at level forms one parent node at level , up to the top level ( levels in total). The pooler Pool computes the key of each node (§3.3), and the value of a node is the mean of its children's values:
where and are the key and value of node at level , with and . The key and value of a node form the summary of its subtree.
Hierarchical selection. Selection proceeds from the top level down (Figure 2b). Let denote the node of level that contains position , which we call the current node. The candidate list of level is ordered by position in the sequence; at the top level, it holds the current node and all nodes before it. Query head scores candidate with its query :
(2)
where is the head dimension, is the RoPE rotation at position , is the index of candidate in and , so the query takes the last index (§3.2). As in NSA (Yuan et al., 2025), the query heads in share one selection, based on the importance . At each level , RecSA selects the current node and the other candidates with the highest importance ( by default), and the children of the selected nodes, up to the query, form the candidate list of the next level:
(3)
where , TopK returns the indices of the candidates with the highest importance and concaten joins the child lists in increasing order of , so . Level 0 has no top- selection: the query attends to all of its candidate tokens (Eq. (4)). Among the candidates of each level , only the current node can contain tokens after the query. This node takes no part in the ranking and is always expanded, with its children taken only up to the query. Hence all tokens of the level-1 current node up to the query enter the softmax as exact tokens, and every summary covers a complete subtree before the query. RecSA adds no attention sink (Xiao et al., 2024b) or fixed local window.
Depth. For the query at position , the number of levels is set by its prefix, positions 0 to : whenever the top level exceeds nodes, a level is added above it. If the prefix has at most tokens, and RecSA is equivalent to dense causal attention. With the default , ; beyond 4,096 tokens, a prefix has two levels up to 65,536 tokens, three up to 1,048,576 tokens and four at 2M.
One softmax over summaries and tokens. The summaries of the unselected candidates and the exact tokens of

Figure 2. One attention layer of RecSA ( tokens, , , three levels). (a) The pooler computes the key of a node from the keys of its 16 children; its value is the mean of their values. (b) is the score of each candidate for the query (Eq. (2)); levels 2 and 1 each select 256 candidates by this score, whose children form the next candidate list, and level 0 has no selection; pruned nodes are not candidates. (c) Summaries and exact tokens share one softmax, with output .
level 0 share one softmax (Figure 2c), over entries identified by level and index:
where, for , is the score of Eq. (2) and , and is the output of head . Because the top-level candidates cover the prefix and each selected node is replaced by its children up to the query, the summaries and the exact tokens partition the prefix. The softmax uses the score of a summary as its logit, with no correction for subtree size or level.
Cost. For fixed and , each level scores at most candidates, and the number of levels grows logarithmically with , so the selection cost per query is . The token budget is the number of entries a query attends to, : at most exact tokens at level 0 and, at each level above, the summaries of at most unselected candidates (3,840 with the default ). The number of entries a query reads, counting each candidate once, is the token budget plus the keys of the selected nodes, which are expanded instead of entering the softmax; it is at most , also .
3.2 Candidate-Local RoPE
RecSA applies RoPE (Su et al., 2024) with one change, which we call candidate-local RoPE: every candidate of level , summaries included, takes its index in as its position, and the query takes the last index, that of the current node. Parts of the sequence skipped between candidates receive no positions. Each level has at most candidates (), so the relative distance between the query
(a) RoPE and ReRoPE
| RoPE | 63 | ... | 40 | 39 | 38 | 37 | 36 | 35 | ... | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ReRoPE | 4 | ... | 4 | 4 | 4 | 4 | 4 | 4 | ... | 4 | 3 | 2 | 1 | 0 |
window
(b) Candidate-local RoPE, ,
| level 2 | 3 | 2 | 1 | 0 | ||||
|---|---|---|---|---|---|---|---|---|
| level 1 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| level 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
selected exact token unselected candidate
Figure 3. Relative distance to the query , the last of 64 tokens. (a) RoPE and ReRoPE (Su, 2023); gray bars stand for runs of tokens. (b) Candidate-local RoPE on an example tree with children per node and selected nodes per level: each selected node is drawn above its children, and at every level the distances stay below . Dashed spans mark parts of the sequence skipped between candidates; they receive no positions.
and any candidate always lies between 0 and 4,095. During backbone training on 32K sequences with (), the candidate list of level 0 reaches 4,096 tokens, so training covers every relative distance that occurs at inference with the same . Figure 3 compares candidate-local RoPE with ReRoPE (Su, 2023), which puts every token beyond a window at distance from the query; under candidate-local RoPE, the candidates of one level are all at different distances from the query.
Because one node can have different indices in the candidate lists of different queries, the tree stores keys before RoPE, and the pooler () pools these keys without position input. We keep the RoPE base of the original model, without scaling.
3.3 Pooler Distillation
Because the key of a node is used both in the importance shared by a GQA group (Eq. (2)) and in the logit of each head in the final softmax (Eq. (4)), both should reflect the dense attention mass on the subtree of the node, so we supervise the pooler with this mass. A mean-pooled key generally does not represent this mass accurately (Hu et al., 2025; Leng et al., 2026). The pooler computes the key of node at level from the keys of its children, for (Figure 2a):
where is the mean of the , is the root mean square of the elements of all , is the root mean square of the elements of , is a scoring vector, the scalars and are an inverse temperature and a gate, denotes concatenation and is the MLP term. Mean pooling is the special case , . Each attention layer has one pooler with 24,770 parameters, shared across levels and across all KV heads of the layer. Appendix A gives the parameter shapes and implementation details.
For each level , we compute the attention mass that the frozen original model, with RoPE at the original positions, puts on the subtree of each candidate in , and average it over the heads of the group. Below the top level, the candidates cover only part of the prefix, so their masses need not sum to one; normalizing them over the candidate list gives the teacher distribution . The student distribution normalizes the importance of Eq. (2) over the same list. Both distributions use the queries and keys of the same forward pass of the frozen original model, so the loss of each layer depends only on the pooler of that layer. We fit the student distribution to the teacher distribution with a KL divergence:
(6)
Below the top level, the candidate lists come from the student's own selection, which follows the same rule as at inference; no gradient flows through the selection.
The MLP term of the pooler can shift the keys of all nodes of a level by the same vector . Under candidate-local RoPE, the score of candidate then gains , which depends on the query and on the position of the candidate, but not on the content of the candidate's subtree. Training can lower the KL through this positional bias, without the pooler learning to distinguish subtrees by their content. We add a shift penalty on the mean of the MLP term over the nodes of each level of a tree, that is, on the shift shared by these nodes, but not on the differences between them:
where , and are those of node i in Eq. (5); the denominator makes the penalty independent of the key scale.
3.4 Training
Stage 1: Pooler. We freeze the backbone and train only the parameters of the pooler (§3.3). Because the pooler (Eq. (5)) does not involve , this stage uses a smaller to obtain deeper trees from 32K sequences. With , the training sequences of 32K tokens have three levels, and the pooler learns to construct the keys of level 2 from the pooled keys of level 1. Inference with the default uses at most these three levels up to 1M; at 2M, it adds level 3, which reuses the same parameters. Stage 1 has two parts on the same sequences. The first part trains , and with the MLP term off ( fixed at 0). Its loss is ; on retrieval and question-answering sequences with a single piece of evidence, we add an auxiliary cross-entropy whose target is the top-level node that contains the evidence. The second part freezes , and and trains , and with . Appendix E gives the hyperparameters and the sampled query positions.
Stage 2: Backbone. We freeze the pooler and train the whole backbone under RecSA with the default k = 256 and only the language modeling loss (data in §5.1). Gradients also reach the backbone through the keys and values of the summaries, via the frozen pooler and mean pooling, respectively; no gradient flows through the selection.
4 EFFICIENT PREFILL AND DECODING
4.1 Prefill
In prefill, adjacent queries select overlapping sets of parent nodes. Some existing block-sparse kernels process a group of adjacent queries over the union of their selected blocks and load each block once for the group, with its keys already rotated by RoPE (Hu et al., 2026a). Under candidate-local RoPE, however, a key can take different positions, and hence different rotations, in the candidate lists of different queries.
We split the rotation between keys and queries using slots: the -th node that a query selects at level , in index order, is its slot . In Figure 4a, the parent node of the framed block is slot 2 of and slot 3 of . Eq. (3) concatenates the child lists in slot order, and only the last list (that of the current node) can be truncated, so child of slot has index in . Because , the product in

Figure 4. Prefill and decoding of RecSA. (a) Prefill: rows correspond to the 16 adjacent queries of one thread block and columns to the union of the parent nodes they selected; numbers give the slot of the parent node for the query of the row. The black frame marks one block (the 16 children of a parent node), loaded once per pass and shared by the queries that selected its parent. (b) Decoding with KV offloading: blue indicates selected nodes and blocks, light orange unselected candidates (summaries) and gray other nodes.
Eq. (2) for this child becomes
where and is the key of the child. The key-side rotation depends only on , not on the query, so the rotated keys of each level are shared by all queries. The rest of the rotation moves to the query side: each query starts from and is rotated by after each node it selected. Our kernels give the same output as rotating the keys for each query, within floating-point error.
One thread block processes the 4 query heads of one KV head for 16 adjacent queries (Figure 4a). A pass loops through the union of the parent nodes that the 16 queries selected, in index order: for each parent, the thread block loads the 16 children into shared memory once and scores them on tensor cores for all 64 query-head pairs, masking the queries that did not select this parent. On PG-19, each KV block loaded in the pass of level 0 serves 7.5, 5.2 and 4.1 of the 16 queries on average at 32K, 131K and 524K.
Each level takes two passes: the first computes the importance of Eq. (2), and after selection, the second accumulates only the unselected candidates into an online softmax (Dao, 2024) as summaries. At the top level, whose candidates are the current node and all nodes before it, both passes are dense and tiled. Level 0 takes one pass, which accumulates all of its candidate tokens into the same softmax.
4.2 Decoding
In decoding (Figure 4b), the key and value of each new token are appended to level 0 (①). Except at a step that adds a level (§3.1), only the last node of each level changes, and RecSA recomputes its key and value (②) from its 16 or fewer children by Eq. (1).
With batch size 1, each step has one query, and scoring a
level with one thread block for each of the 8 KV heads would occupy at most 8 of the 132 SMs of an H200. RecSA instead splits the candidate list of each level into 16 segments, so that at least 128 thread blocks compute the importance, each relative to the maximum score in its segment (③). A second kernel rescales these values to the maximum over all segments and selects the same top- as without segments. The softmax accumulation is split into 16 segments in the same way, and their partial results are merged (⑤).
Because each level has at most candidates (§3.1), every kernel can use a fixed launch grid and read the current context length from GPU memory, so the decoding step of all 36 layers is captured as one CUDA graph and replayed at every step that does not add a level.
4.3 KV Offloading
At 1M and 2M, the full KV cache takes 137 and 275 GiB, which together with the 7.5 GiB of model weights exceeds the 140 GiB of memory on one H200. RecSA keeps the exact tokens in pinned host memory, and the GPU needs to hold only the levels above level 0 (less than 7% of the full KV cache) and buffers for the gathered exact tokens.
Selection reads only the keys of levels and runs entirely on the GPU. A gather kernel then copies the exact tokens in the candidate list of level 0, the children of the selected level-1 nodes, from host memory over PCIe in 16-token blocks (④). Each step gathers at most exact tokens per KV head and layer, at most 576 MiB over the 36 layers, independent of the context length.
After space is reserved for the generated tokens, the remaining GPU memory caches a suffix of the input. The gather kernel reads the cached blocks from the GPU cache and the others from host memory.
Table 1. RULER score (average over the 13 tasks) by context length. Token budget: entries the query at the last position attends to (for RecSA, exact tokens plus summaries), matched across the sparse methods. Best results are in bold.
| Method | 32K | 131K | 262K | 524K | 1M | 2M |
|---|---|---|---|---|---|---|
| Token budget | 5,888 | 8,192 | 8,704 | 9,728 | 11,575 | 11,990 |
| % of context | 18.0 | 6.25 | 3.32 | 1.86 | 1.16 | 0.60 |
| Training-free | ||||||
| InfLLM | 45.0 | 29.3 | 29.2 | 27.4 | 25.7 | 24.2 |
| InfiniteHiP | 79.6 | 63.7 | 57.7 | 49.4 | 36.6 | 34.0 |
| Trained at 32K | ||||||
| Dense + YaRN | 94.5 | 80.0 | 48.3 | 3.6 | 1.6 | 1.1 |
| Dense + DCA | 94.6 | 78.5 | 68.4 | 58.0 | 40.0 | 27.6 |
| MoBA + YaRN | 81.6 | 31.9 | 5.1 | 0.9 | 1.0 | 0.6 |
| MoBA + DCA | 81.8 | 37.9 | 23.8 | 18.1 | 12.5 | 7.2 |
| DSA + YaRN | 95.3 | 80.5 | 57.1 | 18.8 | 6.0 | 1.4 |
| DSA + DCA | 95.2 | 77.5 | 65.7 | 55.2 | 36.8 | 22.6 |
| RecSA (ours) | 94.7 | 83.3 | 75.9 | 69.7 | 60.5 | 49.3 |
On the RULER samples of Appendix D.1, decoding at 1M and 2M takes 8.35 and 10.7 ms per token with the cache, compared with 19.8 and 20.6 ms without the cache.
5 EVALUATION
5.1 Experimental Setup
Model and training. We apply RecSA to Qwen3-4B (Yang et al., 2025), whose training length is 32K, and train it with the two stages of §3.4 on 0.62B tokens in total. The training data include synthetic retrieval tasks, document question answering, books, code and instructions whose responses were generated by the original model (Appendix E). Unless otherwise stated, we evaluate with the default .
Baselines. We train three backbones, Dense, MoBA and DSA, from Qwen3-4B with the settings, sequences, order and number of steps of Stage 2; for DSA, the indexer is first warmed up as in DeepSeek-AI et al. (2025). We evaluate each backbone with YaRN and with DCA and name each model by its attention and its context extension method, such as Dense + YaRN. Qwen3-4B + YaRN denotes the original model with YaRN. The training-free InfLLM and InfiniteHiP run on the original model with their official implementations. At each length, the token budget of every sparse baseline, counted as in §2, is matched to that of RecSA for the query at the last position (Table 1). Appendix E.4 gives the settings at each length.
Benchmarks. RULER (Hsieh et al., 2024) has 13 synthetic tasks (Appendix B). We report its official score, averaged over all tasks, with greedy decoding on 56 samples per task from 32K to 262K, 20 at 524K and 16 at 1M
and above. All methods in Table 1 use the same samples. Perplexity at context length is computed on the last of the first tokens of each of nine PG-19 books (Rae et al., 2020) (Appendix C). For long-document tasks, we select LongBench (Bai et al., 2024) and En.MC from InfiniteBench (Zhang et al., 2024), and for short-context tasks, MMLU (Hendrycks et al., 2021), ARC-C (Clark et al., 2018), GSM8K (Cobbe et al., 2021), IFEval (Zhou et al., 2023), HumanEval (Chen et al., 2021) and MBPP (Austin et al., 2021). Context lengths from 32K to 524K denote to tokens, and 1M and 2M denote and tokens.
Efficiency. We measure latency on one H200 GPU with batch size 1. In the same framework as RecSA, Dense uses FlashAttention-2 (Dao, 2024) for prefill and FlashDecoding (Dao et al., 2023) for decoding. At 1M and 2M, host memory holds the exact tokens of RecSA (§4.3) and, in decoding, the part of the Dense KV cache beyond GPU memory. Appendix D.1 describes how we measure latency.
5.2 Length Extrapolation
Table 1 shows that RecSA achieves the highest RULER score at every length from 131K to 2M. It outperforms the strongest baseline by 2.8 points at 131K (DSA + YaRN) and by 11.7 at 524K and 20.5 at 1M (Dense + DCA). At 2M, RecSA scores 49.3, compared with 34.0 for InfiniteHiP (Lee et al., 2025b), the strongest baseline at this length. At 32K, RecSA matches Dense + YaRN (94.7 vs. 94.5).
Beyond 131K, each backbone scores higher with DCA than with YaRN. For example, Dense + DCA scores 40.0 at 1M and Dense + YaRN 1.6. Like RecSA, DSA + DCA uses a matched token budget and keeps every relative distance within the range seen during training, but at 1M it scores 36.8, compared with 60.5 for RecSA. Keeping relative distances within this range thus does not by itself explain the higher score of RecSA.
On individual tasks (Table 2 and Appendix B), RecSA achieves the highest score on MK1, MQ, MV, S2 and VT at every length from 131K to 2M. For example, at 1M, RecSA scores 90.6 on multi-query retrieval (MQ) and 95.0 on variable tracking (VT); the strongest baselines on these two tasks score 37.5 (InfiniteHiP) and 82.5 (Dense + DCA).
From 131K to 1M, the perplexity of RecSA stays between 10.87 and 11.12 (Table 3). At 1M, the perplexity ranges from 54.42 to 414.69 for the methods with YaRN and from 14.57 to 19.18 for those with DCA.
5.3 Short-Context and Long-Document Tasks
On the six short-context benchmarks (Table 4), RecSA performs comparably to Qwen3-4B; the largest difference
Table 2. RULER score per task at 131K and 1M. Retrieval: needle-in-a-haystack tasks with a single needle (S1–S3), multiple keys (MK1–MK3), multiple values (MV) or multiple queries (MQ). VT: variable tracking. CWE: common words extraction. FWE: frequent words extraction. QA1: SQuAD (Rajpurkar et al., 2016). QA2: HotpotQA (Yang et al., 2018). Best results in each column at each length are in bold. Appendix B gives the scores at all lengths.
| Method | Retrieval | Tracing | Aggregation | QA | Avg | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| S1 | S2 | S3 | MK1 | MK2 | MK3 | MV | MQ | VT | CWE | FWE | QA1 | QA2 | ||
| 131K | ||||||||||||||
| InfLLM | 100.0 | 7.1 | 0.0 | 5.4 | 57.1 | 0.0 | 7.6 | 3.6 | 60.0 | 36.4 | 86.3 | 8.9 | 8.9 | 29.3 |
| InfiniteHiP | 100.0 | 91.1 | 91.1 | 73.2 | 32.1 | 0.0 | 76.3 | 86.6 | 57.1 | 55.9 | 86.3 | 55.4 | 23.2 | 63.7 |
| Dense + YaRN | 100.0 | 100.0 | 98.2 | 94.6 | 64.3 | 41.1 | 91.5 | 94.6 | 95.7 | 70.7 | 85.7 | 58.9 | 44.6 | 80.0 |
| Dense + DCA | 100.0 | 98.2 | 100.0 | 78.6 | 73.2 | 41.1 | 81.7 | 94.6 | 90.4 | 79.3 | 90.5 | 60.7 | 32.1 | 78.5 |
| MoBA + YaRN | 87.5 | 10.7 | 25.0 | 19.6 | 14.3 | 1.8 | 18.8 | 8.9 | 81.8 | 41.8 | 58.3 | 30.4 | 16.1 | 31.9 |
| MoBA + DCA | 98.2 | 14.3 | 17.9 | 19.6 | 23.2 | 8.9 | 17.9 | 12.1 | 81.8 | 48.2 | 88.7 | 37.5 | 25.0 | 37.9 |
| DSA + YaRN | 100.0 | 100.0 | 100.0 | 94.6 | 66.1 | 26.8 | 88.8 | 96.4 | 98.2 | 80.5 | 84.5 | 67.9 | 42.9 | 80.5 |
| DSA + DCA | 100.0 | 98.2 | 100.0 | 78.6 | 69.6 | 37.5 | 79.0 | 92.9 | 89.3 | 81.8 | 86.3 | 62.5 | 32.1 | 77.5 |
| RecSA (ours) | 100.0 | 100.0 | 100.0 | 100.0 | 76.8 | 37.5 | 92.0 | 99.6 | 99.6 | 84.8 | 88.7 | 57.1 | 46.4 | 83.3 |
| 1M | ||||||||||||||
| InfLLM | 100.0 | 6.2 | 0.0 | 0.0 | 56.2 | 0.0 | 1.6 | 3.1 | 53.8 | 7.5 | 81.2 | 18.8 | 6.2 | 25.7 |
| InfiniteHiP | 87.5 | 62.5 | 43.8 | 37.5 | 6.2 | 0.0 | 42.2 | 37.5 | 52.5 | 1.9 | 85.4 | 18.8 | 0.0 | 36.6 |
| Dense + YaRN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 20.8 | 0.0 | 0.0 | 1.6 |
| Dense + DCA | 100.0 | 56.2 | 75.0 | 56.2 | 6.2 | 0.0 | 29.7 | 26.6 | 82.5 | 2.5 | 79.2 | 6.2 | 0.0 | 40.0 |
| MoBA + YaRN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 12.5 | 0.0 | 0.0 | 1.0 |
| MoBA + DCA | 75.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 15.0 | 0.0 | 60.4 | 6.2 | 6.2 | 12.5 |
| DSA + YaRN | 43.8 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.2 | 0.0 | 27.1 | 6.2 | 0.0 | 6.0 |
| DSA + DCA | 100.0 | 31.2 | 62.5 | 43.8 | 6.2 | 0.0 | 29.7 | 20.3 | 71.2 | 21.9 | 72.9 | 6.2 | 12.5 | 36.8 |
| RecSA (ours) | 100.0 | 87.5 | 100.0 | 81.2 | 25.0 | 6.2 | 54.7 | 90.6 | 95.0 | 23.1 | 85.4 | 31.2 | 6.2 | 60.5 |


Figure 5. Efficiency on one H200 GPU with batch size 1. (a) Prefill time per token of RecSA and of Dense with FlashAttention in the same framework; hollow markers indicate RecSA with offloading (§4.3), and arrows mark values above the axis range. (b) Time breakdown of one decoding step of RecSA. Non-attention: the remaining step time, including the projections, the MLPs and the idle time between kernels. Gather: gathering the selected exact tokens from host memory and from the GPU cache (§4.3).
is 1.8 points, on MBPP (61.8 vs. 63.6). On LongBench, RecSA scores 51.8, compared with 49.2 for the original Qwen3-4B and 50.9 for the Dense backbone. On En.MC, RecSA scores 66.8 and Qwen3-4B + YaRN 34.5; Infinite-HiP, Dense + DCA and DSA + DCA score 66.4, 62.4 and 62.0, respectively. Appendix C gives the scores of Dense on all benchmarks and the En.MC scores by input length.
5.4 Efficiency
Prefill of 32K tokens takes 1.59 s with RecSA and 1.46 s with Dense, and from 64K to 2M, RecSA is faster (Figure 5a). At 524K, prefill takes 80 s with RecSA and 257 s with Dense, a 3.2× speedup.
RecSA is faster than Dense in decoding at every measured length, including 32K (Figure 1b). From 131K to 524K, RecSA takes about 6.1 ms per token, while the latency of

Figure 6. RULER score in the ablation experiments. (a) Position encoding. Standard RoPE applies RoPE at absolute token positions and is evaluated with and without YaRN beyond 32K. (b) Pooler. KL and the shift penalty are the losses of Eqs. (6) and (7), and LM loss trains the MLP term with the language modeling loss. Backbone frozen: each pooler is trained on the original model and evaluated with it at 32K, 131K and 524K. Backbone trained: for KL + shift penalty and w/o MLP term, the backbone is then trained as in Stage 2. KL + shift penalty is the pooler of RecSA. (c) RecSA evaluated with and 512. Appendix F gives all scores.
Table 3. Perplexity on nine PG-19 books (Rae et al., 2020) by context length. Sparse methods use the token budgets of Table 1. InfLLM and InfiniteHiP are not listed because their key selection during prefill is not causal. Best results are in bold.
| Method | 32K | 131K | 262K | 524K | 1M |
|---|---|---|---|---|---|
| Trained at 32K | |||||
| Dense + YaRN | 11.17 | 11.81 | 16.96 | 60.94 | 211.33 |
| Dense + DCA | 11.17 | 11.27 | 12.20 | 13.39 | 14.57 |
| MoBA + YaRN | 12.11 | 13.51 | 20.43 | 122.30 | 414.69 |
| MoBA + DCA | 12.11 | 12.87 | 14.85 | 17.12 | 19.18 |
| DSA + YaRN | 11.15 | 11.81 | 15.23 | 25.88 | 54.42 |
| DSA + DCA | 11.15 | 11.32 | 12.35 | 13.67 | 15.01 |
| RecSA (ours) | 11.24 | 10.87 | 11.00 | 11.08 | 11.12 |
Table 4. Scores on short-context benchmarks and long-document tasks. LongBench (Bai et al., 2024): average score over 12 English tasks and 2 code tasks. En.MC: multiple-choice questions about full-length novels from InfiniteBench (Zhang et al., 2024), with inputs of 70K–746K tokens; Qwen3-4B uses YaRN for context extension on En.MC. Best results in each row are in bold.
| Benchmark | Qwen3-4B | RecSA |
|---|---|---|
| MMLU (5-shot) | 70.1 | 70.5 |
| ARC-C (0-shot) | 87.2 | 88.1 |
| GSM8K (0-shot, CoT) | 91.5 | 90.7 |
| IFEval (prompt, strict) | 79.1 | 78.6 |
| HumanEval (0-shot, pass@1) | 82.3 | 81.7 |
| MBPP (0-shot, pass@1) | 63.6 | 61.8 |
| LongBench | 49.2 | 51.8 |
| InfiniteBench En.MC | 34.5 | 66.8 |
Dense grows from 8.6 ms to 23.4 ms, that of RecSA at 524K. At 1M and 2M, RecSA takes 8.35 and 10.7 ms per token, compared with 177 ms and 2.9 s for Dense. Copying
the part of the Dense KV cache in host memory to the GPU accounts for 77% and 96% of the Dense latency, respectively.
The decoding step time of RecSA (Figure 5b) stays nearly constant from 131K to 524K, where the tree has three levels and each level scores at most candidates ( ). At these lengths, the non-attention part takes 3.35 ms, more than half of the step. At 1M and 2M, the selected exact tokens are gathered from host memory and from the GPU cache (Gather), and at 2M, the tree has a fourth level. A two-level variant scores every level-1 node at each step, 8,192 nodes at 131K and 125,000 at 2M, and RecSA is faster than this variant at 131K and faster at 2M (Table D.3).
5.5 Ablation Studies
Unless otherwise stated, each variant below is trained with the same data, order and steps as RecSA.
Summaries improve the average score at long contexts. A model trained and evaluated without summaries, whose softmax covers only the exact tokens, averages 70.4 over the four lengths from 131K to 1M, compared with 72.3 for RecSA (Appendix F).
Candidate-local RoPE improves length extrapolation. The standard RoPE variant is trained with both stages of §3.4, the pooler included, but applies RoPE at absolute token positions. At 32K, it scores 95.2 and RecSA 94.7 (Figure 6a). Without YaRN, standard RoPE scores 1.0 at 131K, where relative distances exceed those seen during training. With YaRN, it scores 66.2 at 131K and 1.9 at 524K and 1M, while RecSA scores 83.3 at 131K and 60.5 at 1M.
Distillation, the shift penalty and the MLP term improve the score at long contexts. With the backbone frozen (Figure 6b), the five poolers score between 73.6 and 78.9 at 32K but between 8.9 and 55.5 at 524K, where the pooler of RecSA (KL + shift penalty) scores highest. Training the MLP term with the language modeling loss instead of distillation gives the lowest scores at 131K and 524K, below mean pooling, and training with KL alone, without the shift penalty, lowers the score at 524K from 55.5 to 45.3. With the backbone trained, the decrease from removing the MLP term grows with length: 3.3 points at 131K, 11.5 at 262K, 19.3 at 524K and 23.4 at 1M. Appendix A.4 examines how the MLP term changes selection.
Increasing to 512 improves the score at every length. Because sets the token budget (§3.1), we evaluate the trained RecSA model with and (Figure 6c). At every length from 32K to 1M, scores higher than , with the token budget, and scores lower at 131K, 262K and 1M. With , relative distances in a candidate list reach 8,191, compared with at most 4,095 in training with .
6 RELATED WORK
Hierarchical selection and summaries. HiP (Lee et al., 2025a) is training-free and selects level by level in a binary tree, scoring each block by one representative key. PISA (Tang et al., 2026) builds a pyramid of mean-pooled block keys, scores each candidate by the LogSumExp of the scores of its children and trains models with this selection. Both discard the unselected blocks. Other methods combine attention over selected tokens with coarse representations of the context. NSA attends to the compressed blocks of the whole context and to the selected blocks in separate branches. Multipole Attention (Hooper et al., 2025) is training-free: in decoding, it clusters the keys with k-means, attends exactly to the keys of high-scoring clusters, approximates the other clusters by their centroids and normalizes both parts together. RecSA also normalizes summaries and exact tokens together, and they partition the prefix; the keys of its summaries come from a trained pooler, and each level scores a bounded number of candidates.
Sparse attention beyond the training length. Landmark Attention (Mohtashami & Jaggi, 2023), HSA (Hu et al., 2025; Leng et al., 2026) and HiLS (Hu et al., 2026a) learn a representation for each block and train the block scores end to end with the language modeling loss. HSA pretrains models of about 240M parameters from scratch at 4K, fine-tunes them on RULER tasks and evaluates them up to 32M. HiLS pretrains models from scratch at 8K and evaluates them up to 4M; it also converts the pretrained Olmo3-7B to HiLS by continued pretraining at 8K, with RULER examples mixed
into the training data, and evaluates it on RULER up to 1M.
Distilled selectors. SeerAttention (Gao et al., 2025b) fits a block-level gate to the max-pooled attention map with a KL divergence and uses it in prefill; SeerAttention-R (Gao et al., 2026) applies such a gate in decoding. The warm-up stage of DSA (DeepSeek-AI et al., 2025) trains only the indexer, fitting it to dense attention with a KL divergence, before the whole model is trained. These methods supervise the scores of one level. RecSA supervises the scores of every level with the dense attention mass on the subtree of each candidate, through one pooler shared across levels, and the keys that the pooler computes serve both for selection and as the keys of summaries.
Position encoding. InfLLM (Xiao et al., 2024a) assigns one position to all tokens beyond the local window, InfiniteHiP gives the selected keys consecutive positions and Landmark Attention maps the retrieved blocks into a reserved range of positions. HiLS keeps RoPE only in the dimensions whose rotation period does not exceed the pre-training length; PISA applies RoPE to the high-frequency half of the dimensions of each head. Context extension methods, such as YaRN, DCA, ReRoPE, PI (Chen et al., 2023), LongRoPE (Ding et al., 2024) and SelfExtend (Jin et al., 2024), change the rotation angles or the assignment of positions. RecSA assigns each candidate its index in the candidate list of its level, and each level has at most candidates, so every relative distance stays below at any context length.
Training-free sparse attention and KV offloading. Training-free sparse methods accelerate prefill (Jiang et al., 2024; Lai et al., 2025) or decoding. Quest (Tang et al., 2024) estimates, at each decoding step, an upper bound on the query-key scores in every page of the KV cache, and the first pruning stage of InfiniteHiP scans all keys; in RecSA, the selection cost per query is . InfLLM and InfiniteHiP, like RecSA (§4.3), keep most of the KV cache in host memory and cache part of it on the GPU.
7 CONCLUSION
We present RecSA, which builds a tree over the KV cache and selects level by level; the summaries of unselected candidates share one softmax with the exact tokens. Its selection cost and the number of entries read per query are , and candidate-local RoPE keeps every relative distance within the range seen during training, so RecSA has no inherent limit on context length. We initialize RecSA from Qwen3-4B, distill its pooler from dense attention and train it only at the original model's 32K training length. On RULER, RecSA outperforms all baselines from 131K to 2M. With our kernels, RecSA is faster than dense attention in end-to-end prefill and decoding from 64K to 2M.
REFERENCES
Ainslie, J., Lee-Thorp, J., de Jong, M., Zemlyanskiy, Y., Lebrón, F., and Sanghai, S. GQA: Training generalized multi-query transformer models from multi-head checkpoints. In Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 4895–4901, 2023.
An, C., Huang, F., Zhang, J., Gong, S., Qiu, X., Zhou, C., and Kong, L. Training-free long-context scaling of large language models. In International Conference on Machine Learning (ICML), pp. 1493–1510, 2024.
Austin, J., Odena, A., Nye, M., Bosma, M., Michalewski, H., Dohan, D., Jiang, E., Cai, C., Terry, M., Le, Q., and Sutton, C. Program synthesis with large language models. arXiv preprint arXiv:2108.07732, 2021.
Bai, Y., Lv, X., Zhang, J., Lyu, H., Tang, J., Huang, Z., Du, Z., Liu, X., Zeng, A., Hou, L., Dong, Y., Tang, J., and Li, J. LongBench: A bilingual, multitask benchmark for long context understanding. In Annual Meeting of the Association for Computational Linguistics (ACL), pp. 3119–3137, 2024.
Chen, M., Tworek, J., Jun, H., Yuan, Q., Pinto, H. P. d. O., Kaplan, J., Edwards, H., Burda, Y., Joseph, N., Brockman, G., Ray, A., Puri, R., Krueger, G., Petrov, M., Khlaaf, H., Sastry, G., Mishkin, P., Chan, B., Gray, S., Ryder, N., Pavlov, M., Power, A., Kaiser, L., Bavarian, M., Winter, C., Tillet, P., Such, F. P., Cummings, D., Plappert, M., Chantzis, F., Barnes, E., Herbert-Voss, A., Guss, W. H., Nichol, A., Paino, A., Tezak, N., Tang, J., Babuschkin, I., Balaji, S., Jain, S., Saunders, W., Hesse, C., Carr, A. N., Leike, J., Achiam, J., Misra, V., Morikawa, E., Radford, A., Knight, M., Brundage, M., Murati, M., Mayer, K., Welinder, P., McGrew, B., Amodei, D., McCandlish, S., Sutskever, I., and Zaremba, W. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
Chen, S., Wong, S., Chen, L., and Tian, Y. Extending context window of large language models via positional interpolation. arXiv preprint arXiv:2306.15595, 2023.
Clark, P., Cowhey, I., Etzioni, O., Khot, T., Sabharwal, A., Schoenick, C., and Tafjord, O. Think you have solved question answering? Try ARC, the AI2 reasoning challenge. arXiv preprint arXiv:1803.05457, 2018.
Cobbe, K., Kosaraju, V., Bavarian, M., Chen, M., Jun, H., Kaiser, L., Plappert, M., Tworek, J., Hilton, J., Nakano, R., Hesse, C., and Schulman, J. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021.
Dao, T. FlashAttention-2: Faster attention with better parallelism and work partitioning. In International Conference on Learning Representations (ICLR), 2024.
Dao, T., Haziza, D., Massa, F., and Sizov, G. Flash-Decoding for long-context inference. https://crfm.stanford.edu/2023/10/12/flashdecoding.html, 2023.
Dasigi, P., Lo, K., Beltagy, I., Cohan, A., Smith, N. A., and Gardner, M. A dataset of information-seeking questions and answers anchored in research papers. In Conference of the North American Chapter of the Association for Computational Linguistics (NAACL), pp. 4599–4610, 2021.
DeepSeek-AI, Liu, A., Mei, A., Lin, B., Xue, B., Wang, B., Xu, B., Wu, B., Zhang, B., Lin, C., Dong, C., Lu, C., Zhao, C., Deng, C., Xu, C., Ruan, C., Dai, D., Guo, D., Yang, D., Chen, D., Li, E., Zhou, F., Lin, F., Dai, F., Hao, G., Chen, G., Li, G., Zhang, H., Xu, H., Li, H., Liang, H., Wei, H., Zhang, H., Luo, H., Ji, H., Ding, H., Tang, H., Cao, H., Gao, H., Qu, H., Zeng, H., Huang, J., Li, J., Xu, J., Hu, J., Chen, J., Xiang, J., Yuan, J., Cheng, J., Zhu, J., Ran, J., Jiang, J., Qiu, J., Li, J., Song, J., Dong, K., Gao, K., Guan, K., Huang, K., Zhou, K., Huang, K., Yu, K., Wang, L., Zhang, L., Wang, L., Zhao, L., Yin, L., Guo, L., Luo, L., Ma, L., Wang, L., Zhang, L., Di, M. S., Xu, M. Y., Zhang, M., Zhang, M., Tang, M., Zhou, M., Huang, P., Cong, P., Wang, P., Wang, Q., Zhu, Q., Li, Q., Chen, Q., Du, Q., Xu, R., Ge, R., Zhang, R., Pan, R., Wang, R., Yin, R., Xu, R., Shen, R., Zhang, R., Liu, S. H., Lu, S., Zhou, S., Chen, S., Cai, S., Chen, S., Hu, S., Liu, S., Hu, S., Ma, S., Wang, S., Yu, S., Zhou, S., Pan, S., Zhou, S., Ni, T., Yun, T., Pei, T., Ye, T., Yue, T., Zeng, W., Liu, W., Liang, W., Pang, W., Luo, W., Gao, W., Zhang, W., Gao, X., Wang, X., Bi, X., Liu, X., Wang, X., Chen, X., Zhang, X., Nie, X., Cheng, X., Liu, X., Xie, X., Liu, X., Yu, X., Li, X., Yang, X., Li, X., Chen, X., Su, X., Pan, X., Lin, X., Fu, X., Wang, Y. Q., Zhang, Y., Xu, Y., Ma, Y., Li, Y., Li, Y., Zhao, Y., Sun, Y., Wang, Y., Qian, Y., Yu, Y., Zhang, Y., Ding, Y., Shi, Y., Xiong, Y., He, Y., Zhou, Y., Zhong, Y., Piao, Y., Wang, Y., Chen, Y., Tan, Y., Wei, Y., Ma, Y., Liu, Y., Yang, Y., Guo, Y., Wu, Y., Wu, Y., Cheng, Y., Ou, Y., Xu, Y., Wang, Y., Gong, Y., Wu, Y., Zou, Y., Li, Y., Xiong, Y., Luo, Y., You, Y., Liu, Y., Zhou, Y., Wu, Z. F., Ren, Z. Z., Zhao, Z., Ren, Z., Sha, Z., Fu, Z., Xu, Z., Xie, Z., Zhang, Z., Hao, Z., Gou, Z., Ma, Z., Yan, Z., Shao, Z., Huang, Z., Wu, Z., Li, Z., Zhang, Z., Xu, Z., Wang, Z., Gu, Z., Zhu, Z., Li, Z., Zhang, Z., Xie, Z., Gao, Z., Pan, Z., Yao, Z., Feng, B., Li, H., Cai, J. L., Ni, J., Xu, L., Li, M., Tian, N., Chen, R. J., Jin, R. L., Li, S. S., Zhou, S., Sun, T., Li, X. Q., Jin, X., Shen, X., Chen, X., Song, X., Zhou, X., Zhu, Y. X., Huang, Y., Li, Y., Zheng, Y., Zhu, Y., Ma, Y., Huang,
Z., Xu, Z., Zhang, Z., Ji, D., Liang, J., Guo, J., Chen, J., Xia, L., Wang, M., Li, M., Zhang, P., Chen, R., Sun, S., Wu, S., Ye, S., Wang, T., Xiao, W. L., An, W., Wang, X., Sun, X., Wang, X., Tang, Y., Zha, Y., Zhang, Z., Ju, Z., Zhang, Z., and Qu, Z. DeepSeek-V3.2: Pushing the frontier of open large language models. arXiv preprint arXiv:2512.02556, 2025.
DeepSeek-AI, Xu, A., Lin, B., Xue, B., Wang, B., Xu, B., Wu, B., Zhang, B., Lin, C., Dong, C., Ling, C., Lu, C., Zhao, C., Deng, C., Hou, C., Xu, C., Shao, C., Ruan, C., Sun, C., Dai, D., Guo, D., Yang, D., Chen, D., Li, D., Ji, D., Li, E., Wei, F., Lin, F., Yuan, F., Xia, F., Dai, F., Hao, G., Chen, G., Cao, G., Meng, G., Li, G., Yu, H., Zhang, H., Xu, H., Li, H., Liang, H., Zhang, H., Luo, H., Wei, H., Yuan, H., Zhang, H., Luo, H., Chen, H., Ji, H., Zhang, H., Ding, H., Tang, H., Cao, H., Gao, H., Qu, H., Zeng, H., Yang, J., Zhu, J. Q., Luo, J., Song, J., Yu, J., Huang, J., Cai, J., Liang, J., Zhou, J., Ye, J., Li, J., Xu, J., Hu, J., Yang, J., Chen, J., Yan, J., Chen, J., Zhou, J., Xiang, J., Yuan, J., Cheng, J., Zhou, J., Zhu, J., Yu, J., Sun, J., Ran, J., Jiang, J., Qiu, J., Li, J., Zheng, J., Song, J., Dong, K., Gao, K., Guan, K., Zhou, K., Huang, K., Yu, K., Wang, L., Zhang, L., Wang, L., Xia, L., Zhang, L., Zhao, L., Guo, L., Luo, L., Ma, L., Zhu, L., Wang, L., Cai, L., Zhang, L., Chen, L., Di, M. S., Xu, M. Y., Mei, M., Wang, M., Zhang, M., Zhang, M., Tang, M., Li, M., Zhou, M., Han, M., Wang, N., Huang, P., Wang, P., Cong, P., Wang, P., Zhang, P., Wang, Q., Zhu, Q., Li, Q., Chen, Q., Du, Q., Jiang, Q., Tian, R., Xu, R., Lu, R., Xu, R., Ge, R., Zhang, R., Pan, R., Wang, R., Chen, R., Yin, R., Xu, R., Shen, R., Zhang, R., Chen, R., Liu, S. H., Lu, S., Sun, S., Zhou, S., Chen, S., Cai, S., Nie, S., Wu, S., Chen, S., Hu, S., Liu, S., Hu, S., Ma, S., Wang, S., Yu, S., Zhou, S., Pan, S., Yu, S., Zhou, S., Ni, T., Yun, T., Jin, T., Pei, T., Ye, T., Lin, T., Ji, T., Cui, T., Yue, T., Yu, T., Wang, T., Zhang, W., Xiao, W. L., Zeng, W., An, W., Zhao, W., Liu, W., Liang, W., Pang, W., Luo, W., Yao, W., Gao, W., Yang, W., Huang, W., Hou, W., Zhang, W., Ma, W., Gao, X., He, X., Wang, X., Wang, X., Bi, X., Liu, X., Wang, X., Chen, X., Zhang, X., Nie, X., Sun, X., Wang, X., Cheng, X., Liu, X., Xie, X., Liu, X., Liu, X., Yu, X., Li, X., Yang, X., Zhang, X., Chen, X., Wang, X., Su, X., Chen, X., Lin, X., Fu, X., Yan, Y. C., Wang, Y. Q., Ma, Y. W., Luo, Y., Zhang, Y., Xu, Y., Ma, Y., Huang, Y., Li, Y., Li, Y., Xu, Y., Zhao, Y., Sun, Y., Wang, Y., Qian, Y., Shao, Y., Yu, Y., Zhang, Y., Ding, Y., Shi, Y., Wu, Y., Xiong, Y., Ma, Y., He, Y., Tang, Y., Zhou, Y., Luo, Y., Zhong, Y., Piao, Y., Wang, Y., Zhang, Y., Chen, Y., Tan, Y., Wei, Y., Ma, Y., Liu, Y., Yang, Y., Guo, Y., Wu, Y., Wu, Y., Li, Y., Cheng, Y., Ou, Y., Xu, Y., Li, Y., Wang, Y., Yang, Y., Xu, Y., Wu, Y., Meng, Y., Zou, Y., Zha, Y., Xiong, Y., Chen, Y., Lin, Y., Cao, Y., Wang, Y., Zhang, Y., Yan, Y., Lin, Y., Gu, Y., Luo, Y.,
You, Y., Liu, Y., Zhou, Y., Zhou, Y., Huang, Y., Wu, Z. F., Wang, Z., Zhao, Z., Ren, Z., Zhang, Z., Sha, Z., Fu, Z., Ju, Z., Xu, Z., Xie, Z., Zhang, Z., Gao, Z., Hao, Z., Gou, Z., Ma, Z., Yan, Z., Shao, Z., Huang, Z., Chen, Z., Wu, Z., Ren, Z., Wu, Z., Li, Z., Zhang, Z., Xu, Z., Wang, Z., Qu, Z., Gu, Z., Zhu, Z., Li, Z., Zhang, Z., Xie, Z., Gao, Z., Wan, Z., Pan, Z., and Yao, Z. DeepSeek-V4: Towards highly efficient million-token context intelligence. arXiv preprint arXiv:2606.19348, 2026.
Ding, Y., Zhang, L. L., Zhang, C., Xu, Y., Shang, N., Xu, J., Yang, F., and Yang, M. LongRoPE: Extending LLM context window beyond 2 million tokens. In International Conference on Machine Learning (ICML), pp. 11091–11104, 2024.
Gao, C., Wu, X., Lin, Z., Zhang, D., and Hu, S. NExtLong: Toward effective long-context training without long documents. In International Conference on Machine Learning (ICML), pp. 18566–18584, 2025a.
Gao, L., Tow, J., Abbasi, B., Biderman, S., Black, S., DiPofi, A., Foster, C., Golding, L., Hsu, J., Le Noac'h, A., Li, H., McDonell, K., Muennighoff, N., Ociepa, C., Phang, J., Reynolds, L., Schoelkopf, H., Skowron, A., Sutawika, L., Tang, E., Thite, A., Wang, B., Wang, K., and Zou, A. The language model evaluation harness. https://zenodo.org/records/12608602, 2024.
Gao, Y., Zeng, Z., Du, D., Cao, S., Zhou, P., Qi, J., Lai, J., So, H. K.-H., Cao, T., Yang, F., and Yang, M. SeerAttention: Self-distilled attention gating for efficient long-context prefilling. In Advances in Neural Information Processing Systems (NeurIPS), pp. 55846–55869, 2025b.
Gao, Y., Guo, S., Cao, S., Xia, Y., Cheng, Y., Wang, L., Ma, L., Sun, Y., Ye, T., Dong, L., So, H. K.-H., Hua, Y., Cao, T., Yang, F., and Yang, M. Sparse attention adaptation for long reasoning. In International Conference on Learning Representations (ICLR), 2026.
Hendrycks, D., Burns, C., Basart, S., Zou, A., Mazeika, M., Song, D., and Steinhardt, J. Measuring massive multitask language understanding. In International Conference on Learning Representations (ICLR), 2021.
Hooper, C., Zhao, S., Manolache, L., Kim, S., Mahoney, M. W., Shao, Y. S., Keutzer, K., and Gholami, A. Multi-pole attention for efficient long context reasoning. In Advances in Neural Information Processing Systems (NeurIPS), pp. 37382–37405, 2025.
Hsieh, C.-P., Sun, S., Kriman, S., Acharya, S., Rekesh, D., Jia, F., Zhang, Y., and Ginsburg, B. RULER: What's the real context size of your long-context language models? In Conference on Language Modeling (COLM), 2024.
Hu, X., Leng, J., Zhao, J., Tu, K., and Wu, W. Hardware-aligned hierarchical sparse attention for efficient long-term memory access. In Advances in Neural Information Processing Systems (NeurIPS), pp. 88925–88950, 2025.
Hu, X., Wei, X., Gu, H., Zhang, M., Liang, T., Li, H., Zhu, L., Wang, Y., Han, S., Bai, Y., Tu, K., Mi, H., and Liang, L. Hierarchical sparse attention done right: Toward infinite context modeling. arXiv preprint arXiv:2607.02980, 2026a.
Hu, X., Zhou, Z., Liang, R., Li, Z., Wu, W., and Li, J. Every token counts: Generalizing 16M ultra-long context in large language models. In Annual Meeting of the Association for Computational Linguistics (ACL), pp. 10208–10220, 2026b.
Jiang, H., Li, Y., Zhang, C., Wu, Q., Luo, X., Ahn, S., Han, Z., Abdi, A. H., Li, D., Lin, C.-Y., Yang, Y., and Qiu, L. MInference 1.0: Accelerating pre-filling for long-context LLMs via dynamic sparse attention. In Advances in Neural Information Processing Systems (NeurIPS), pp. 52481–52515, 2024.
Jin, H., Han, X., Yang, J., Jiang, Z., Liu, Z., Chang, C.-Y., Chen, H., and Hu, X. LLM maybe LongLM: SelfExtend LLM context window without tuning. In International Conference on Machine Learning (ICML), pp. 22099–22114, 2024.
Kazemnejad, A., Padhi, I., Natesan Ramamurthy, K., Das, P., and Reddy, S. The impact of positional encoding on length generalization in transformers. In Advances in Neural Information Processing Systems (NeurIPS), 2023.
Kwon, W., Li, Z., Zhuang, S., Sheng, Y., Zheng, L., Yu, C. H., Gonzalez, J. E., Zhang, H., and Stoica, I. Efficient memory management for large language model serving with PagedAttention. In ACM Symposium on Operating Systems Principles (SOSP), pp. 611–626, 2023.
Lai, X., Lu, J., Luo, Y., Ma, Y., and Zhou, X. FlexPrefill: A context-aware sparse attention mechanism for efficient long-sequence inference. In International Conference on Learning Representations (ICLR), 2025.
Lee, H., Park, G., Lee, Y., Suh, J., Kim, J., Jeong, W., Kim, B., Lee, H., Jeon, M., and Hwang, S. J. A training-free sub-quadratic cost transformer model serving framework with hierarchically pruned attention. In International Conference on Learning Representations (ICLR), 2025a.
Lee, H., Park, G., Suh, J., and Hwang, S. J. InfiniteHiP: Extending language model context up to 3 million tokens on a single GPU. arXiv preprint arXiv:2502.08910, 2025b.
Leng, J., Hu, X., Wang, J., Li, J., Wu, W., and Lu, Y. Understanding and improving length generalization in hierarchical sparse attention models. In International Conference on Learning Representations (ICLR), 2026.
Li, J., Fang, A., Smyrnis, G., Ivgi, M., Jordan, M., Gadre, S., Bansal, H., Guha, E., Keh, S., Arora, K., Garg, S., Xin, R., Muennighoff, N., Heckel, R., Mercat, J., Chen, M., Gururangan, S., Wortsman, M., Albalak, A., Bitton, Y., Nezhurina, M., Abbas, A., Hsieh, C.-Y., Ghosh, D., Gardner, J., Kilian, M., Zhang, H., Shao, R., Pratt, S., Sanyal, S., Ilharco, G., Daras, G., Marathe, K., Gokaslan, A., Zhang, J., Chandu, K., Nguyen, T., Vasiljevic, I., Kakade, S., Song, S., Sanghavi, S., Faghri, F., Oh, S., Zettlemoyer, L., Lo, K., El-Nouby, A., Pouransari, H., Toshev, A., Wang, S., Groeneveld, D., Soldaini, L., Koh, P. W., Jitsev, J., Kollar, T., Dimakis, A. G., Carmon, Y., Dave, A., Schmidt, L., and Shankar, V. DataComp-LM: In search of the next generation of training sets for language models. In Advances in Neural Information Processing Systems (NeurIPS), pp. 14200–14282, 2024.
Lu, E., Jiang, Z., Liu, J., Du, Y., Jiang, T., Hong, C., Liu, S., He, W., Yuan, E., Wang, Y., Huang, Z., Yuan, H., Xu, S., Xu, X., Lai, G., Chen, Y., Zheng, H., Yan, J., Su, J., Wu, Y., Zhang, Y., Yang, Z., Zhou, X., Zhang, M., and Qiu, J. MoBA: Mixture of block attention for long-context LLMs. In Advances in Neural Information Processing Systems (NeurIPS), pp. 17790–17815, 2025.
Mohtashami, A. and Jaggi, M. Random-access infinite context length for transformers. In Advances in Neural Information Processing Systems (NeurIPS), pp. 54567–54585, 2023.
Paszke, A., Gross, S., Massa, F., Lerer, A., Bradbury, J., Chanan, G., Killeen, T., Lin, Z., Gimelshein, N., Antiga, L., Desmaison, A., Köpf, A., Yang, E., DeVito, Z., Raison, M., Tejani, A., Chilamkurthy, S., Steiner, B., Fang, L., Bai, J., and Chintala, S. PyTorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems (NeurIPS), pp. 8026–8037, 2019.
Peng, B., Quesnelle, J., Fan, H., and Shippole, E. YaRN: Efficient context window extension of large language models. In International Conference on Learning Representations (ICLR), 2024.
Rae, J. W., Potapenko, A., Jayakumar, S. M., Hillier, C., and Lillicrap, T. P. Compressive transformers for long-range sequence modelling. In International Conference on Learning Representations (ICLR), 2020.
Rajpurkar, P., Zhang, J., Lopyrev, K., and Liang, P. SQuAD: 100,000+ questions for machine comprehension of text.
In Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 2383–2392, 2016.
Su, J. Rectified rotary position embeddings. https://github.com/bojone/rerope, 2023.
Su, J., Ahmed, M., Lu, Y., Pan, S., Bo, W., and Liu, Y. RoFormer: Enhanced transformer with rotary position embedding. Neurocomputing, 568:127063, 2024.
Tang, B., Qin, Z., Pan, Y., Li, Z., and Liu, P. Block sparse attention with log-linear complexity. arXiv preprint arXiv:2609.31093, 2026.
Tang, J., Zhao, Y., Zhu, K., Xiao, G., Kasikci, B., and Han, S. QUEST: Query-aware sparsity for efficient long-context LLM inference. In International Conference on Machine Learning (ICML), pp. 47901–47911, 2024.
Tillet, P., Kung, H. T., and Cox, D. Triton: An intermediate language and compiler for tiled neural network computations. In ACM SIGPLAN International Workshop on Machine Learning and Programming Languages (MAPL), pp. 10–19, 2019.
Trivedi, H., Balasubramanian, N., Khot, T., and Sabharwal, A. MuSiQue: Multihop questions via single-hop question composition. Transactions of the Association for Computational Linguistics (TACL), 10:539–554, 2022.
Wang, J., Ji, T., Wu, Y., Yan, H., Gui, T., Zhang, Q., Huang, X., and Wang, X. Length generalization of causal transformers without position encoding. arXiv preprint arXiv:2404.12224, 2024.
Wolf, T., Debut, L., Sanh, V., Chaumond, J., Delangue, C., Moi, A., Cistac, P., Rault, T., Louf, R., Funtowicz, M., Davison, J., Shleifer, S., von Platen, P., Ma, C., Jernite, Y., Plu, J., Xu, C., Le Scao, T., Gugger, S., Drame, M., Lhoest, Q., and Rush, A. M. Transformers: State-of-the-art natural language processing. In Conference on Empirical Methods in Natural Language Processing: System Demonstrations (EMNLP), pp. 38–45, 2020.
Xiao, C., Zhang, P., Han, X., Xiao, G., Lin, Y., Zhang, Z., Liu, Z., and Sun, M. InfLLM: Training-free long-context extrapolation for LLMs with an efficient context memory. In Advances in Neural Information Processing Systems (NeurIPS), pp. 119638–119661, 2024a.
Xiao, G., Tian, Y., Chen, B., Han, S., and Lewis, M. Efficient streaming language models with attention sinks. In International Conference on Learning Representations (ICLR), 2024b.
Yang, A., Li, A., Yang, B., Zhang, B., Hui, B., Zheng, B., Yu, B., Gao, C., Huang, C., Lv, C., Zheng, C., Liu, D., Zhou, F., Huang, F., Hu, F., Ge, H., Wei, H., Lin, H., Tang,
J., Yang, J., Tu, J., Zhang, J., Yang, J., Yang, J., Zhou, J., Zhou, J., Lin, J., Dang, K., Bao, K., Yang, K., Yu, L., Deng, L., Li, M., Xue, M., Li, M., Zhang, P., Wang, P., Zhu, Q., Men, R., Gao, R., Liu, S., Luo, S., Li, T., Tang, T., Yin, W., Ren, X., Wang, X., Zhang, X., Ren, X., Fan, Y., Su, Y., Zhang, Y., Zhang, Y., Wan, Y., Liu, Y., Wang, Z., Cui, Z., Zhang, Z., Zhou, Z., and Qiu, Z. Qwen3 technical report. arXiv preprint arXiv:2505.09388, 2025.
Yang, Z., Qi, P., Zhang, S., Bengio, Y., Cohen, W. W., Salakhutdinov, R., and Manning, C. D. HotpotQA: A dataset for diverse, explainable multi-hop question answering. In Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 2369–2380, 2018.
Yuan, J., Gao, H., Dai, D., Luo, J., Zhao, L., Zhang, Z., Xie, Z., Wei, Y., Wang, L., Xiao, Z., Wang, Y., Ruan, C., Zhang, M., Liang, W., and Zeng, W. Native sparse attention: Hardware-aligned and natively trainable sparse attention. In Annual Meeting of the Association for Computational Linguistics (ACL), pp. 23078–23097, 2025.
Zhang, X., Chen, Y., Hu, S., Xu, Z., Chen, J., Hao, M. K., Han, X., Thai, Z. L., Wang, S., Liu, Z., and Sun, M. Bench: Extending long context evaluation beyond 100K tokens. In Annual Meeting of the Association for Computational Linguistics (ACL), pp. 15262–15277, 2024.
Zhou, J., Lu, T., Mishra, S., Brahma, S., Basu, S., Luan, Y., Zhou, D., and Hou, L. Instruction-following evaluation for large language models. arXiv preprint arXiv:2311.07911, 2023.
AI USAGE DISCLOSURE
We used AI coding assistants for four tasks. Code generation: they wrote parts of the implementation to the authors' specifications, including the training and evaluation scripts. Experiment execution: they launched and monitored the training and evaluation jobs that the authors specified and approved, and collected the results. Literature search: they helped find related work and check citation metadata against the original sources. Writing: they polished the grammar and phrasing of the authors' text. Separately, some of the training data consists of responses generated by the original Qwen3-4B (Appendix E). The research ideas, the method, the experimental design, the analysis and the conclusions are the authors' own. The authors reviewed all AI-assisted work and take full responsibility for the content of this paper.
A TREE AND POOLER
The pooler of each attention layer has the parameters , , , , and (Eq. (5)), and clamps and to a minimum of .
In Stage 1, the candidate lists in the KL (Eq. (6)) include the current node, whose key is pooled from all of its children (Eq. (1)).
A.1 Nodes with Fewer than Children
The last node of each level has children until it is full. For such a node, Eqs. (1) and (5) use only these children: the value is the mean of their values, and are computed over them and the softmax that gives runs over them.
A.2 Tree Update in Decoding
In decoding, Recursive Sparse Attention (RecSA) recomputes the key and value of the node that contains the new token at each level, from level 1 up to the top level (Section 4.2). When the position of the new token is a multiple of , RecSA adds a node with one child at level . When the top level exceeds nodes, RecSA builds a new top level from it by Eq. (1), and the existing levels do not change.
A.3 Initialization
The first part of Stage 1 initializes the pooler of every layer as follows, with separate random draws for each layer: is a unit vector in a random direction, , , the elements of are drawn independently and uniformly from , and . The initial key is then , and the small keeps every close to , so this key is close to the mean of the child keys. The first part leaves , and at these values, and the second part trains them from there.
A.4 Analysis of the MLP Term
We use the notation of Eq. (5) and write for a query vector. With , the score without the MLP term equals, up to a constant, the first-order Taylor expansion of at (Hu et al., 2026a), because is the gradient of this LogSumExp at that point. No single key can match this LogSumExp for every query, because is linear in and the LogSumExp is not. The MLP term can move the key away from , and we measure what it contributes.
Setup. We used 28 RULER (Hsieh et al., 2024) samples at 131K, four from each of S2, S3, MK1, MK2, MV, MQ and VT (Table 2). For each sample, we ran RecSA with
Table A.1. The MLP term on needle nodes, the nodes that contain evidence for the answer. 131K, 28 RULER samples, queries of the first four answer tokens; w/o MLP term: . : the sum of the weights of the level-1 needle nodes among the 16 children of a level-2 needle node (0.14 if all children had equal weight). LSE: LogSumExp of the token scores below a node; the row LSE – node score is for level-2 needle nodes; scores are centered over the nodes of each query. Recall: fraction of queries for which a level-2 needle node is among the top 1/8 of the level-2 nodes (0.635 when nodes are ranked by LSE).
| w/o MLP term | RecSA | |
|---|---|---|
| on level-1 needle nodes | 0.23 | 0.52 |
| LSE – node score | 1.21 | 0.34 |
| Recall | 0.468 | 0.625 |
the correct answer appended and kept the keys of every layer and the queries of the first four answer tokens. From these keys we recomputed levels 1 (16 tokens) and 2 (256 tokens) with and without the MLP term (, all other parameters unchanged). We compared the score of each node with the LogSumExp (LSE) of the query's scores over all tokens below it. Selection does not change when the scores of all nodes are shifted by the same amount, so we centered the scores over the nodes of each query. We call a node that contains evidence for the answer a needle node. We measure recall as the fraction of queries for which a needle node is among the top 1/8 of the nodes at its level.
Results. The MLP term does not correct the score of the node whose key it enters. Its contribution to that score, , has a correlation below 0.1 in magnitude with the gap between the LSE and the mean score of the tokens below the node at both levels, and level-1 recall is unchanged (0.747 vs. 0.752). Its effect appears at the next level. The MLP term of a level-1 key enters the level-2 weights through and acts there as a query-independent bias: the logits of the level-1 needle nodes rise by 1.45, the sum of their weights increases from 0.23 to 0.52 (Table A.1) and the level-2 key moves closer to them. Of the 0.878 by which the MLP term raises the score of a needle node at level 2, the change in () contributes 1.025 and the terms of both levels –0.147. With the MLP term at level 2 only, level-2 recall is 0.476, compared with 0.468 without the term; with the term at level 1 only, level-2 recall is 0.628. The keys of the original Qwen3-4B (Yang et al., 2025), on which the pooler is trained, give nearly the same numbers on 14 of these samples (two per task): the gap between the LSE and the node score falls from 1.23 to 0.37, and recall rises from 0.469 to 0.628.
B RULER RESULTS PER TASK
Setup. We generate the samples with our reimplementation of the RULER generators (Hsieh et al., 2024), which differs from the official code in four ways. The essay haystack consists of web documents from DCLM-Baseline (Li et al., 2024) instead of the essays of Paul Graham. The uncommon words of CWE and the words of FWE are random strings of three consonant-vowel syllables, where the official code uses English words for CWE and random strings of six letters for FWE. The distractor keys of MK2 carry a numeric suffix, so that they stay unique at long contexts. QA1 draws its questions from SQuAD v1.1 instead of SQuAD 2.0. From 524K on, QA1 needs more distractor paragraphs than the development set of SQuAD v1.1 has, so the distractor paragraphs repeat. Each input is one user turn in the chat template of Qwen3-4B in non-thinking mode, and the assistant turn starts with the answer prefix of the task; with the template, an input has 95% to 100% of L tokens. Each task keeps the official limit on generated tokens: 128 for S1 to MQ, 30 for VT, 120 for CWE, 50 for FWE and 32 for QA1 and QA2. The score is the string match of the official code: the fraction of gold answers that appear in the output or, for QA1 and QA2, whether any gold answer appears.
Results. Tables B.1 and B.2 list the score of each task, with the abbreviations of Table 2, for the methods of Table 1 at every length. They also list the original Qwen3-4B with YaRN (Peng et al., 2024) up to 524K, the original Qwen3-4B with DCA (An et al., 2024) up to 1M and the variants of Table F.1 with a trained backbone up to 1M.
C SHORT-CONTEXT BENCHMARKS, LONG-DOCUMENT TASKS AND PERPLEXITY
C.1 Short-Context Benchmarks
The three models, Qwen3-4B, Dense and RecSA, receive the same questions and prompts. The generative benchmarks use the chat template of Qwen3-4B in non-thinking mode with greedy decoding. For RecSA, the score of each sample depends only on its first 4,096 tokens. In a multiple-choice question, these include the input and the option being scored; in a generation task, they include the input and the output up to the end of the answer or the code. In this range, RecSA is equivalent to dense causal attention (Section 3.1), so we evaluate the trained weights of RecSA with dense attention, using the scaled dot-product attention (SDPA) of PyTorch (Paszke et al., 2019) in Transformers (Wolf et al., 2020). Qwen3-4B and Dense are evaluated the same way.
The benchmarks are evaluated as follows:
- MMLU (Hendrycks et al., 2021): all 14,042 questions,
5-shot with the first five questions of the dev set of each subject as examples, in the format of lm-evaluation-harness (Gao et al., 2024) and without the chat template. We compare the log-likelihoods of the option letters A–D.
-
ARC-C (Clark et al., 2018): all 1,172 questions, 0-shot. As in MMLU, the prompt gives the question and its options labeled with letters, without the chat template, and we compare the log-likelihoods of the letters.
-
GSM8K (Cobbe et al., 2021): all 1,319 questions, 0-shot, with “Please reason step by step, and put your final answer within \boxed{}.” appended to the question and at most 1,024 generated tokens. The answer is the number in the last \boxed{}}, or the last number in the response if it has none.
-
IFEval (Zhou et al., 2023): 541 prompts with at most 1,280 generated tokens, scored by the checkers of lm-evaluation-harness 0.4.13; we report prompt-level strict accuracy. The checkers draw random numbers, so we set the seed of Python’s random module to 0, of NumPy to 1234 and of langdetect to 0.
-
HumanEval (Chen et al., 2021) and MBPP (Austin et al., 2021), with 164 and 500 problems: the humaneval_instruct and mbpp_instruct formats of lm-evaluation-harness, 0-shot, pass@1, with at most 1,024 and 512 generated tokens, respectively. Each program runs separately with a time limit of 10 s.
Table C.1 lists the scores of the three models on all benchmarks, including LongBench (Appendix C.2).
C.2 Long-Document Tasks
LongBench. Of the 14 English tasks of LongBench (Bai et al., 2024), we use 12 (NarrativeQA, MultiFieldQA-en, HotpotQA, 2WikiMQA, GovReport, QMSum, Multi-News, TREC, TriviaQA, SAMSum, PassageCount and PassageRetrieval-en), together with the 2 code tasks (LCC and RepoBench-P), 3,350 samples in total. Qasper and MuSiQue are sources of the training data (Appendix E.1) and are excluded. The prompts, the maximum generation length of each task and the metrics follow the official settings. As in the official code, prompts longer than 31,500 tokens, the limit for 32K models, are truncated in the middle, and TREC, TriviaQA, SAMSum, LCC and RepoBench-P are used without the chat template. The other tasks use the chat template of Qwen3-4B in non-thinking mode. All prompts fit within the training length of Qwen3-4B, so Qwen3-4B runs without YaRN. All models use greedy decoding, and the score is the mean over the 14 tasks.
- MMLU (Hendrycks et al., 2021): all 14,042 questions,
Table B.1. RULER score per task, 32K–262K. The best Avg among the methods of Table 1 is in bold.
| 32K | S1 | S2 | S3 | MK1 | MK2 | MK3 | MV | MQ | VT | CWE | FWE | QA1 | QA2 | Avg |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| InfLLM | 100.0 | 17.9 | 32.1 | 32.1 | 67.9 | 10.7 | 29.0 | 36.6 | 57.1 | 56.1 | 81.0 | 39.3 | 25.0 | 45.0 |
| InfiniteHiP | 100.0 | 98.2 | 100.0 | 96.4 | 58.9 | 19.6 | 95.1 | 99.6 | 53.2 | 76.2 | 82.7 | 87.5 | 67.9 | 79.6 |
| Dense + YaRN | 100.0 | 98.2 | 100.0 | 100.0 | 94.6 | 100.0 | 99.6 | 100.0 | 99.3 | 93.2 | 89.9 | 87.5 | 66.1 | 94.5 |
| Dense + DCA | 100.0 | 98.2 | 100.0 | 100.0 | 96.4 | 100.0 | 99.6 | 100.0 | 99.3 | 93.4 | 89.9 | 87.5 | 66.1 | 94.6 |
| MoBA + YaRN | 100.0 | 71.4 | 96.4 | 76.8 | 76.8 | 89.3 | 67.0 | 72.3 | 94.6 | 86.6 | 90.5 | 82.1 | 57.1 | 81.6 |
| MoBA + DCA | 100.0 | 71.4 | 91.1 | 78.6 | 80.4 | 87.5 | 64.7 | 77.7 | 95.4 | 85.7 | 91.1 | 82.1 | 57.1 | 81.8 |
| DSA + YaRN | 100.0 | 100.0 | 100.0 | 100.0 | 94.6 | 100.0 | 100.0 | 100.0 | 98.9 | 94.6 | 91.7 | 91.1 | 67.9 | 95.3 |
| DSA + DCA | 100.0 | 98.2 | 100.0 | 100.0 | 94.6 | 100.0 | 100.0 | 100.0 | 99.3 | 95.2 | 91.1 | 91.1 | 67.9 | 95.2 |
| RecSA (ours) | 100.0 | 100.0 | 100.0 | 98.2 | 96.4 | 96.4 | 98.2 | 100.0 | 100.0 | 95.2 | 89.9 | 92.9 | 64.3 | 94.7 |
| Qwen3-4B + YaRN | 100.0 | 96.4 | 100.0 | 98.2 | 89.3 | 76.8 | 98.7 | 99.1 | 54.3 | 73.2 | 83.3 | 83.9 | 60.7 | 85.7 |
| Qwen3-4B + DCA | 100.0 | 98.2 | 100.0 | 100.0 | 89.3 | 78.6 | 98.7 | 99.1 | 53.6 | 72.7 | 82.7 | 83.9 | 62.5 | 86.1 |
| w/o summaries | 100.0 | 100.0 | 100.0 | 100.0 | 94.6 | 98.2 | 98.2 | 100.0 | 99.6 | 93.6 | 86.9 | 91.1 | 66.1 | 94.5 |
| w/o MLP term | 100.0 | 100.0 | 100.0 | 98.2 | 98.2 | 98.2 | 97.8 | 100.0 | 100.0 | 95.9 | 89.3 | 87.5 | 67.9 | 94.8 |
| standard RoPE + YaRN | 100.0 | 98.2 | 100.0 | 100.0 | 94.6 | 100.0 | 98.7 | 100.0 | 100.0 | 93.8 | 91.1 | 92.9 | 67.9 | 95.2 |
| standard RoPE | 100.0 | 98.2 | 100.0 | 100.0 | 94.6 | 100.0 | 98.7 | 100.0 | 100.0 | 93.8 | 91.1 | 92.9 | 67.9 | 95.2 |
| top-k 128 | 100.0 | 100.0 | 100.0 | 100.0 | 96.4 | 89.3 | 95.1 | 100.0 | 100.0 | 93.2 | 89.9 | 94.6 | 67.9 | 94.3 |
| top-k 512 | 100.0 | 100.0 | 100.0 | 98.2 | 100.0 | 100.0 | 99.1 | 100.0 | 100.0 | 97.1 | 86.9 | 96.4 | 69.6 | 96.0 |
| 131K | S1 | S2 | S3 | MK1 | MK2 | MK3 | MV | MQ | VT | CWE | FWE | QA1 | QA2 | Avg |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| InfLLM | 100.0 | 7.1 | 0.0 | 5.4 | 57.1 | 0.0 | 7.6 | 3.6 | 60.0 | 36.4 | 86.3 | 8.9 | 8.9 | 29.3 |
| InfiniteHiP | 100.0 | 91.1 | 91.1 | 73.2 | 32.1 | 0.0 | 76.3 | 86.6 | 57.1 | 55.9 | 86.3 | 55.4 | 23.2 | 63.7 |
| Dense + YaRN | 100.0 | 100.0 | 98.2 | 94.6 | 64.3 | 41.1 | 91.5 | 94.6 | 95.7 | 70.7 | 85.7 | 58.9 | 44.6 | 80.0 |
| Dense + DCA | 100.0 | 98.2 | 100.0 | 78.6 | 73.2 | 41.1 | 81.7 | 94.6 | 90.4 | 79.3 | 90.5 | 60.7 | 32.1 | 78.5 |
| MoBA + YaRN | 87.5 | 10.7 | 25.0 | 19.6 | 14.3 | 1.8 | 18.8 | 8.9 | 81.8 | 41.8 | 58.3 | 30.4 | 16.1 | 31.9 |
| MoBA + DCA | 98.2 | 14.3 | 17.9 | 19.6 | 23.2 | 8.9 | 17.9 | 12.1 | 81.8 | 48.2 | 88.7 | 37.5 | 25.0 | 37.9 |
| DSA + YaRN | 100.0 | 100.0 | 100.0 | 94.6 | 66.1 | 26.8 | 88.8 | 96.4 | 98.2 | 80.5 | 84.5 | 67.9 | 42.9 | 80.5 |
| DSA + DCA | 100.0 | 98.2 | 100.0 | 78.6 | 69.6 | 37.5 | 79.0 | 92.9 | 89.3 | 81.8 | 86.3 | 62.5 | 32.1 | 77.5 |
| RecSA (ours) | 100.0 | 100.0 | 100.0 | 100.0 | 76.8 | 37.5 | 92.0 | 99.6 | 99.6 | 84.8 | 88.7 | 57.1 | 46.4 | 83.3 |
| Qwen3-4B + YaRN | 100.0 | 92.9 | 100.0 | 85.7 | 50.0 | 5.4 | 75.4 | 87.9 | 57.1 | 34.6 | 80.4 | 46.4 | 28.6 | 65.0 |
| Qwen3-4B + DCA | 100.0 | 98.2 | 100.0 | 69.6 | 55.4 | 12.5 | 78.1 | 89.7 | 52.1 | 45.7 | 84.5 | 53.6 | 19.6 | 66.1 |
| w/o summaries | 100.0 | 100.0 | 100.0 | 100.0 | 71.4 | 35.7 | 91.5 | 99.1 | 99.6 | 80.9 | 87.5 | 57.1 | 41.1 | 81.8 |
| w/o MLP term | 100.0 | 94.6 | 96.4 | 92.9 | 69.6 | 32.1 | 85.7 | 92.9 | 99.3 | 79.5 | 87.5 | 64.3 | 44.6 | 80.0 |
| standard RoPE + YaRN | 100.0 | 80.4 | 92.9 | 71.4 | 32.1 | 0.0 | 72.3 | 79.9 | 96.1 | 78.2 | 83.9 | 48.2 | 25.0 | 66.2 |
| standard RoPE | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 13.1 | 0.0 | 0.0 | 1.0 |
| top-k 128 | 100.0 | 94.6 | 98.2 | 98.2 | 53.6 | 12.5 | 87.1 | 98.2 | 99.6 | 83.6 | 90.5 | 57.1 | 35.7 | 77.6 |
| top-k 512 | 100.0 | 100.0 | 100.0 | 100.0 | 89.3 | 67.9 | 91.1 | 99.6 | 100.0 | 88.6 | 88.1 | 71.4 | 48.2 | 88.0 |
| 262K | S1 | S2 | S3 | MK1 | MK2 | MK3 | MV | MQ | VT | CWE | FWE | QA1 | QA2 | Avg |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| InfLLM | 100.0 | 3.6 | 0.0 | 3.6 | 55.4 | 0.0 | 4.0 | 4.5 | 63.2 | 30.2 | 86.9 | 17.9 | 10.7 | 29.2 |
| InfiniteHiP | 100.0 | 80.4 | 85.7 | 62.5 | 28.6 | 0.0 | 62.9 | 71.4 | 72.9 | 32.9 | 86.9 | 44.6 | 21.4 | 57.7 |
| Dense + YaRN | 98.2 | 69.6 | 80.4 | 50.0 | 26.8 | 1.8 | 45.1 | 42.4 | 85.4 | 23.4 | 57.1 | 32.1 | 16.1 | 48.3 |
| Dense + DCA | 100.0 | 89.3 | 96.4 | 60.7 | 66.1 | 25.0 | 75.9 | 75.9 | 87.5 | 46.8 | 88.7 | 50.0 | 26.8 | 68.4 |
| MoBA + YaRN | 0.0 | 0.0 | 0.0 | 1.8 | 8.9 | 0.0 | 0.4 | 0.9 | 0.0 | 0.7 | 36.9 | 7.1 | 8.9 | 5.1 |
| MoBA + DCA | 94.6 | 1.8 | 1.8 | 1.8 | 8.9 | 0.0 | 2.7 | 3.1 | 69.6 | 16.6 | 85.1 | 12.5 | 10.7 | 23.8 |
| DSA + YaRN | 100.0 | 75.0 | 87.5 | 67.9 | 23.2 | 0.0 | 48.2 | 63.8 | 93.6 | 45.0 | 72.0 | 42.9 | 23.2 | 57.1 |
| DSA + DCA | 100.0 | 85.7 | 98.2 | 64.3 | 51.8 | 12.5 | 63.8 | 71.9 | 88.2 | 64.8 | 78.0 | 50.0 | 25.0 | 65.7 |
| RecSA (ours) | 100.0 | 98.2 | 96.4 | 96.4 | 51.8 | 12.5 | 80.4 | 98.2 | 99.6 | 79.3 | 87.5 | 51.8 | 33.9 | 75.9 |
| Qwen3-4B + YaRN | 100.0 | 60.7 | 67.9 | 51.8 | 10.7 | 0.0 | 43.3 | 45.1 | 38.9 | 3.2 | 58.3 | 28.6 | 8.9 | 39.8 |
| Qwen3-4B + DCA | 100.0 | 89.3 | 100.0 | 66.1 | 35.7 | 3.6 | 64.7 | 69.2 | 54.6 | 17.9 | 82.7 | 39.3 | 28.6 | 57.8 |
| w/o summaries | 100.0 | 100.0 | 98.2 | 94.6 | 33.9 | 3.6 | 83.5 | 97.3 | 99.3 | 70.5 | 88.7 | 50.0 | 37.5 | 73.6 |
| w/o MLP term | 100.0 | 66.1 | 83.9 | 80.4 | 42.9 | 7.1 | 54.9 | 64.3 | 99.6 | 72.3 | 85.1 | 51.8 | 28.6 | 64.4 |
| standard RoPE + YaRN | 87.5 | 8.9 | 5.4 | 10.7 | 0.0 | 0.0 | 5.8 | 1.8 | 69.6 | 25.4 | 58.3 | 8.9 | 5.4 | 22.1 |
| standard RoPE | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| top-k 128 | 100.0 | 87.5 | 92.9 | 94.6 | 30.4 | 1.8 | 71.4 | 90.2 | 99.6 | 74.6 | 89.3 | 42.9 | 30.4 | 69.7 |
| top-k 512 | 100.0 | 100.0 | 100.0 | 94.6 | 64.3 | 14.3 | 78.1 | 98.7 | 99.3 | 84.6 | 90.5 | 58.9 | 37.5 | 78.5 |
Table B.2. RULER score per task, 524K–2M (continued from Table B.1). The best Avg among the methods of Table 1 is in bold. †: the first 4 of the 20 samples of each task.
| 524K | S1 | S2 | S3 | MK1 | MK2 | MK3 | MV | MQ | VT | CWE | FWE | QA1 | QA2 | Avg |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| InfLLM | 100.0 | 10.0 | 0.0 | 10.0 | 25.0 | 0.0 | 2.5 | 3.8 | 68.0 | 10.0 | 81.7 | 30.0 | 15.0 | 27.4 |
| InfiniteHiP | 95.0 | 75.0 | 80.0 | 65.0 | 10.0 | 0.0 | 55.0 | 63.8 | 50.0 | 10.5 | 83.3 | 35.0 | 20.0 | 49.4 |
| Dense + YaRN | 10.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 31.7 | 0.0 | 5.0 | 3.6 |
| Dense + DCA | 100.0 | 85.0 | 90.0 | 55.0 | 70.0 | 0.0 | 67.5 | 55.0 | 76.0 | 12.0 | 88.3 | 35.0 | 20.0 | 58.0 |
| MoBA + YaRN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 11.7 | 0.0 | 0.0 | 0.9 |
| MoBA + DCA | 85.0 | 0.0 | 5.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 38.0 | 6.0 | 76.7 | 10.0 | 15.0 | 18.1 |
| DSA + YaRN | 100.0 | 10.0 | 0.0 | 0.0 | 0.0 | 0.0 | 7.5 | 0.0 | 68.0 | 0.0 | 53.3 | 0.0 | 5.0 | 18.8 |
| DSA + DCA | 100.0 | 80.0 | 90.0 | 55.0 | 55.0 | 0.0 | 47.5 | 42.5 | 84.0 | 42.0 | 76.7 | 30.0 | 15.0 | 55.2 |
| RecSA (ours) | 100.0 | 95.0 | 95.0 | 95.0 | 45.0 | 0.0 | 68.8 | 92.5 | 100.0 | 57.0 | 83.3 | 45.0 | 30.0 | 69.7 |
| Qwen3-4B + YaRN† | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 6.2 | 0.0 | 0.0 | 16.7 | 0.0 | 0.0 | 1.8 |
| Qwen3-4B + DCA | 100.0 | 90.0 | 100.0 | 35.0 | 15.0 | 0.0 | 47.5 | 42.5 | 61.0 | 2.0 | 81.7 | 45.0 | 20.0 | 49.2 |
| w/o summaries | 100.0 | 90.0 | 100.0 | 95.0 | 10.0 | 0.0 | 80.0 | 96.2 | 100.0 | 43.5 | 93.3 | 40.0 | 30.0 | 67.5 |
| w/o MLP term | 100.0 | 50.0 | 90.0 | 25.0 | 10.0 | 0.0 | 38.8 | 42.5 | 100.0 | 40.0 | 88.3 | 35.0 | 35.0 | 50.4 |
| standard RoPE + YaRN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 25.0 | 0.0 | 0.0 | 1.9 |
| standard RoPE | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| top-k 128 | 100.0 | 90.0 | 90.0 | 90.0 | 30.0 | 0.0 | 63.8 | 85.0 | 99.0 | 60.5 | 93.3 | 45.0 | 30.0 | 67.4 |
| top-k 512 | 100.0 | 95.0 | 100.0 | 95.0 | 55.0 | 0.0 | 67.5 | 93.8 | 100.0 | 72.5 | 91.7 | 45.0 | 35.0 | 73.1 |
| 1M | S1 | S2 | S3 | MK1 | MK2 | MK3 | MV | MQ | VT | CWE | FWE | QA1 | QA2 | Avg |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| InfLLM | 100.0 | 6.2 | 0.0 | 0.0 | 56.2 | 0.0 | 1.6 | 3.1 | 53.8 | 7.5 | 81.2 | 18.8 | 6.2 | 25.7 |
| InfiniteHiP | 87.5 | 62.5 | 43.8 | 37.5 | 6.2 | 0.0 | 42.2 | 37.5 | 52.5 | 1.9 | 85.4 | 18.8 | 0.0 | 36.6 |
| Dense + YaRN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 20.8 | 0.0 | 0.0 | 1.6 |
| Dense + DCA | 100.0 | 56.2 | 75.0 | 56.2 | 6.2 | 0.0 | 29.7 | 26.6 | 82.5 | 2.5 | 79.2 | 6.2 | 0.0 | 40.0 |
| MoBA + YaRN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 12.5 | 0.0 | 0.0 | 1.0 |
| MoBA + DCA | 75.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 15.0 | 0.0 | 60.4 | 6.2 | 6.2 | 12.5 |
| DSA + YaRN | 43.8 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.2 | 0.0 | 27.1 | 6.2 | 0.0 | 6.0 |
| DSA + DCA | 100.0 | 31.2 | 62.5 | 43.8 | 6.2 | 0.0 | 29.7 | 20.3 | 71.2 | 21.9 | 72.9 | 6.2 | 12.5 | 36.8 |
| RecSA (ours) | 100.0 | 87.5 | 100.0 | 81.2 | 25.0 | 6.2 | 54.7 | 90.6 | 95.0 | 23.1 | 85.4 | 31.2 | 6.2 | 60.5 |
| Qwen3-4B + DCA | 100.0 | 50.0 | 62.5 | 31.2 | 6.2 | 0.0 | 26.6 | 17.2 | 47.5 | 1.2 | 72.9 | 18.8 | 12.5 | 34.4 |
| w/o summaries | 100.0 | 87.5 | 100.0 | 87.5 | 6.2 | 0.0 | 59.4 | 93.8 | 100.0 | 11.9 | 89.6 | 25.0 | 0.0 | 58.5 |
| w/o MLP term | 100.0 | 0.0 | 62.5 | 25.0 | 12.5 | 0.0 | 28.1 | 21.9 | 96.2 | 20.0 | 85.4 | 31.2 | 0.0 | 37.1 |
| standard RoPE + YaRN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 25.0 | 0.0 | 0.0 | 1.9 |
| standard RoPE | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| top-k 128 | 100.0 | 68.8 | 81.2 | 56.2 | 6.2 | 0.0 | 50.0 | 76.6 | 100.0 | 27.5 | 87.5 | 18.8 | 12.5 | 52.7 |
| top-k 512 | 100.0 | 87.5 | 100.0 | 81.2 | 25.0 | 0.0 | 57.8 | 95.3 | 92.5 | 60.0 | 89.6 | 43.8 | 12.5 | 65.0 |
| 2M | S1 | S2 | S3 | MK1 | MK2 | MK3 | MV | MQ | VT | CWE | FWE | QA1 | QA2 | Avg |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| InfLLM | 100.0 | 0.0 | 0.0 | 6.2 | 25.0 | 0.0 | 0.0 | 1.6 | 40.0 | 2.5 | 83.3 | 25.0 | 31.2 | 24.2 |
| InfiniteHiP | 81.2 | 37.5 | 50.0 | 25.0 | 6.2 | 0.0 | 28.1 | 15.6 | 45.0 | 6.9 | 83.3 | 25.0 | 37.5 | 34.0 |
| Dense + YaRN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 14.6 | 0.0 | 0.0 | 1.1 |
| Dense + DCA | 100.0 | 12.5 | 25.0 | 25.0 | 0.0 | 0.0 | 15.6 | 3.1 | 65.0 | 0.0 | 81.2 | 18.8 | 12.5 | 27.6 |
| MoBA + YaRN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 8.3 | 0.0 | 0.0 | 0.6 |
| MoBA + DCA | 37.5 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 3.8 | 0.0 | 52.1 | 0.0 | 0.0 | 7.2 |
| DSA + YaRN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 18.8 | 0.0 | 0.0 | 1.4 |
| DSA + DCA | 100.0 | 0.0 | 12.5 | 12.5 | 0.0 | 0.0 | 12.5 | 0.0 | 73.8 | 9.4 | 54.2 | 12.5 | 6.2 | 22.6 |
| RecSA (ours) | 100.0 | 75.0 | 56.2 | 68.8 | 6.2 | 0.0 | 39.1 | 70.3 | 95.0 | 5.0 | 75.0 | 25.0 | 25.0 | 49.3 |
Table C.1. Scores of the original Qwen3-4B, the Dense backbone and RecSA. Dense is trained from Qwen3-4B with the settings of Stage 2 on the same sequences as RecSA (Section 5.1). Best results in each row are in bold.
| Benchmark | Qwen3-4B | Dense | RecSA |
|---|---|---|---|
| MMLU (5-shot) | 70.1 | 70.3 | 70.5 |
| ARC-C (0-shot) | 87.2 | 86.9 | 88.1 |
| GSM8K (0-shot, CoT) | 91.5 | 90.9 | 90.7 |
| IFEval (prompt, strict) | 79.1 | 79.5 | 78.6 |
| HumanEval (0-shot, pass@1) | 82.3 | 81.1 | 81.7 |
| MBPP (0-shot, pass@1) | 63.6 | 60.8 | 61.8 |
| LongBench | 49.2 | 50.9 | 51.8 |
En.MC. En.MC from InfiniteBench (Zhang et al., 2024) has 229 questions with four options on 58 novels, in which the names of the characters are replaced. We input the whole novel without truncation, so the inputs have 70K to 746K tokens, including the question, the options and the template. The prompt uses the template that InfiniteBench provides for chat models, as one user turn in non-thinking mode; we generate at most 40 tokens with greedy decoding and score the output with the official method. Each question is assigned to the smallest of 131K, 262K, 524K and 1M that is at least as long as its input, and each baseline uses its settings at that length (Appendix E.4). Table C.2 lists the scores.
C.3 Perplexity
Books. We take the books of the PG-19 (Rae et al., 2020) training set that have at least tokens under the Qwen3 tokenizer and exclude two kinds. First, we exclude reference works made of unrelated entries, such as dictionaries and encyclopedias. Second, we exclude books that overlap with the training data: their title, URL or full-text hash appears in the metadata of the training data, or a training sequence contains one of their 50-word spans or one of their 50-token spans taken every 256 tokens. This check covers all sequences of the training pool (Appendix E.1). Of several editions or volumes of one work, we keep one. Nine books remain, and Table C.3 lists them.
Computation. For context length , the window of each book is the last tokens of its first tokens. The input is the plain text of the book, without a chat template or special tokens. We run one forward pass per window and report the exponential of the mean negative log-likelihood over the predicted tokens of the nine windows, which have the same length. The sparse methods use the token budgets of Table 1, and YaRN and DCA use their settings at each length (Appendix E.4).
D EFFICIENCY
D.1 Experimental Setup
Environment. All measurements run on one H200 GPU with batch size 1 in bf16, with PyTorch 2.7.1, CUDA 12.8, Triton 3.3.1 (Tillet et al., 2019), FlashAttention 2.8.3 (Dao, 2024) and Transformers 5.9.0.
Prefill. Up to 1M, the input is the window of length of The Anatomy of Melancholy (Appendix C.3). At 2M, it is the first tokens of The History of England, Vol. II followed by the first tokens of The Anatomy of Melancholy. We measure the wall-clock time of one complete prefill after a warm-up and report the median of 3 timed runs up to 262K and the time of one run from 524K. For RecSA, the time includes building the KV cache and the tree and, at 1M and 2M, writing the exact tokens to host memory. Dense runs the forward pass of Transformers with FlashAttention-2, computes the logits of the last position only and keeps no KV cache. At 2M, the intermediate results of the Dense forward pass over the whole sequence do not fit in GPU memory, so we compute the non-attention part in chunks of 131,072 tokens, while attention still calls FlashAttention once per layer over the whole sequence. In the prefill of RecSA at 2M, the two passes of level 1, which has 125,000 nodes, process 4 adjacent queries per thread block instead of 16 (Section 4.1).
Decoding. Up to 524K, the input is a sequence of random tokens generated with a fixed seed. At these lengths, all data reside on the GPU, and the number of candidates scored at each level and the number of entries read depend only on the position. At 524K, the step time on a RULER sample differs from that on the random sequence by less than 0.1%. At 1M and 2M, the amount read from host memory at each step depends on which nodes are selected, so we measure RecSA on two RULER samples at each length, one from MK1 and one from MQ (Table 2). Dense reads its whole KV cache at every step. We measure Dense on the same random sequence up to 524K and on random keys and values at 1M and 2M.
Except for Dense at 1M and 2M, we first prefill the input. We then decode token by token, and each step includes the output logits. Up to 524K, each step takes the next token of the random sequence as input. On the RULER samples, each step takes the token that RecSA generates greedily, with the end-of-sequence token suppressed; RecSA without the GPU cache (Section 4.3) and the two-level variant (Appendix D.4) take the same tokens. The whole decoding step is captured as one CUDA graph. At the top level, each of the 16 segments of Section 4.2 is scored by 4 thread blocks per KV head, so 512 thread blocks compute the importance. After a warm-up, we synchronize at the end of
Table C.2. En.MC scores. The last four columns group the questions by input length, with the number of questions in parentheses. Best results in each column are in bold.
| Method | All (229) | 70K–131K (79) | 131K–262K (106) | 262K–524K (40) | 524K–746K (4) |
|---|---|---|---|---|---|
| Qwen3-4B + YaRN | 34.5 | 64.6 | 20.8 | 15.0 | 0.0 |
| InfiniteHiP | 66.4 | 67.1 | 68.9 | 57.5 | 75.0 |
| Dense + DCA | 62.4 | 69.6 | 64.2 | 45.0 | 50.0 |
| DSA + DCA | 62.0 | 64.6 | 65.1 | 52.5 | 25.0 |
| RecSA (ours) | 66.8 | 74.7 | 66.0 | 55.0 | 50.0 |
Table C.3. The nine PG-19 books. Tokens: length of the whole book.
| Title | Gutenberg ID | Tokens |
|---|---|---|
| Modern Machine-Shop Practice, Vols. I and II | 39225 | 1,261,044 |
| The Bible, King James Version | 30 | 1,405,554 |
| History of the United Netherlands, 1584–1609 | 4885 | 1,003,719 |
| The Anatomy of Melancholy | 10800 | 1,000,033 |
| The Complete Memoirs of Jacques Casanova de Seingalt | 2981 | 1,531,970 |
| The History of England, Vol. II (Smollett) | 19217 | 1,099,801 |
| Abridgment of the Debates of Congress, 1789–1856 | 40499 | 1,073,145 |
| Complete Poetic and Dramatic Works of Robert Browning | 50954 | 1,348,826 |
| Church History, Vols. 1–3 (Kurtz) | 51491 | 1,279,278 |
each step and take the median step time over at least 32 steps; at 1M and 2M, the latency of RecSA is the mean of the medians of the two samples. Dense uses the Flash-Decoding kernel (Dao et al., 2023) of FlashAttention-2 with a preallocated KV cache, and the number of splits is that of the default heuristic of FlashAttention or 32, whichever is faster. The non-attention part of Dense (projections, MLPs and normalization) uses the same kernels as RecSA.
Offloading at 1M and 2M. RecSA keeps the exact tokens in host memory and caches the most recent exact tokens on the GPU (Section 4.3). On the RULER samples, the cached range holds 80.1% of the input at 1M and 38.1% at 2M, and 89.2% and 77.4% of the selected level-1 nodes fall in it. Dense keeps the keys and values of the last 949,248 and 945,152 input tokens on the GPU, 95% and 47% of the input, which fills the available memory. The rest stays in pinned host memory and is copied to the GPU in chunks of 16,384 tokens at every step: 7.0 GiB at 1M and 144.9 GiB at 2M. FlashAttention computes attention over the part on the GPU and over each copied chunk, and the partial results are merged by their LogSumExp; the copies and the computation run one after another on one CUDA stream. The measured bandwidth from host to GPU is 51.6 GiB/s.
D.2 Latency
Table D.1 lists the prefill times behind Figure 5a and the decoding latencies of Figure 1b.
D.3 Decoding Latency Breakdown
To break down a step, we prefill the input again in a new process and run decoding steps under the PyTorch profiler, which records the time of every kernel in the CUDA graph. Up to 524K, the work of a step depends only on its position, so we profile 8 steps after the timed steps of Appendix D.1. At 1M and 2M, it also depends on the selected nodes, so we profile the steps at the timed positions, with the same input tokens. We assign each kernel to one of the following parts and take the mean time of each part over the profiled steps:
-
Non-attention: the projections, the MLPs, normalization, the embedding, the output layer and the idle time between kernels, which is the step time of Table D.1 minus the summed kernel time.
-
Tree update: appending the key and value of the new token to level 0 and recomputing the last node of each level (① and ② in Figure 4b). At 1M and 2M, this writes the new key and value to host memory and to the GPU cache and copies the children of the last level-1 node to the GPU.
-
Top level, Intermediate levels: scoring, top- selection and attention over the summaries at that level.
-
Gather: gathering the selected exact tokens from the GPU cache and from host memory (④ in Figure 4b).
-
Exact tokens: attention over the exact tokens in the candidate list of level 0.
-
Merge: merging the partial softmax results of the segments and the levels.
The time of a kernel that serves two adjacent levels is split between them in proportion to the time of the work of each level run alone. Table D.2 lists the results; the 1M and 2M columns are the means over the two RULER samples. In a Dense step at 1M and 2M, copying keys and values from host memory takes 136 of 177 ms and 2,823 of 2,945 ms.
Table D.1. Prefill time (s) and decoding latency (ms per token) of RecSA and Dense. At 1M and 2M, host memory holds the exact tokens of RecSA and, in decoding, the part of the Dense KV cache that does not fit on the GPU.
| Context length | Prefill (s) | Decoding (ms) | ||
|---|---|---|---|---|
| RecSA | Dense | RecSA | Dense | |
| 32K | 1.59 | 1.46 | 4.88 | 5.29 |
| 64K | 3.87 | 4.66 | 5.99 | 6.41 |
| 131K | 13.5 | 16.8 | 6.04 | 8.56 |
| 262K | 34.2 | 65.0 | 6.06 | 13.3 |
| 524K | 79.8 | 257 | 6.15 | 23.4 |
| 1M | 199 | 908 | 8.35 | 177 |
| 2M | 603 | 3,672 | 10.7 | 2,945 |
Table D.2. Time breakdown (ms) of one decoding step of RecSA (Figure 5b). The time of a kernel that serves two adjacent levels is split between them in proportion to the time of the work of each level run alone. -: the part does not occur at this length.
| Context length | 32K | 131K | 262K | 524K | 1M | 2M |
|---|---|---|---|---|---|---|
| Tree levels | 2 | 3 | 3 | 3 | 3 | 4 |
| Non-attention | 3.26 | 3.35 | 3.35 | 3.35 | 3.41 | 3.40 |
| Tree update | 0.25 | 0.39 | 0.39 | 0.39 | 0.63 | 0.87 |
| Top level | 0.89 | 0.73 | 0.80 | 0.91 | 1.24 | 0.70 |
| Intermediate levels | – | 1.03 | 0.98 | 0.96 | 0.98 | 2.01 |
| Gather | – | – | – | – | 1.55 | 3.07 |
| Exact tokens | 0.35 | 0.32 | 0.32 | 0.33 | 0.32 | 0.32 |
| Merge | 0.15 | 0.21 | 0.21 | 0.21 | 0.21 | 0.28 |
| Total | 4.88 | 6.04 | 6.06 | 6.15 | 8.35 | 10.66 |
D.4 Tree Depth
Up to 65,536 tokens, RecSA uses at most two levels. For longer contexts, Table D.3 compares RecSA with a two-level variant, which scores every level-1 node at each step. The variant is slower than RecSA at every length, from 1.1× at 131K to 1.9× at 2M, because the number of level-1 nodes it scores grows linearly with the context length.
E TRAINING AND BASELINES
E.1 Training Data
Table E.1 lists the training data: task data, whose responses depend on information in the context, and general data, which we add to preserve the general capabilities of the original model.
Task data. The synthetic retrieval tasks insert records such as “[R248624] E407003 code V153512.” at line breaks into PG-19 books (Rae et al., 2020) or GitHub source code and ask for values in the records, for example the value of one key among near-duplicate keys, the values of up to 12 keys in a given order, the code reached through a chain of links
Table D.3. Decoding latency (ms per token) of RecSA and of a two-level variant, which scores every level-1 node at each step, measured as in Appendix D.1. Up to 65,536 tokens, RecSA uses at most two levels. At 1M and 2M, both store the exact tokens in host memory.
| Context length | 131K | 262K | 524K | 1M | 2M |
|---|---|---|---|---|---|
| RecSA tree levels | 3 | 3 | 3 | 3 | 4 |
| Level-1 nodes | 8,192 | 16,384 | 32,768 | 62,500 | 125,000 |
| RecSA | 6.04 | 6.06 | 6.15 | 8.35 | 10.7 |
| Two-level variant | 6.37 | 7.11 | 7.83 | 11.5 | 20.5 |
| Speedup of RecSA | 1.1× | 1.2× | 1.3× | 1.4× | 1.9× |
Table E.1. Training data. Pool: sequences available for training. Stage 1 and Stage 2: sequences read by each run. Length: tokens per sequence in the pool, chat template included.
| Data | Pool | Stage 1 | Stage 2 | Length |
|---|---|---|---|---|
| Task data | ||||
| Synthetic retrieval | 5,500 | 4,769 | 4,760 | 32,060–32,456 |
| Document QA | 958 | 831 | 840 | 32,749–32,787 |
| General data | ||||
| Books and code | 420 | 295 | 295 | 32,741–32,768 |
| Instructions | 588 | 398 | 398 | 32,768 |
| Long-form | 150 | 107 | 107 | 9,325–24,623 |
| Sequences | 7,616 | 6,400 | 6,400 | |
| Tokens | 245.2M | 206.4M | 206.4M | |
or a sum of amounts. The document QA sequences hold 849 questions from MuSiQue (Trivedi et al., 2022) and 109 from Qasper (Dasigi et al., 2021); we add distractor passages from the training split of the same dataset to the context of each question. Each prompt specifies the response format, such as the answer alone or the answer with the identifiers of its supporting records or passages.
General data. The book and code sequences are contiguous spans of one PG-19 book or one GitHub repository. The instruction and long-form sequences pair a document window with one instruction, and their responses were generated by the original Qwen3-4B in non-thinking mode with greedy decoding. The instruction sequences use six instruction types, such as summarizing a passage or answering a question that the same model generated from the passage, with two templates per type for PG-19 books and two for GitHub code; their responses have at most 512 tokens. After generation, we prepend earlier text of the same document so that each instruction sequence has 32,768 tokens. The long-form instructions, from 14 templates, ask for about 400 to 600 words on a window of 8,600 to 24,000 tokens; only responses of 400 to 800 tokens are kept.
Loss masking. Task, instruction and long-form sequences use the chat template of Qwen3-4B in non-thinking mode, with an empty thinking block before the response; the language modeling loss covers only their response tokens, including the final end-of-turn token. Book and code sequences have no template, and the loss covers every next-token target.
Order and amount. The sequences of each kind of data are shuffled with a fixed seed, and the synthetic retrieval and document QA sequences are then shuffled into one order. Optimizer steps 1, 9, 17, ... read only general sequences, and all other steps read task sequences. Each run reads 800 general and 5,600 task sequences and no sequence twice. The two parts of Stage 1 read the same sequences; Stage 2 reads the same general sequences and shares 5,200 task sequences with Stage 1. The three runs (the two parts of Stage 1 and Stage 2) process 0.62B tokens in total and read 6,800 distinct sequences with 219.4M tokens.
E.2 Training Hyperparameters
Table E.2 lists the hyperparameters of each run. All runs use AdamW with , , and no weight decay, clip the gradient to a global norm of 1.0 and run on 8 NVIDIA H200 GPUs with one sequence per GPU in each forward and backward pass. The learning rate rises linearly during warm-up, stays at its peak and decays linearly over the last 15% of the steps, to 1/60 (Stage 1) or 1/120 (Stage 2) of the peak at the last step. In Stage 2, the loss of a sequence is the mean cross-entropy over the tokens that the loss covers, and all sequences have equal weight, so general data, read at one step in eight, carries one eighth of the total weight. Stage 2 keeps fp32 weights and computes in bf16; Stage 1 computes the pooler and its losses in fp32.
E.3 Stage 1 Query Sampling and Loss Computation
Tree. Every sampled query uses the tree of its whole sequence, even when its prefix alone would need fewer levels (Section 3.1). With , a training sequence of length has three levels if and two otherwise; 51 of the 107 long-form sequences of Stage 1 have two. On a three-level sequence, a query at position has at most 64 top-level candidates, which are all selected and expanded; its top-level KL is still computed.
Query positions. For a sequence of length , we draw 256 positions uniformly, with replacement, with ; the query set is the union of the drawn positions and the task-specific positions . In a task sequence, contains the position that predicts the first response token that depends on the evidence, for example the first token of a value or of a cited record or passage identifier. In synthetic retrieval tasks, also contains the position of the first token of the question. General data has no task-specific positions. We write .
Table E.2. Hyperparameters of RecSA training. Each run trains only the listed parameters; all other parameters are frozen. : the KL terms of each part, with the query positions and weights of Appendix E.3. : auxiliary cross-entropy. : shift penalty (Eq. (7)), with weight . LM: language modeling loss. Learning rate: peak value. Batch size: sequences per optimizer step. Accumulation: gradient accumulation steps. Time: wall-clock time of the training loop, including checkpointing.
| Stage 1 | Stage 2 | ||
|---|---|---|---|
| First part | Second part | ||
| Parameters | w, , g | , b, | backbone |
| Count | 4,680 | 887,040 | 4.02B |
| Loss | LM | ||
| k | 64 | 64 | 256 |
| Learning rate | |||
| Warm-up steps | 20 | 20 | 40 |
| Steps | 400 | 400 | 800 |
| Batch size | 16 | 16 | 8 |
| Accumulation | 2 | 2 | 1 |
| Time | 37 min | 39 min | 7.7 h |
Losses. For one sequence and one layer, let be the mean of (Eq. (6)) over the 8 KV heads and the positions , with for the top level; at level 1, the mean leaves out the pairs of a KV head and a position whose level-1 candidates hold less than of the dense attention mass. Let be 32 positions drawn uniformly without replacement from , drawn anew for each layer. The two parts of Stage 1 minimize
where the level-1 terms apply only to three-level sequences and a term over an empty set is zero. In the second part, the mean KL over the task-specific positions has ten times the weight of the mean over the other sampled positions.
The auxiliary cross-entropy is the mean of over the 8 KV heads, where is the top-level node that contains the start of the evidence. It applies to the 982 of the 6,400 sequences that have a single piece of evidence starting before . The shift penalty evaluates Eq. (7) for each KV head, with counting every node of level , including the partial last node, and averages it over the 8 KV heads; the denominator is clamped to at least . The penalty covers levels 1 and 2, or level 1 on two-level sequences, and applies to every sequence.
We sum the losses of the 36 layers and average them over the 16 sequences of each optimizer step; the loss of each layer updates only the pooler of that layer. Gradient clipping applies jointly to the poolers of all layers.
E.4 Baselines
Training setup. Dense, MoBA (Lu et al., 2025) and DSA (DeepSeek-AI et al., 2025) start from the original Qwen3-4B and train all backbone parameters with the Stage 2 settings of Table E.2, on the same sequences in the same order. Training uses RoPE without scaling, and Dense uses FlashAttention-2 (Dao, 2024). In training, MoBA and DSA attend to at most 5,888 entries per query, the token budget of RecSA at 32K.
MoBA. We use the official implementation in all 36 layers, with blocks of 128 tokens. Each query head scores the complete blocks before its position by the dot product of the query with the mean key of the block, and attends to its current block and the highest-scoring blocks. MoBA adds no parameters; in training.
DSA. Each layer has a lightning indexer with 16 heads of dimension 128, two per GQA group, and one indexer key per token, normalized by LayerNorm over all 128 dimensions, with RoPE on its first 64 dimensions. The indexer has 202M parameters in total, runs in fp32 and takes the normalized input of the attention layer, detached from the backbone. For each query and GQA group, DSA attends to the tokens with the highest index scores (Eq. (1) of DSA, summed over the two heads of the group), without sink tokens or a local window. As in DSA, we first warm up the indexer on the frozen original model with dense attention, using the KL divergence of Eq. (3) of DSA to the attention distribution averaged over the 4 heads of the group. The warm-up runs for 950 steps of 16 sequences (0.49B tokens), about 2.4 passes over the Stage 2 sequences, with AdamW, no weight decay and a learning rate that rises over 20 steps to and then stays constant. Each sequence contributes 4,096 query positions. If at most 2,048 positions are covered by the language modeling loss or predict a covered token, the query positions include all of them, and the rest are drawn uniformly without replacement; otherwise all 4,096 are drawn uniformly without replacement. During backbone training, the indexer continues to train with the KL divergence restricted to the selected tokens (Eq. (4) of DSA), at a learning rate of under the Stage 2 schedule; this loss does not reach the backbone.
Training-free methods. InfLLM (Xiao et al., 2024a) and InfiniteHiP (Lee et al., 2025b) run on the original Qwen3-4B with their official implementations and their own position encoding, without YaRN. InfLLM uses blocks of 128 tokens with 4 representative tokens each.
Token budgets. Table E.3 lists the settings at each length. MoBA selects whole blocks, so its is the budget divided by 128 and rounded down; at 1M and 2M, it attends to at
Table E.3. Settings of the baselines at each context length. Token budget: entries the query at the last position attends to under RecSA (Table 1); DSA uses it as . MoBA: selected blocks of 128 tokens, the current block included. InfLLM: initial tokens, local window and retrieved blocks of 128 tokens. InfiniteHiP: sink tokens, sliding window and selected tokens. YaRN: scaling factor ; -: not applied.
| 32K | 131K | 262K | 524K | 1M | 2M | |
|---|---|---|---|---|---|---|
| Token budget | 5,888 | 8,192 | 8,704 | 9,728 | 11,575 | 11,990 |
| MoBA blocks | 46 | 64 | 68 | 76 | 90 | 93 |
| InfLLM | ||||||
| Initial | 128 | 128 | 128 | 256 | 256 | 256 |
| Local Blocks | 3,840 | 5,376 | 5,760 | 6,272 | 7,479 | 7,766 |
| 15 | 21 | 22 | 25 | 30 | 31 | |
| InfiniteHiP | ||||||
| Sink | 448 | 640 | 640 | 768 | 896 | 896 |
| Window | 1,792 | 2,496 | 2,688 | 2,944 | 3,575 | 3,734 |
| Selected | 3,648 | 5,056 | 5,376 | 6,016 | 7,104 | 7,360 |
| YaRN | - | 4 | 8 | 16 | 32 | 64 |
most 11,520 and 11,904 entries. The configuration files in the official code of InfLLM set 128 initial tokens, a 4,096-token local window and 16 retrieved blocks; the 3K setting of the InfiniteHiP paper has 256 sink tokens, a 1,024-token window and 2,048 selected tokens. We scale these parts in proportion to the token budget and set the local or sliding window so that the parts sum to it.
Context extension. YaRN (Peng et al., 2024) scales the RoPE frequencies by the smallest power of two with for context length , with , and the attention logits multiplied by ; at 32K, it is not applied. DSA + YaRN also scales the RoPE frequencies of the indexer. DCA (An et al., 2024) uses chunks of 31,744 tokens and a local window of 1,024 tokens at every length, so that no relative distance exceeds 32,768 and keys within 1,024 tokens of the query keep their original distances. DCA keeps without frequency scaling and, as in its vLLM implementation (Kwon et al., 2023), multiplies the attention logits by , with for an input of tokens. MoBA + DCA and DSA + DCA compute their selection scores at the position indices of DCA. Qwen3-4B + YaRN and Qwen3-4B + DCA are the original Qwen3-4B, without training, with the same settings; Appendix B lists their RULER scores.
F ABLATIONS
Table F.1 gives the RULER score of each variant from 32K to 1M. The variant w/o summaries is RecSA trained and evaluated without summaries, and the variant w/o MLP term is RecSA trained and evaluated with in the
Table F1. RULER score in the ablation experiments (average over the 13 tasks). Avg: average over the four lengths from 131K to 1M. -: not evaluated.
| Variant | 32K | 131K | 262K | 524K | 1M | Avg |
|---|---|---|---|---|---|---|
| RecSA | 94.7 | 83.3 | 75.9 | 69.7 | 60.5 | 72.3 |
| w/o summaries | 94.5 | 81.8 | 73.6 | 67.5 | 58.5 | 70.4 |
| w/o MLP term | 94.8 | 80.0 | 64.4 | 50.4 | 37.1 | 58.0 |
| standard RoPE + YaRN | 95.2 | 66.2 | 22.1 | 1.9 | 1.9 | 23.0 |
| standard RoPE | 95.2 | 1.0 | 0.0 | 0.0 | 0.0 | 0.3 |
| top-k 128 | 94.3 | 77.6 | 69.7 | 67.4 | 52.7 | 66.9 |
| token budget | 3,968 | 4,352 | 4,864 | 5,888 | 5,980 | |
| top-k 512 | 96.0 | 88.0 | 78.5 | 73.1 | 65.0 | 76.2 |
| token budget | 9,728 | 15,872 | 16,384 | 17,408 | 19,255 | |
| Backbone frozen | ||||||
| KL + shift penalty | 76.5 | 67.7 | - | 55.5 | - | - |
| KL | 74.7 | 63.6 | - | 45.3 | - | - |
| w/o MLP term | 78.9 | 65.9 | - | 43.2 | - | - |
| mean pooling | 73.8 | 52.2 | - | 16.7 | - | - |
| LM loss | 73.6 | 40.6 | - | 8.9 | - | - |
pooler (Eq. (5)). The variants standard RoPE and standard RoPE + YaRN are the same model, trained like RecSA with both stages of Section 3.4, the pooler included, but with RoPE applied at absolute token positions, and evaluated without and with YaRN beyond 32K. Each key is rotated at its absolute position before pooling, so the pooler pools rotated keys and the summaries receive no further rotation. The variants top-k 128 and top-k 512 are the RecSA model evaluated with and instead of 256; the token budget row below each gives the entries the query at the last position attends to (for , see Table 1). Under Backbone frozen, the backbone is the original model, only the pooler is trained and the variants are evaluated at 32K, 131K and 524K. KL + shift penalty is the pooler of RecSA after Stage 1 (Section 3.4). KL sets in the second part of Stage 1. The variant w/o MLP term in this block is the pooler after the first part of Stage 1, with . LM loss trains the MLP term in the second part of Stage 1 with the language modeling loss instead of . Mean pooling has no trainable parameters.
Averaged over the 148 samples per task from 131K to 1M, the variant w/o summaries scores 15.5 points lower than RecSA on MK2 and 7.8 points lower on CWE, and its average over the other 11 tasks differs from that of RecSA by 0.1 points; Appendix B gives its score on each task at each length. Its perplexity on the nine PG-19 books (Table 3) is 11.24, 10.88, 11.00, 11.02 and 11.07 from 32K to 1M, compared with 11.24, 10.87, 11.00, 11.08 and 11.12 for RecSA.