논문 해설
Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost
재귀적 희소 어텐션: 로그 비용으로 백만 토큰 길이 외삽
- 연구 문제 약 1M 토큰 맥락에서 밀집 어텐션은 prefill과 decoding 모두 비용이 크며, 기존 희소 어텐션은 질의당 선택 비용이 O(L)이거나 학습 길이 밖의 외삽을 충분히 검증하지 않았습니다.
- 연구 방법 RecSA는 KV 캐시 위에 트리를 구성하고 레벨마다 상위 k개 후보를 선택하며, 선택되지 않은 요약과 정확한 토큰이 하나의 softmax를 공유하도록 합니다. 후보 로컬 RoPE로 상대 거리를 학습 범위 안에 두고, 풀러를 밀집 어텐션 질량에 증류합니다.
- 주요 결과 Qwen3-4B를 32K에서 학습한 RecSA는 RULER에서 131K부터 2M까지 기준 방법보다 높은 점수를 기록했고(1M에서 60.5 대 최고 기준 40.0), 524K에서 prefill 3.2배와 decoding 3.8배 가속을 보고했습니다.
장문 맥락에서 희소 어텐션의 선택 비용과 외삽 문제
약 1M 토큰 길이의 맥락에서는 밀집 어텐션의 prefill과 decoding 비용이 크게 늘어나며, 학습에 쓸 수 있는 긴 문서도 길이가 커질수록 희소해집니다. 기존 대부분의 희소 어텐션 방법은 각 질의마다 모든 앞선 블록이나 토큰을 점수화하므로 선택 비용이 맥락 길이 L에 대해 O(L)입니다. 계층적 선택은 이 비용을 O(log L)로 줄이지만, 원문에 따르면 기존의 학습 가능한 계층적 방법은 정확도를 학습 길이 안에서만 보고했습니다. 또한 HiP와 PISA는 각 키의 원래 위치를 유지하므로 학습 길이를 넘으면 선택된 키까지의 거리가 학습 중 보지 못한 범위에 들어갈 수 있습니다. 이 논문은 이 두 문제를 함께 다루며, 계층 선택만으로는 맥락 확장의 필요가 사라지지 않는다는 점을 출발점으로 삼습니다.
RecSA의 트리 구조와 계층 선택
RecSA는 KV 캐시 위에 트리를 구성합니다. 각 레이어는 KV 헤드마다 하나의 트리를 가지며, 레벨 0에는 토큰별 키(RoPE 적용 전)와 값이 있습니다. 연속된 C=16개의 항목이 상위 레벨의 한 노드가 되고, 노드의 키는 풀러가 자식 키로부터 계산하며 값은 자식 값의 평균입니다. 선택은 최상위 레벨에서 시작해 아래로 내려갑니다. 각 레벨의 후보 리스트에서 질의와의 중요도 점수를 계산하고, 현재 노드를 포함해 상위 k−1개의 후보를 고른 뒤 선택된 노드의 자식을 다음 레벨의 후보 리스트로 삼습니다. 기본값 k=256이면 각 레벨은 최대 Ck=4,096개의 후보를 점수화합니다. 선택되지 않은 후보의 요약과 레벨 0의 정확한 토큰들은 하나의 softmax를 공유하며, 이때 요약의 logit은 점수 그대로 사용되고 하위 트리 크기나 레벨에 따른 보정은 없습니다.
따라서 질의당 선택 비용과 읽는 항목 수가 모두 O(log L)입니다.

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.
원문 · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · 원문 그림 인용 · 원본 PDF 4쪽에서 그림 영역을 추출했습니다.후보 로컬 RoPE와 학습 길이 내 상대 거리
RecSA는 RoPE를 모든 항목, 요약을 포함해 적용하되, 항목의 위치를 원래 토큰 위치가 아니라 해당 레벨 후보 리스트에서의 인덱스로 정합니다. 질의는 마지막 인덱스, 즉 현재 노드의 인덱스를 가집니다. 이렇게 하면 레벨마다 후보가 최대 Ck=4,096개이므로 질의와 후보 사이의 상대 거리가 0에서 4,095 사이에 머뭅니다. 원문은 이를 근거로 어떤 길이에서도 상대 거리가 학습 중 본 범위 안에 있다고 설명합니다. 다만 이는 k=256과 32K 학습 설정에서의 설명이며, 같은 원문은 k=512로 늘리면 후보 리스트 안의 상대 거리가 최대 8,191에 이른다고 함께 밝힙니다. 따라서 거리 범위 보장은 사용한 k에 묶인 조건으로 읽어야 합니다.

