Research
FreeSolo: Linear-time Sparse Attention with Zero-Shot Length Extrapolation
Overview Research area: Efficient long-context language modeling — specifically sparse attention architectures and zero-shot length extrapolation. Technical level: Advanced. The paper assumes familiar

- arXiv
- 2610.17191
- Published
- 2026-10-12
- Authors
- Zekun Shi, Alastair James Arthur Price
AI summary
Overview
Research area: Efficient long-context language modeling — specifically sparse attention architectures and zero-shot length extrapolation.
Technical level: Advanced. The paper assumes familiarity with rotary position embeddings (RoPE), KV caching, softmax attention complexity, and continued pretraining.
Scope: The paper introduces FreeSolo, a native sparse attention mechanism with separate short-range and long-range branches, and evaluates two variants (FS-L and FS-B) on long-context retrieval benchmarks against full-attention, recurrent, and sparse-attention baselines.
What This Paper Is About
Long-context models must retrieve information from far beyond the length they were trained on, but full attention costs quadratic time, and recurrent models compress history into a fixed-size state that limits how much can be stored. Sparse attention and continued pretraining (CPT) can extend effective context, but generalization past the trained length remains unreliable and CPT is expensive. FreeSolo aims to get linear-time or near-linear attention that still extrapolates to much longer sequences without any long-context fine-tuning.
Key Contributions
-
A two-branch native sparse attention design. Every head combines a short-range sliding-window branch that uses RoPE inside a fixed window (w = 512) with a long-range branch that selects "cells" of 32 tokens and applies NoPE attention to the selected tokens' original keys and values, using unrotated queries and keys so no unseen rotary offsets appear.
-
Searchable, prunable cell summaries. Mean cell keys serve as a chunk representation for routing (content match), the maximum token-key norm in a cell (
a_c) provides a query-independent priority for pruning, and the paper shows these simple statistics suffice to route, prune, and hierarchically summarize memory. -
Two variants with different cost profiles. FreeSolo-Linear (FS-L) prunes the prefix per head by key norm and recency before query-dependent selection, giving O(N) attention cost and a bounded streaming state; FreeSolo-Balanced Tree Search (FS-B) keeps a growing archive and searches two causal forests with a beam of 16 nodes per level, giving O(N log²N) algorithmic cost including radix-sort construction.
-
Zero-shot extrapolation results. Both variants extrapolate from 4k training to 16k without long-context fine-tuning, and both retrieve single needles at 256k — 64× the training length — while FS-B achieves the highest RULER mean in the superlinear group and FS-L leads the linear group at every reported length.
Main Findings
-
Extrapolation at 16k costs little accuracy. At the ≈800M scale, the RULER mean falls only from 32.0 to 22.3 for FS-L and from 37.7 to 30.4 for FS-B between 4k and 16k.
-
Harder retrieval tasks separate the methods. At 800M and 16k, FS-L scores 81/40 on S-NIAH-2/3, versus 26/0 for Raven and 72/34 for base FS. At 64k, FS-L reaches 53/13, versus 28/4 for FS and 0/0 for NAtS-L.
-
FS-B is the strongest overall variant. At 800M and 16k it scores 100/88/84 on S-NIAH-1/2/3, with a full RULER mean of 30.4. At 743M, FS-B posts means of 42.1 / 37.7 / 31.8 / 30.4 at 2k / 4k / 8k / 16k, ahead of FS-L (37.2 / 32.0 / 25.6 / 22.3) and base FS (39.4 / 34.0 / 27.6 / 23.1).
-
Gains extend beyond single needles. FS-L scores 23 on MK-NIAH-1 versus 3 for both linear baselines, and 17 on MV-NIAH versus 9 and 0.5 for Raven and NAtS-L.
-
Full RULER means favor FreeSolo at both scales. At 800M and 16k the means are 23.1/22.3 for FS/FS-L versus 12.8/2.8 for Raven/NAtS-L. At 340M, FS-B / FS-L / FS reach 34.2 / 32.4 / 30.8 at 2k and 20.2 / 10.7 / 11.8 at 16k.
-
Single-needle recall survives very long ranges. At 340M, FS holds 98–100 through 256k while FS-L scores 84 at 256k; Raven falls to 20 at 131k. At 800M, FS and FS-L score 96/85 at 256k, compared with zero for NAtS-L.
-
Short CPT preserves most hard-task retrieval. On the same 50 prompts at 800M and 16k, the FS continuation scores 84/38 on S-NIAH-2/3 and FS-L scores 80/42 — so adaptation to pruning, not just extra training, explains much of the behavior.
-
Some baselines fail to sustain recall. MoBA and NSA do not sustain recall in these evaluations, whereas Raven, NAtS-L, and GDN retain retrieval ability beyond the training context.
-
Short-context quality is largely preserved. On eight zero-shot tasks at 340M, FS averages 51.9 and FS-L 51.0, versus 51.8 for TF++, 51.4 for Raven, and 50.8 for NAtS-L. At 800M, FS reaches 56.5, close to TF++'s 56.8 and SWA's 56.2, while FS-L reaches 55.2 and Raven 54.6.
-
From-scratch pruning training underperforms. The 340M from-scratch model retains strong S-NIAH-1 recall, but the tested 800M from-scratch run retrieves poorly; the paper states this motivates the two-stage recipe but does not isolate the cause.
-
Some tasks remain hard for everyone. Variable tracking and similar tasks stay difficult for all models even within the training context.
Methodology in Plain English
The design splits each attention head into two jobs.
The short-range branch is an ordinary sliding window of 512 tokens that uses RoPE, and its radius is held fixed at both training and evaluation, so the model never sees relative positions larger than it was trained on. The long-range branch is where the interesting work happens: the token history is grouped into cells of 32 tokens, and each cell is summarized by a mean key (used to match against the query for routing) and by the largest key norm inside it (used as a query-independent priority). The model scores cells using a content term plus a position bias that grows with distance and is scaled by that norm, picks the top 4 cells per query and head (128 tokens), and only then performs softmax attention over the actual, unrotated token keys and values inside those cells. The two branch outputs are added with a learned per-head weight.
FS-L goes further: before any query-dependent scoring, each head keeps only 8 recent cells plus the 64 cells with the highest maximum key norm, giving a bounded pool of at most 72 cells that updates only at query-block boundaries (every 128 tokens). This makes the cost linear and the streaming cache small.
FS-B takes a different route for the case where many equally plausible facts must each remain reachable. It builds two trees per head — one over the full prefix and one over cells whose norm exceeds a threshold set once per checkpoint as the median cell norm on FineWeb-Edu windows — where each node stores a mean key, a radius bounding its children, the maximum cell norm, and the earliest position. A beam search of 16 nodes per level descends each tree, using a score that is a provable upper bound on the cell score beneath a node, and the union of both beams is reranked with token-level log-sum-exp scores before the top 4 cells are read.
Training proceeds in stages. Models are LLaMA-style decoders trained on FineWeb-Edu with 4096-token contexts and 15B/32B token budgets at 341M/743M parameters. FS is trained first; FS-L is then produced by continued pretraining with pruning enabled (0.73B/1.57B tokens, about 5% of pretraining), and at 800M FS-B uses a retrieval-weighted CPT loss (0.42B tokens) that upweights repeated spans and recall-switch points. Hard top-P and top-K indices receive no gradient, and the routing scalars stay fixed at σ_h = 4 and λ_h = 1.
Why This Matters
The paper argues that neither compression nor sparsity alone guarantees length extrapolation, and that CPT on longer sequences is an additional cost. FreeSolo shows that careful position handling — keeping RoPE strictly local and doing long-range routing/readout without positional rotations — lets a model extrapolate from 4k to 16k and even retrieve single needles at 256k, all while keeping attention cost linear (FS-L) or strictly subquadratic (FS-B). The separation of which cells remain available from which cells a query reads is the conceptual move that lets FS-L trade memory capacity against per-query bandwidth in a tunable way.
Real-world applications:
- Long-document and multi-document question answering, where a single supporting passage must be found in hundreds of pages.
- Conversational assistants with long histories, where recent turns need dense local attention and old turns need cheap retrievable memory.
- Code and repository analysis, where a relevant function definition may sit far from the current edit site.
- Log, transcript, and audit-record search, where evidence is sparse and spread across a long stream.
Industry relevance: the linear-time variant maintains a bounded streaming state of O(((P+W)s + w + B + s)d) token state per head, which matters for inference serving, and the headline claim is a cost reduction from quadratic to linear while retaining most of the harder-task retrieval — a trade that directly affects serving economics for long-context products.
Future Directions
-
Closing the dense multi-fact gap. FS-L suits evidence concentrated in a few cells; in a list of unique key–value pairs where every pair is equally likely to matter, a fixed pool reaches a shrinking fraction of targets. FS-B addresses this with tree search, but the paper motivates further work on keeping every cell reachable at low cost.
-
Cheaper or unnecessary CPT. Training with pruning from scratch is possible but the tested 800M from-scratch run retrieves poorly, while CPT gives better overall retrieval. The paper explicitly says its runs do not isolate the cause, leaving the two-stage recipe as an open question.
-
System-level efficiency. The reported comparison is algorithmic; the reference streaming cache is disclosed to make repeated buffer copies, and the efficiency table uses a masked implementation that stores O(Nd) KV and adds Θ(N²/(Bs)) work, so actual wall-clock and memory behavior of the streaming path is a natural next target.
-
Lengths beyond 256k and absolute accuracy decline. Accuracy still falls with length for all variants even where relative ordering is favorable, and thresholds such as τ are calibrated once per checkpoint — extending both the reachable length and the robustness of such calibration remain open.
Target Audience
Researchers and engineers working on long-context attention, KV-cache efficiency, and length extrapolation, particularly those who need retrieval behavior (not just perplexity) at lengths several times the training context. It is also relevant to practitioners who must choose between recurrent/state-based models and sparse-attention hybrids for long-document or long-conversation systems, and to readers interested in how positional encoding choices (RoPE locally, NoPE globally) interact with extrapolation.
Authors’ abstract
Linear-time sequence models typically store long-context information in a recurrent state. A fixed-size state limits how much information can be stored, while hybrid architectures that add full attention for better recall incur quadratic sequence cost. Alternatively, sparse attention with continued pretraining (CPT) can extend the effective context length. Generalization beyond the trained length remains challenging, however, and CPT can be costly. We introduce FreeSolo, a native sparse attention mechanism with a short-range sliding window branch and a long-range branch that selects keypoint cells for direct token attention. Its linear-time variant, FS-L, learns to prune the prefix before query-dependent selection through short CPT. FS-B searches balanced trees with $O(N\log^2 N)$ algorithmic cost including radix-sort construction. FreeSolo demonstrates better zero-shot length extrapolation than the baselines without long-context fine-tuning.