Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost

RecSA cuts attention selection cost to logarithmic while staying accurate at million tokens

  • Problem Sparse attention methods still score every preceding block or token for each query, so selection cost grows linearly with context length. Hierarchical selection is cheaper, but prior trainable versions were only accurate within their training length.
  • Method RecSA picks a bounded number of candidates per tree level, so selection cost is logarithmic.
  • Results RecSA scores 60.5 on RULER at 1M tokens, compared with 40.0 for the best baseline, Dense + DCA. It is faster than dense attention in prefill and decoding from 64K to 2M.

Figure 2: One attention layer of RecSA (220 tokens, C= 16 , k= 256 , three levels). (a) The pooler computes the key Ki of a node from
the keys of its 16 childr…

Figure 2 . One attention layer of RecSA (220 tokens, C= 16 , k= 256 , three levels). (a) The pooler computes the key Ki of a node from the keys of its 16 children; its value Vi is the mean of their values. (b) s is the score of each candidate for the query qt (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 outputo t.

Original paper · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · Original paper figure · Extracted the figure area from page 4 of the original PDF.

Why selection cost grows with context and what hierarchical methods leave open

Dense attention stays expensive at long lengths for two separate reasons. In prefill, its cost grows quadratically with the length of the input. In decoding, every generated token has to read the entire KV cache. That makes the selection cost per query O(L) at context length L.

Hierarchical selection scores a top level of bounded size, then only the children of the nodes it keeps. This structure cuts the selection cost to O(log L). Hierarchical selection alone doesn't remove the need for context extension. Trainable methods such as MoBA, NSA and DSA train at the target length, which requires long documents.

The question for RecSA is whether one design can get both logarithmic cost and distances that stay in range. RecSA lets each level above the tokens select at most k candidates, so the selection cost stays O(log L). At 1M, the token budget of RecSA is 1.16% of the context.

A tree of summaries over the KV cache

RecSA's central idea is to summarize the KV cache in a tree, so a query can locate the relevant part without reading every entry. Each group of 16 consecutive entries forms a parent node, and the same grouping repeats upward until a single top level remains. Each node stores one key and one value, where the value is the mean of its children's values and the key comes from a learned pooler.

Because the summary of a node covers its whole subtree, a single node can stand in for many tokens during selection.

Selection runs from the top level down, and at each level the query scores its candidates with the importance in Eq. (2). The query heads of one KV group share that selection, which keeps the current node and the k - 1 other candidates with the highest importance, with k = 256 by default. The children of the kept nodes form the candidate list for the level below, up to the query, and that list holds at most Ck entries, which is 4,096 with the defaults.

A new level is added whenever the top level grows beyond Ck nodes, so with four levels at 2M the depth stays small.

Unselected candidates are not thrown away. The entries a query attends to number at most Ck plus (D - 1)(Ck - k), which is 3,840 summary entries per level above level 0 with the default k. So the number of entries read per query also grows only logarithmically with length.

Positions reset per level

Standard RoPE gives each key its absolute position in the sequence, so a query can end up far from keys seen in training. Each level has at most Ck = 4,096 candidates, so the relative distance between the query and any candidate lies between 0 and 4,095. That bound holds at any context length, because adding a level adds no new distances beyond the per-level list size.

Training covers this range because 32K sequences with k = 256 fill the level-0 candidate list to 4,096 tokens. ReRoPE, by contrast, places every token beyond a window at one fixed distance from the query. Under candidate-local RoPE, the candidates of one level all sit at different distances from the query, which keeps more of the positional information.

The pooler pools these keys without position input, so a node's key does not depend on which queries select it.

Distilling the pooler, then training the backbone

The pooler is taught from dense attention, so its keys reflect the mass each subtree receives. For each level above the tokens, RecSA takes the attention mass the frozen original model puts on each candidate's subtree, averaged over the G heads of the group. Because candidates cover only part of the prefix, the teacher masses are normalized over the candidate list.

The pooler's MLP term can shift all keys of a level by one shared vector, which lowers the KL through positional bias. Stage 1 freezes the backbone and uses k = 64, since the pooler doesn't involve k and this gives deeper trees from 32K sequences. With Ck = 1,024, the 32K training sequences have three levels, and the pooler learns to build level 2 keys from pooled level 1 keys.

Stage 1 trains w, τ and g with the MLP term off, then trains W1, b1 and W2 with LKL + λLshift.

Stage 2 freezes the pooler and trains the whole backbone under RecSA with the default k = 256. Only the language modeling loss drives this stage, and gradients reach the backbone through the summary keys and values. No gradient flows through the selection, so the choice of candidates stays fixed during backpropagation. Training on Qwen3-4B, whose training length is 32K, yields RecSA, which reaches 60.5 on RULER at 1M against 40.0 for Dense + DCA.

Keeping prefill and decoding fast

Block-sparse kernels usually load each KV block once for a group of adjacent queries, but RecSA gives one key different positions for different queries.

For each parent in the union of selected nodes, the block loads its 16 children into shared memory once. Each level above 0 takes two passes: one computes importance, and the second accumulates the unselected candidates into an online softmax as summaries.

With batch size 1, scoring a level with one thread block per KV head would use at most 8 of the 132 SMs of an H200. RecSA splits each level's candidate list into 16 segments, so at least 128 thread blocks compute the importance.

A gather kernel copies the exact tokens of the selected level-1 children from host memory over PCIe in 16-token blocks. Each step gathers at most 4,096 exact tokens per KV head and layer, which comes to 576 MiB across the 36 layers, whatever the context length.

RULER at lengths up to 2M

Table 1 shows RecSA with the highest RULER average at every length from 131K to 2M, with token budgets matched across the sparse methods. At 1M, RecSA scores 60.5 with a budget of 1.16% of the context, compared to 40.0 for Dense + DCA, the strongest other baseline at that length. The lead widens with length: RecSA beats the best baseline by 2.8 points at 131K, by 11.7 at 524K and by 20.5 at 1M.

All of these numbers come from a model trained only at 32K, with the same data and steps as the baselines.

Keeping relative distances in range doesn't explain the gap by itself, because DSA + DCA also keeps them in range. Yet DSA + DCA scores 36.8 at 1M, against 60.5 for RecSA, so the lead comes from more than range alone. On individual tasks at 1M, RecSA scores 90.6 on MQ and 95.0 on VT, where the strongest baselines reach 37.5 and 82.5. Perplexity on PG-19 stays between 10.87 and 11.12 for RecSA from 131K to 1M, while the YaRN variants range from 54.42 to 414.69 at 1M.

Speed at long lengths and the costs at short ones

Prefill and decoding latency decide where RecSA is worth running, and the paper reports both on one H200 GPU with batch size 1. Dense FlashAttention serves as the baseline, run in the same framework as RecSA. At 32K, prefill is the one place where RecSA loses, at 1.59 s compared with 1.46 s for Dense.

Decoding is faster than Dense at every measured length, including 32K. At 1M and 2M, RecSA takes 8.35 and 10.7 ms per token, against 177 ms and 2.9 s for Dense. The decoding step of RecSA stays nearly flat from 131K to 524K because each level scores at most Ck = 4,096 candidates. A two-level variant that scores every level-1 node at each step is 1.1× slower than RecSA at 131K and 1.9× slower at 2M.

What each part contributes

The summary ablation removes the summaries from the softmax, so only exact tokens count. Averaged over 131K to 1M, that variant scores 70.4, compared with 72.3 for RecSA. That gap supports keeping the summaries in the softmax, since the authors report that summaries improve the average at long contexts.

The RoPE ablation trains standard RoPE at absolute token positions with both stages of training. With YaRN, it scores 66.2 at 131K, while RecSA scores 83.3 at the same length. At 32K the gap is small, with 95.2 for standard RoPE and 94.7 for RecSA. The authors read the gap at longer lengths as evidence that candidate-local positions drive the improvement.

The pooler ablation freezes the backbone and evaluates five pooler variants. These variants score 73.6 to 78.9 at 32K, but 8.9 to 55.5 at 524K. The KL plus shift penalty pooler, which is the pooler of RecSA, scores highest at 524K. Dropping the shift penalty lowers the 524K score from 55.5 to 45.3. With the backbone trained, removing the MLP term costs 3.3 points at 131K and 23.4 at 1M.

Because k sets the token budget, the authors vary k at inference rather than retrain the model. They evaluate the trained RecSA model with k = 128, k = 256 and k = 512. k = 512 scores higher than k = 256 at every length from 32K to 1M, at 1.7×–1.9× the token budget. k = 128 scores lower at 131K, 262K and 1M.

Limits of the evidence

At 32K, RecSA is slower to prefill than Dense, taking 1.59 s against 1.46 s. Its decoding still beats Dense at 32K, which is the shortest length the authors measured for decoding. The tree gains a fourth level only at 2M, where the prefix has four levels.

The evaluation covers RULER, PG-19 perplexity, LongBench, En.MC and six short-context benchmarks. RULER uses 56 samples per task up to 262K, 20 at 524K and 16 at 1M and above. The perplexity table stops at 1M, so no perplexity result is reported at 2M.

The authors trained one backbone, Qwen3-4B, with a 32K training length on 0.62B tokens. They didn't test other backbones, so these results cover Qwen3-4B alone. They didn't run the efficiency measurements beyond one H200 GPU with batch size 1.

The En.MC inputs run from 70K to 746K tokens, so the long-document test covers only that span. They didn't test context lengths past 2M, so behavior beyond that length stays unknown.

Paper info

Authors
Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang
Venue
arXiv · Preprint
First published
2026-11-4
Added
2026-11-6
Updated
2026-11-4
Version
v1
arXiv
2611.07232
Category
cs.CL · cs.LG
Original paper terms
CC BY 4.0
What we show
Paper info, commentary and permitted figures from the original paper

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

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 $O(L)$ at context length $L$; hierarchical selection reduces it to $O(\log L)$, 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 $k$ candidates, so each query has $O(\log L)$ selection cost and reads $O(\log L)$ 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 3.2x and decoding by 3.8x.

Figures from the paper

Quote from the paper

Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang (2026). Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost. arXiv:2611.07232v1. https://arxiv.org/abs/2611.07232v1

BibTeX
@misc{wang2026recursive,
  title = {{Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost}},
  author = {Ruitian Wang and Xinyu Yang and Minshen Zhang and Hao Zhang},
  year = {2026},
  eprint = {2611.07232},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.07232v1}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up