Figure 3 . Relative distance to the query qt, 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 C= 4 children per node andk= 2 selected nodes per level: each selected node is drawn above its children, and at every level the distances stay below Ck= 8 . Dashed spans mark parts of the sequence skipped between candidates; they receive no positions.
원문 · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · 원문 그림 인용 · 원본 PDF 4쪽에서 그림 영역을 추출했습니다.풀러 증류와 두 단계 학습
풀러는 레이어마다 하나이며 모든 레벨에서 공유됩니다. 풀러는 자식 키 x_c로부터 가중 평균 p와 MLP 항 σm을 결합해 키 K를 계산합니다. 학습은 두 단계입니다. 1단계에서는 백본을 고정하고 풀러 파라미터만 학습합니다. 이때 교사 분포는 고정된 원래 모델에서 RoPE를 원래 위치에 적용해 각 후보 하위 트리가 받는 밀집 어텐션 질량을 후보 리스트 안에서 정규화한 값이고, 학생 분포는 식 (2)의 중요도를 같은 리스트에서 정규화한 값입니다. 두 분포의 KL 발산을 최소화하며, 확률적 위치 편향을 막기 위해 레벨별 평균 MLP 이동량에 shift 패널티를 줍니다. 2단계에서는 풀러를 고정하고 RecSA 아래에서 백본을 언어 모델링 손실로 학습합니다.
이 과정에서 선택 자체로는 기울기가 흐르지 않습니다. 따라서 풀러 학습은 백본을 바꾸지 않고, 백본 학습은 학습된 풀러를 그대로 사용하는 구조입니다.
RULER와 perplexity의 길이별 비교
Qwen3-4B를 32K 길이에서 학습한 RecSA는 같은 토큰 예산으로 맞춘 기준 방법들과 비교되었습니다. RULER 평균 점수에서 RecSA는 131K부터 2M까지 모든 길이에서 가장 높았고, 1M에서는 60.5를 기록해 가장 강한 기준인 Dense + DCA의 40.0보다 높았습니다. 32K에서는 RecSA가 Dense + YaRN과 같은 수준(94.7 대 94.5)이었습니다. PG-19에서 측정한 perplexity는 RecSA가 131K부터 1M까지 10.87에서 11.12 사이를 유지했고, 1M에서 YaRN 계열은 54.42에서 414.69, DCA 계열은 14.57에서 19.18 범위였습니다.
이 결과는 Qwen3-4B 백본과 해당 토큰 예산 설정에서 얻은 것이며, 다른 모델 계열이나 다른 예산에서의 일반 성능으로 확장되지는 않습니다.

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.
원문 · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · 원문 그림 인용 · 원본 PDF 7쪽에서 그림 영역을 추출했습니다.
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.
원문 · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · 원문 그림 인용 · 원본 PDF 9쪽에서 그림 영역을 추출했습니다.
Table C.3 . The nine PG-19 books. Tokens: length of the whole book.
원문 · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · 원문 그림 인용 · 원본 PDF 20쪽에서 그림 영역을 추출했습니다.prefill과 decoding 효율
효율 평가는 H200 GPU 한 장에서 배치 크기 1로 측정되었습니다. 524K 길이에서 RecSA는 prefill을 80초로 처리해 밀집 어텐션의 257초보다 3.2배 빨랐고, decoding은 약 6.1ms/token으로 밀집 어텐션의 23.4ms보다 3.8배 빨랐습니다. 1M과 2M에서 밀집 decoding은 KV 캐시 일부를 호스트 메모리에서 복사하느라 177ms와 2.9s가 걸렸지만, RecSA는 8.35ms와 10.7ms였습니다. 이 가속은 저자들의 최적화 커널과 같은 프레임워크에서 측정된 값이므로 다른 구현의 밀집 어텐션과 직접 같은 조건으로 보지는 않습니다. 원문은 RecSA가 64K부터 2M까지 prefill과 decoding에서 밀집 어텐션보다 빠르다고 보고합니다.

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 m 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.
원문 · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.
Figure 5 . Efficiency on one H200 GPU with batch size 1. (a) Prefill time per token ofRecSA 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).
원문 · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · 원문 그림 인용 · 원본 PDF 8쪽에서 그림 영역을 추출했습니다.
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.
원문 · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · 원문 그림 인용 · 원본 PDF 21쪽에서 그림 영역을 추출했습니다.절제 실험과 k 변화의 영향
절제 실험에서 요약을 제거한 변형은 131K부터 1M까지의 평균이 70.4로, RecSA의 72.3보다 낮았습니다. MLP 항을 제거하면 학습된 백본에서 길이가 늘수록 점수 차이가 커져 131K에서 3.3점, 1M에서 23.4점 낮아졌습니다. 표준 RoPE는 YaRN 없이 131K에서 1.0점이었고, YaRN을 적용해도 1M에서 1.9점에 그쳤습니다. k를 128로 낮추면 131K, 262K, 1M에서 점수가 떨어졌고 k를 512로 늘리면 모든 길이에서 점수가 올랐지만, 이때 토큰 예산도 1.7배에서 1.9배로 커집니다. 따라서 k=512의 개선은 예산 증가와 함께 해석해야 하며, 풀러 학습 방식은 고정된 단계 조건에서 비교된 결과입니다.

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 withk= 128, 256 and 512. Appendix F gives all scores.
원문 · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · 원문 그림 인용 · 원본 PDF 9쪽에서 그림 영역을 추출했습니다.적용 범위와 한계
원문은 RecSA의 검증 범위를 Qwen3-4B 백본, 32K 학습 길이, 0.62B 학습 토큰, 그리고 기본 k=256과 해당 토큰 예산 설정으로 한정합니다. 또한 k를 바꾸면 후보 리스트 안의 상대 거리 범위와 토큰 예산이 함께 바뀌므로, 거리 범위의 보장과 점수 향상은 이 설정 안에서 읽어야 합니다. 효율 수치는 저자들의 커널과 H200 GPU, 배치 크기 1 조건에서 측정되었고, 1M과 2M의 decoding은 호스트 메모리 복사 비용과 선택된 노드에 따라 달라집니다. 짧은 맥락의 벤치마크에서는 RecSA가 원래 모델과 비슷한 수준이었지만 일부 과제에서는 차이가 있었습니다. 이 범위 밖의 모델, 다른 학습 예산, 다른 하드웨어에서의 성능은 본문의 실험으로 확인되지 않았습니다.

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.
원문 · CC BY 4.0 · Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang · Recursive Sparse Attention: Million-Token Length Extrapolation at Logarithmic Cost · 원문 그림 인용 · 원본 PDF 9쪽에서 그림 영역을 추출했습니다.논문 정보
- 저자
- Ruitian Wang, Xinyu Yang, Minshen Zhang, Hao Zhang
- 학회·저널
- arXiv · 프리프린트
- 최초 공개일
- 2026년 11월 4일
- 등록일
- 2026년 11월 6일
- 수정일
- 2026년 11월 4일
- 버전
- v1
- arXiv
- 2611.07232
- 분류
- cs.CL · cs.LG
- 원문 이용 조건
- CC BY 4.0
- 제공 범위
- 논문 정보, 해설, 허용된 원문 그림
AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.
초록
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.
원문 인용
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}
}