betaFeedback

WorksComputer Science

FreeSolo: Linear-time Sparse Attention with Zero-Shot Length Extrapolation

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(Nlog⁡2N)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.

Introduction

Long-context language modeling requires efficient attention and retrieval beyond the training length. Full attention has quadratic sequence cost [38]. Recurrent models compress history into fixed-size states [19, 14, 6], while Native Sparse Attention (NSA) [45] and Mixture of Block Attention (MoBA) [26] preserve token access but score growing sets of blocks. Neither compression nor sparsity alone ensures length extrapolation. Continued pretraining (CPT) on longer sequences can extend retrieval at additional training cost [12].

We introduce FREESOLO (FS), a native sparse mechanism that learns token keys whose simple statistics make memory searchable, prunable, and hierarchically summarizable. Mean keys give a simple chunk representation for routing and hierarchical search, while maximum token-key norms provide pruning priorities. These summaries need only identify evidence: top-KK selection is followed by attention over the cells’ original token keys and values. FS scores all eligible cell summaries during training, but only selected token values enter the long-range readout. The read budget stays fixed as history grows. RoPE [35] stays within a fixed local window, while long-range routing and readout use unrotated queries and keys, avoiding unseen rotary offsets (Figure 2).

FreeSolo attention diagram

Figure 2. FreeSolo attention. FS scores the full prefix; FS-L prunes per head, independently of the query. Both select K=4K = 4 cells per query and head. We use P=64P = 64 high-norm cells, W=8W = 8 recent cells, cell size s=32s = 32, query blocks of B=128B = 128 tokens, and SR radius w=512w = 512.

We develop two main variants through short CPT from base FS at the same 4k context length. FreeSolo-Linear (FS-L) uses norm pruning for O(N)O(N) attention cost and bounded state. FreeSolo-Balanced Tree Search (FS-B) keeps a growing archive and uses two content forests, with O(Nlog⁡2N)O(N\log^{2}N) algorithmic cost including radix-sort construction, superlinear but strictly subquadratic (§ 3.5). Both extrapolate zero-shot to 16k: at 800M, the RULER mean decreases only from 32.0 to 22.3 for FS-L and from 37.7 to 30.4 for FS-B relative to 4k. Notably, both retrieve single needles at 256k, 64× the training length. At both scales, FS-B achieves the highest RULER mean in the superlinear group at 4k and beyond, and FS-L leads the linear group at every reported length (Table 1).

Table 1: RULER accuracy (0–100). All models train at 4k; results at 8k and above test zero-shot extrapolation. Means cover available tasks; cost is defined in § 4.1. FS-B’s algorithmic cost includes radix-sort construction (Appendix § 13.§ 2). Bold/underline mark the best/second-best scores within each block (super-linear or linear cost); dashes denote unavailable results.

ModelParamsComplexityS-NIAH-1 2kS-NIAH-1 4kS-NIAH-1 8kS-NIAH-1 16kS-NIAH-1 32kS-NIAH-1 64kS-NIAH-1 131kS-NIAH-1 256kS-NIAH-2 2kS-NIAH-2 4kS-NIAH-2 8kS-NIAH-2 16kS-NIAH-2 32kS-NIAH-2 64kS-NIAH-3 2kS-NIAH-3 4kS-NIAH-3 8kS-NIAH-3 16kS-NIAH-3 32kS-NIAH-3 64kMean 2kMean 4kMean 8kMean 16k
TF++335MO(N2)O(N^2)955700––––912400––38100––26.213.30.20.0
InfLLM335MO(N2)O(N^2)9458139––––892382––39121––––––
MoBA341MO(N2/b)O(N^2/b)761200––––832300––59300––25.67.60.00.0
NSA513MO(N2/b)O(N^2/b)432300––––481800––1000––13.27.30.90.0
Raven-full355MO(N2)O(N^2)1009983394440010089417––38100––26.721.513.57.1
FS341MO(N2/s)O(N^2/s)99991001009810098100100774117––581470––30.823.216.511.8
FS-B341MO(Nlog⁡2N)O(N\log^2 N)10099999999100100100100998960321091786427342434.231.126.620.2
FS-L341MO(N)O(N)998890876586858499703420737017912132.421.615.510.7
Raven357MO(N)O(N)95969381784120–9270363––3000––20.517.814.08.5
NAtS-L380MO(NR)O(NR)100943719000–8922203––36610––25.615.37.44.0
GDN335MO(N)O(N)95833519––––8320183––0000––21.614.27.03.6
SWA341MO(N)O(N)181573––––312162––25230––14.69.34.54.0
≈800M scale
TF++743MO(N2)O(N^2)1009500––––1009400––675000––46.337.50.00.0
InfLLM743MO(N2)O(N^2)10096204––––10089124––775040––––––
NSA1128MO(N2/b)O(N^2/b)1007580––––984630––30700––40.724.82.60.1
Raven-full723MO(N2)O(N^2)100100100100989174481008881695119158214––41.433.726.523.8
FS743MO(N2/s)O(N^2/s)979193957997959610099927263288571513427439.434.027.623.1
FS-B743MO(Nlog⁡2N)O(N\log^2 N)9798971001001001001001001009588804396938784716942.137.731.830.4
FS-L743MO(N)O(N)1009284848478808599998981685390715540291337.232.025.622.3
Raven726MO(N)O(N)100100100100100999992999781265–327100–30.123.918.412.8
NAtS-L793MO(NR)O(NR)86725921210010076283006224600027.819.410.22.8
GDN694MO(N)O(N)1001001005622–––94381913––8427105––35.822.816.510.4
SWA743MO(N)O(N)181573––––312162––19310––15.610.35.54.0

Table 1.

Preliminaries

Attention. For one head, let qi\mathbf{q}_i, ki\mathbf{k}_i, vi∈Rd\mathbf{v}_i \in\mathbb{R}^{d} be the query, key, and value at position i∈{0,…,N−1}i \in\{0,\ldots,N-1\}. Define ℓij=qiTkj/d\ell_{ij} = \mathbf{q}_i^{\mathsf{T}}\mathbf{k}_j/\sqrt{d} and Δ=i−j\Delta= i-j. For a nonempty token set J\mathcal{J}, collect the logits in ℓi,J\boldsymbol{\ell}_{i,\mathcal{J}} and matching value rows vjT\mathbf{v}_j^{\mathsf{T}} in VJ\mathbf{V}_{\mathcal{J}}. The readout is

oiT=softmax⁡(ℓi,J)TVJ=∑j∈Jexp⁡(ℓij)vjT∑j∈Jexp⁡(ℓij).(1)\mathbf{o}_i^{\mathsf{T}} = \operatorname{softmax}(\boldsymbol{\ell}_{i,\mathcal{J}})^{\mathsf{T}}\mathbf{V}_{\mathcal{J}} = \frac{\sum_{j\in\mathcal{J}}\exp(\ell_{ij})\mathbf{v}_j^{\mathsf{T}}}{\sum_{j\in\mathcal{J}}\exp(\ell_{ij})}. \tag*{(1)}

Full causal attention uses J={0,…,i}\mathcal{J} = \{0,\ldots,i\} and costs O(N2d)O(N^{2}d) per sequence or O(Nd)O(Nd) per cached decoding step. FlashAttention computes the same readout with O(Nd)O(Nd) memory [7].

Sparse attention. Sparse attention restricts each query to Ji⊆{0,…,i}\mathcal{J}_i \subseteq\{0,\ldots,i\}, fixed or query dependent. If ∣Ji∣≤m|\mathcal{J}_i| \le m, the readout costs O(Nmd)O(Nmd) per sequence, plus selection.

Length extrapolation. Zero-shot length extrapolation evaluates at N>LN > L after training at length LL, with fixed weights. We measure retrieval rather than perplexity, whose token average can obscure errors requiring distant context [11].

Method

Range separation

FreeSolo combines local window attention with sparse long-range attention in each head (Figure 2). The local branch applies RoPE within a fixed window. The long-range branch selects top-KK cells and applies

NoPE attention (Kazemnejad et al., [20]) to their tokens, using unrotated queries and keys. This branch is sparse in both FS and FS-L; FS-L also prunes the prefix before query-dependent scoring. Both branches share projections of the layer’s RMS-normalized hidden state ziz_i (Zhang and Sennrich, [46]): qi=Wqziq_i = W_qz_i, ki=Wkzik_i = W_kz_i, and vi=Wvziv_i = W_vz_i. We combine the outputs as

oi=oisr+αhoilr,(2)o_i = o_i^{\mathrm{sr}} + \alpha_h o_i^{\mathrm{lr}}, \tag*{(2)}

where αh\alpha_h is learned per head. Each branch normalizes its own attention, and their supports may overlap. We concatenate the head outputs, project by WoW_o, and add the layer input. A second RMSNorm and SwiGLU feed-forward residual (Shazeer, [33]) complete the layer.

Local branch

Let Li={j:0≤j≤i, i−j≤w}\mathcal{L}_i = \{j : 0 \le j \le i,\ i - j \le w\}, where ww is a look-back radius, so a full window contains w+1w + 1 tokens. Let R(i)R(i) be the RoPE rotation at position ii (Su et al., [35]). We use the local score

ℓijsr=(R(i)qi)T(R(j)kj)d=qiTR(j−i)kjd,(3)\ell_{ij}^{\mathrm{sr}} = \frac{(\mathbf{R}(i)q_i)^{\mathsf{T}}(\mathbf{R}(j)k_j)}{\sqrt{d}} = \frac{q_i^{\mathsf{T}}\mathbf{R}(j-i)k_j}{\sqrt{d}}, \tag*{(3)}

and collect these logits over Li\mathcal{L}_i to compute

(oisr)⊤=softmax⁡((ℓi,Lisr)⊤)VLi.(4)(\mathbf{o}^{\mathrm{sr}}_i)^{\top} = \operatorname{softmax}((\ell^{\mathrm{sr}}_{i,\mathcal{L}_i})^{\top})\mathbf{V}_{\mathcal{L}_i}. \tag*{(4)}

We use w=512w = 512 at both training and evaluation. Increasing the context therefore introduces no larger relative offsets into this branch.

Long-range branch

The long-range branch provides a sparse, content-addressable memory beyond the local window. Storing contextualized token key/value pairs allows later queries to retrieve individual details directly [40, 41]. Mean keys guide cell selection; the readout uses the selected tokens’ keys and values. FS scores the full prefix before the query block. FS-L first prunes this prefix by key norm and recency, separating which cells remain available from which cells a query reads. This separates memory capacity from per-query read bandwidth (Appendix § 12.§ 3).

Cells. A cell is a group of ss consecutive token key/value pairs, selected as a unit by the router. Using zero-based indices, cell cc contains positions Ic={cs,…,(c+1)s−1}\mathcal{I}_c = \{cs,\ldots,(c+1)s-1\}. Its summaries are

kˉc=1s∑j∈Ickj,pc=(c+12)s,ac=max⁡j∈Ic∥kj∥2.(5)\bar{\mathbf{k}}_c = \frac{1}{s}\sum_{j\in\mathcal{I}_c}\mathbf{k}_j,\qquad p_c = \left(c+\frac{1}{2}\right)s,\qquad a_c = \max_{j\in\mathcal{I}_c}\lVert\mathbf{k}_j\rVert_2. \tag*{(5)}

The mean key summarizes content for routing, pcp_c lies halfway between the cell boundaries, and the largest key norm supplies a query-independent priority. The raw keys and values remain available for token-level attention after selection.

Query blocks. A query block groups B/sB/s consecutive cells, covering BB token positions, with BB a multiple of ss. The full prefix is shared across heads and queries in a block. FS-L reuses each head’s retained pool throughout the block, amortizing pruning and gathering. Selection and readout are per query and head. We use B=128B = 128 and s=32s = 32, so each block contains four cells. The block containing query ii starts at bi=B⌊i/B⌋b_i = B\lfloor i/B\rfloor.

Causal availability. The full prefix Ci\mathcal{C}_i contains all cells before the query-block start:

Ci={c∈Z≥0:(c+1)s≤bi}.(6)\mathcal{C}_i = \{c \in\mathbb{Z}_{\ge0} : (c+1)s \le b_i\}. \tag*{(6)}

Every cell in this prefix contains only past tokens for every query in the block. The prefix stays fixed until all BB queries have finished (Figure 2). At the next boundary, it includes the completed block, and FS-L updates its retained cells. The local window covers the intervening past because w=512≥B−1w = 512 \ge B - 1; the first block has no long-range cells.

Cell scoring. We combine mean-key content routing, also used in MoBA [26], with a norm-weighted relative position bias:

ric=qi⊤kˉcd+λhacgh(i−pc),c∈Ci,(7)r_{ic} = \frac{\mathbf{q}_i^{\top}\bar{\mathbf{k}}_c}{\sqrt{d}} + \lambda_h a_c g_h(i-p_c),\qquad c\in\mathcal{C}_i, \tag*{(7)}

where gh(Δ)=erf⁡(Δ/(2σh))g_h(\Delta)=\operatorname{erf}(\Delta/(2\sigma_h)), σh>0\sigma_h>0, and λh≥0\lambda_h\ge0. The content term uses unrotated queries and keys. The erf prior encodes relative distance in a translation-invariant way and supplies a norm-scaled bias to cell scoring. All eligible offsets satisfy i−pc>0i-p_c>0. Ranking these scores and selecting only the top-KK cells induces sparsity: only tokens in the selected cells enter the long-range readout. FS scores the full prefix; FS-L first prunes it by key norm.

Query-independent pruning. Each head prunes independently using its own projected key norms. FS-L retains the WW most recent cells and the PP cells with largest aca_c:

Ai=Recent⁡W(Ci) ∪ TopP⁡c∈Ci(ac),∣Ai∣≤W+P.(8)\mathcal{A}_i=\operatorname{Recent}_W(C_i)\ \cup\ \operatorname{TopP}_{c\in C_i}(a_c),\qquad|\mathcal{A}_i|\le W+P. \tag*{(8)}

The union removes duplicates. The priority favors cells containing a large-norm key, while the recent window preserves nearby context. Projected keys have varying norms; we do not normalize them individually. The RMSNorm after the long-range readout normalizes the output, not these priorities.

Key norm supplies a query-independent priority, not a guarantee of relevance to every query. CPT adapts the model to this restricted access pattern. Appendix § 12.§ 3 measures how much pruning compresses the prefix and which cells remain available for retrieval. We use P=64P=64 and W=8W=8.

Per-query selection. FS uses Ai=Ci\mathcal{A}_i=C_i; FS-L uses Eq. (8). Each head evaluates Eq. (7) on its own Ai\mathcal{A}_i and selects up to K=4K=4 cells per query. Different heads can select different cells, and selections can change at every token within a query block. Let Ti(Ai)\mathcal{T}_i(\mathcal{A}_i) contain the min⁡(K,∣Ai∣)\min(K,|\mathcal{A}_i|) highest-scoring cells, and collect their token indices as Si=⋃c∈Ti(Ai)Ic\mathcal{S}_i=\bigcup_{c\in\mathcal{T}_i(\mathcal{A}_i)}\mathcal{I}_c.

Token readout. The long-range output is

uilr⁡=softmax⁡(ℓi,Si)TVSi,oilr⁡=RMSNorm⁡(ui).(9)\mathbf{u}_i^{\operatorname{lr}}=\operatorname{softmax}(\boldsymbol{\ell}_{i,\mathcal{S}_i})^{\mathsf{T}}\mathbf{V}_{\mathcal{S}_i},\qquad\mathbf{o}_i^{\operatorname{lr}}=\operatorname{RMSNorm}(\mathbf{u}_i). \tag*{(9)}

This is NoPE attention: the erf prior affects cell scoring only, while the readout uses unmodified token keys and values, with no positional bias in its logits. The softmax is normalized jointly over all selected tokens. RMSNorm acts over the dd head features ([46]). Both outputs in Eq. (9) are zero when Si\mathcal{S}_i is empty.

Training. We obtain FS-L by continued pretraining of FS with pruning enabled. Both stages use the standard next-token cross-entropy objective on 4096-token sequences. CPT resets the optimizer and learning-rate schedule (Appendix § 9) and requires no longer training contexts. Causal masks allow all query blocks to be evaluated in parallel. Hard top-PP and top-KK indices receive no gradient; shared projections and contextual states learn through local attention and selected-token readout. The routing-only scalars receive no gradient in this configuration and remain at σh=4\sigma_h=4 and λh=1\lambda_h=1.

Training with pruning from scratch is also possible, but CPT gives better overall retrieval, particularly on the harder tasks. The 340M from-scratch model retains strong S-NIAH-1 recall, whereas the tested 800M run retrieves poorly. Starting from FS provides useful representations before imposing the pruning constraint. This motivates the two-stage recipe, although the runs do not isolate the cause of the from-scratch difference. Appendix § 12.§ 4 gives the comparisons and variation across CPT runs.

FS-B long-range selection, per head

Figure 3. FS-B long-range selection, per head. The query searches two causal forests over the prefix: one over every cell and one over cells with ac≥τℓha_c \ge\tau_{\ell h}. Each beam keeps 16 nodes per level down to the leaves, ⌈log⁡2M⌉\lceil\log_2 M\rceil levels for MM admitted cells (6 and 5 in this 64-cell example). The union of both beams is reranked with token keys; the top K=4K = 4 cells form SiS_i, which is read as in FS.

Inference. Prompt prefill uses the same causal operator and populates each layer’s raw key/value cache and cell summaries. During decoding, each new token appends its key and value; a completed cell supplies its mean key and maximum key norm. The local window advances every token. The long-range prefix advances only at query-block boundaries, when FS-L also updates its retained set. Within a block, each query scores the available cells, selects its own top-KK, and applies Eq. (9) before the branch combination in Eq. (2). FS-L’s streaming cache merges newly eligible cells into the retained set and discards unused KV once it leaves the recent, local, and unfinished-block buffers.

Balanced tree search (FS-B)

FS-L suits evidence concentrated in a few cells, as in single-needle retrieval, because query-independent pruning can keep those cells. Dense, independently queryable facts are harder: in a list of unique key–value pairs followed by a question about a uniformly sampled key, every pair is equally likely to matter, so a fixed pool reaches a shrinking fraction of the possible targets (Appendix § 12.§ 5). FS keeps every cell reachable but scores the full prefix in O(N2/s)O(N^2/s) work. FS-B keeps the local branch and the NoPE readout of Eq. (9) and changes only how SiS_i is chosen: each query searches content trees over a growing memory, so no cell is discarded for all future queries while search and read budgets stay bounded.

Two causal forests. FS-B always uses two forests per head, with admitted sets

Ai0=Ci,AiT={c∈Ci:ac≥τℓh},(10)\mathcal{A}_i^0 = C_i,\qquad\mathcal{A}_i^T = \{c \in C_i : a_c \ge\tau_{\ell h}\}, \tag*{(10)}

where τℓh\tau_{\ell h} is the median cell norm on FineWeb-Edu windows, calibrated once per checkpoint and reused at all lengths. The first forest keeps the whole prefix searchable; the second emphasizes high-norm evidence, as FS-L does, without a fixed quota. In each forest, every aligned chunk of 2k2^k admitted cells is split recursively at the median of its mean keys along their principal direction, and summary nodes join the chunk roots, so MM admitted cells give height ⌈log⁡2M⌉\lceil\log_2 M \rceil (Figure 9). A node vv over cells C(v)C(v) stores their mean key μv\mu_v, a radius ρv≥max⁡c∈C(v)∥kc−μv∥2\rho_v \ge\max_{c\in C(v)} \lVert\mathbf{k}_c-\mu_v\rVert_2, the maximum norm Av=max⁡c∈C(v)acA_v = \max_{c\in C(v)} a_c, and the earliest position pvmin⁡=min⁡c∈C(v)pcp_v^{\min} = \min_{c\in C(v)} p_c.

Streaming construction of one FS-B forest: one forest with $M=13=8+4+1$ admitted cells, leaf arrival-order labels 3, 6, 1, 8, 2, 5, 7, 4, 11, 9, 12, 10, 13, root with 13 cells, an intermediate node with 5 cells, chunks of 8, 4, and 1 cells, height $\lceil\log_2 M\rceil=4$, and two construction steps

Figure 9. Streaming construction of one FS-B forest, per head. Solid edges form balanced trees within power-of-two chunks; dashed edges join their roots, smallest first. Leaf numbers denote arrival order, while their arrangement follows mean-key splits. The 13=8+4+113 = 8 + 4 + 1 example has height ⌈log⁡213⌉=4\lceil\log_2 13 \rceil= 4. Right: the two construction steps; node summaries are defined in Eqs. (20)–(21).

Beam search. From the root, each forest keeps the Wb=16W^{\mathrm{b}} = 16 highest-priority nodes per level down to the leaves, ranking nodes by

Uv=qiTμv+c∥qi∥2ρvd+λhAvgh(i−pvmin⁡).(11)U_v = \frac{\mathbf{q}_i^{\mathsf{T}}\mu_v + c\lVert\mathbf{q}_i\rVert_2\rho_v}{\sqrt{d}} + \lambda_h A_v g_h(i-p_v^{\min}). \tag*{(11)}

For c≥1c \ge1, UvU_v bounds the score of Eq. (7) for every cell below vv: the radius bounds the content term, and AvA_v and pvmin⁡p_v^{\min} bound the nonnegative, monotone prior. The search remains approximate, since a branch with a lower bound can still hold the best cell; we use c=8c = 8. The leaves reached form candidate sets Bi0\mathcal{B}_i^0 and BiT\mathcal{B}_i^T of at most 16 cells each, which differ because the forests group the prefix differently.

Token-level reranking. Mean keys can hide a single useful token, so FS-B rescores the deduplicated candidates Bi=Bi0∪BiT\mathcal{B}_i = \mathcal{B}_i^0 \cup\mathcal{B}_i^T with their token keys,

r~ic=log⁡∑j∈Icexp⁡(qiTkjd)+λhacgh(i−pc),c∈Bi,(12)\widetilde{r}_{ic} = \log\sum_{j\in I_c} \exp\left(\frac{\mathbf{q}_i^{\mathsf{T}}\mathbf{k}_j}{\sqrt{d}}\right) + \lambda_h a_c g_h(i-p_c),\qquad c\in\mathcal{B}_i, \tag*{(12)}

and the top K=4K = 4 cells form SiS_i, read with Eq. (9).

Retrieval-weighted CPT. At 340M, FS-B reuses the FS-L weights. At 800M, base FS undergoes 0.42B-token CPT on 4096-token FineWeb-Edu sequences with a weighted next-token loss:

L=−∑twtlog⁡pθ(xt+1∣x≤t)∑twt,wt=1+βfft+βsχt,(13)\mathcal{L} = -\frac{\sum_t w_t \log p_\theta(x_{t+1}\mid x_{\le t})}{\sum_t w_t},\qquad w_t = 1 + \beta_f f_t + \beta_s \chi_t, \tag*{(13)}

Here ft,χt∈{0,1}f_t,\chi_t \in\{0,1\} are text-derived masks. The recall mask ft=1f_t = 1 marks starts and continuations of repeated spans, identified by a unique earlier four-token match more than 512 tokens back in the same document. The switch mask χt=1\chi_t = 1 adds a bonus at a recall start within 64 tokens of the preceding start if their earlier source positions are more than 64 tokens apart. Every token retains base weight 1. Training uses full-prefix FS selection with 16-cell reads; forests are used only at inference (Appendix § 13.§ 4).

Computational cost

At fixed head dimensions and budgets, FS costs O(N2/s)O(N^2/s), FS-L O(N)O(N), and FS-B O(Nlog⁡2N)O(N\log^2 N) including radix-sort construction.

Cell statistics cost O(Nd)O(Nd) per head. Each query scores M≃N/sM \simeq N/s cells, giving FS a cost of O(N2d/s+N(w+Ks)d)O(N^2d/s + N(w+Ks)d) including local and selected-token readout. Query blocks share availability, not scores; BB does not reduce the quadratic term. FS-L incrementally merges newly eligible cells into its top-PP set. Fixed key-norm scores prevent discarded cells from re-entering. A heap costs O(Mlog⁡(P+1))O(M \log(P+1)) in total; bounded-array merges are linear at fixed budgets.

Let C=P+WC = P + W. Scoring the retained cells costs O(NCd)O(NCd), and attention over gathered selected tokens costs O(NKsd)O(NK_sd). With incremental retention and the local branch, the sequence cost is

O(Nd+Mlog⁡(P+1)+N(C+w+Ks)d).(14)O(Nd + M \log(P+1) + N(C+w+K_s)d). \tag*{(14)}

At fixed budgets, decode work is bounded, including amortized retention updates. The streaming implementation keeps O(((P+W)s+w+B+s)d)O(((P+W)s+w+B+s)d) token state per head plus indices and counters, computes rotations on demand, and prefills in fixed chunks (Appendix § 11).

FS-L results in Table 1 and Table 4 use this bounded cache, which keeps only the retained cells (Appendix § 9); its resource measurements are in Appendix § 11. The efficiency comparison in Table 6 uses a masked implementation that stores O(Nd)O(Nd) KV and rescans priorities at block boundaries, adding Θ(N2/(Bs))\Theta(N^2/(Bs)) work, with O(N(P+W)sd)O(N(P+W)sd) masked readout.

TaskRaven-full 2kRaven-full 4kRaven-full 8kRaven-full 16kFS 2kFS 4kFS 8kFS 16kFS-B 2kFS-B 4kFS-B 8kFS-B 16kFS-L 2kFS-L 4kFS-L 8kFS-L 16kNAtS-L 2kNAtS-L 4kNAtS-L 8kNAtS-L 16kRaven 2kRaven 4kRaven 8kRaven 16k
≈340M scale
S-NIAH-110099833999991001001009999999988908710094371995969381
S-NIAH-2100894171007741171009989609970342089222039270363
S-NIAH-33810058147091786427701791366103000
MK-NIAH-1252218182720155272519243124211017181041111103
MK-NIAH-2010010002001010000000000
MK-NIAH-3000010012000000000000000
MQ-NIAH20.813.36.85.020.220.812.82.823.822.518.512.521.821.510.53.817.515.24.82.815.016.513.23.0
MV-NIAH19.317.86.86.523.218.515.59.824.522.023.521.024.319.816.37.318.88.84.57.011.212.012.04.5
VT0.81.40.40.22.21.20.61.63.21.21.01.02.80.00.00.04.80.60.00.02.62.01.41.0
CWE0.20.60.00.14.19.25.20.85.210.36.51.84.99.14.00.42.65.00.20.31.00.20.20.1
FWE0.00.00.00.08.73.35.03.39.06.011.75.09.71.02.32.73.01.70.32.30.00.00.00.0
QA-11613972515572310442684319129415646
QA-2––1010––85––96––104––1010––129
Available-task mean26.721.513.57.130.823.216.511.834.231.126.620.232.421.615.510.725.615.37.44.020.517.814.08.5
≈800M scale
S-NIAH-11001001001009791939597989710010092848486725921100100100100
S-NIAH-21008881691009992721001009588999989811007628399978126
S-NIAH-3915821485715134969387849071554062246032710
MK-NIAH-1373629325332302850342831433227233120733019143
MK-NIAH-2310070119412831100003000
MK-NIAH-3320000002100201000000000
MQ-NIAH69.546.544.038.334.525.822.823.045.828.328.827.326.222.516.015.516.511.51.50.327.819.811.07.2
MV-NIAH56.341.339.039.028.026.322.818.838.330.329.826.326.220.821.017.013.510.83.00.525.817.013.59.0
VT0.60.20.60.61.60.20.40.03.81.41.00.63.80.80.40.60.00.20.00.01.60.80.61.0
CWE3.39.35.41.28.426.713.53.37.826.48.94.44.513.07.11.20.40.70.00.01.91.30.10.1
FWE1.71.70.40.016.76.05.05.717.78.77.08.00.30.01.70.01.73.34.70.018.011.013.33.7
QA-132201012423012938271310433011112314110221465
QA-2––1513––1511––1714––1916––129––1111
Available-task mean41.433.726.523.839.434.027.623.142.137.731.830.437.232.025.622.327.819.410.22.830.123.918.412.8

Table 4. RULER results by task (0–100) at 340M and 800M. Bold and underline mark the best and second-best scores within each group (super-linear or linear cost) and scale. Dashes denote unavailable results.

Prefill (Ktok/s)Decode (tok/s)
Model4k16k64k131k4k16k64k131k
TF++ (full attention)144.4123.848.826.234.734.734.720.5
SWA (sliding-512)143.5218.8248.6245.333.133.233.233.3
MoBA34.348.633.320.227.426.926.1OOM
NSA87.0121.489.865.215.815.715.815.8
GDN65.7141.8146.8146.225.525.725.625.4
NAtS-L56.1132.6107.683.722.522.722.222.9
Raven71.3137.7147.6148.924.724.824.824.8
FS30.922.310.9OOM19.018.718.2OOM
FS-L34.643.644.239.619.819.919.819.8
FS-B1.51.41.21.16.15.95.65.3

Table 6. Prefill and eager decode throughput at 340M scale on one A100-40GB (bf16, batch 1). OOM denotes the 40 GB memory limit.

FS-B searches M≤⌊N/s⌋=⌊N/32⌋M \le\lfloor N/s \rfloor= \lfloor N/32 \rfloor admitted cells per forest. Beams descend ⌈log⁡2M⌉\lceil\log_2 M \rceil levels; search, reranking and readout cost O(d[Wbwlog⁡M+Wbws+Ks])O(d[W_b^w \log M + W_b^w s + K_s]) per query, or O(Nlog⁡N)O(N \log N) per sequence. Fixed-width radix sorting adds O(Mdlog⁡22M)O(Md\log_2^2 M) construction work, giving O(Nlog⁡22N)O(N\log_2^2 N) combined algorithmic cost and O(Nd)O(Nd) archive space per head. Appendix § 13.§ 2 derives this bound and discloses repeated buffer copies in the reference streaming cache.

Experiments

Setup

We train LLaMA-style decoders ([37]) on FineWeb-Edu ([29]), using a 32k LLaMA tokenizer and a 4096-token context. The two FreeSolo configurations have 341M and 743M parameters, with pretraining budgets of 15B and 32B tokens. Training uses bf16 and AdamW ([25]); see Appendix § 9 for architecture and optimizer settings.

FS-L uses 0.73B/1.57B CPT tokens at 340M/800M, about 5% of pretraining; FS-B uses 0.42B at 800M (§ 3.4). All CPT uses 4096-token contexts. Main-table baselines use pretraining checkpoints. Appendix § 12.§ 4 adds selected 800M-scale baseline CPT controls, FS/FS-L comparisons at both scales, and seed and from-scratch studies.

Baselines. TF++ is the full-attention Transformer++ reference ([44]) with RoPE; SWA uses a 512-token RoPE window. NSA ([45]) and MoBA ([26]) select blocks for sparse token attention. GDN ([44]) uses a recurrent gated delta rule, and NAtS-L ([8]) combines GDN with retained-token softmax attention. InfLLM ([41]) adds inference-time retrieval to the TF++ checkpoint; we evaluate it on S-NIAH-1/2/3.

Raven ([1]) writes sparsely to key/value memory slots and reads them with softmax. We use the standalone 256-slot model as the linear-time Raven baseline. Raven-full has stronger published S-NIAH-2/3 recall, but its full NoPE attention costs O(N2)O(N^2), so we exclude it from this linear-time comparison. Its SWA hybrid is linear at fixed window size but has weaker recall than Raven-full ([1 Table 9]). Baselines share the corpus, tokenizer, and training context within each scale. The tables list parameter counts; Appendix § 9 records training budgets and settings.

Complexity. Table 1 reports algorithmic attention complexity at fixed head dimensions and budgets: O(N2/s)O(N^{2}/s) for FS, O(N2/b)O(N^{2}/b) for MoBA and NSA with a fixed block factor bb, O(Nlog⁡2N)O(N \log^{2} N) for FS-B including radix-sort construction, and O(N)O(N) for FS-L (§ 3.5), Raven, GDN, and SWA. NAtS-L costs O(NR)O(NR) for RR retained tokens, quadratic at a fixed retention fraction [8]. Our InfLLM lookup is exhaustive.

Evaluation. We evaluate NVIDIA RULER [16] with 100 examples per task and length, greedy decoding, and official 0–100 scores. Suite means cover 12 tasks at 2k/4k and 13 at 8k/16k, which add QA-2. We omit further long-context runs when a model’s retrieval has already failed at shorter extrapolation lengths. Appendix § 10 reports all task scores; Appendix § 9 gives the protocol.

Zero-shot extrapolation for long-context retrieval

Raven, NAtS-L, and GDN retain retrieval ability beyond the training context, whereas MoBA and NSA do not sustain recall in our evaluations (Table 1). FreeSolo’s advantage is clearest on the harder S-NIAH-2/3 tasks (Figure 1). At 800M and 16k, four times the training length, FS-L scores 81/40, compared with 26/0 for Raven and 72/34 for FS. FS-L reaches 53/13 at 64k, compared with 28/4 for FS and 0/0 for NAtS-L. Relative to FS, the 800M FS-L checkpoint trades some S-NIAH-1 recall for higher S-NIAH-2/3 scores at 16k–64k, although absolute accuracy still declines with length.

Figure 1. Zero-shot RULER extrapolation at 800M. Models train at 4k (dotted line); shading marks extrapolation. 100 examples per task and length.

FS-B’s two-forest search (§ 3.4) improves retrieval further: at 800M and 16k it scores 100/88/84 on S-NIAH-1/2/3, with a full RULER mean of 30.4.

FS and FS-L also outperform Raven and NAtS-L on the full RULER mean at both scales. At 800M/16k, the means are 23.1/22.3 for FS/FS-L, versus 12.8/2.8 for Raven/NAtS-L. The 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/0.5 for Raven/NAtS-L (Table 4). Some tasks, including variable tracking, remain difficult for all models even within the training context.

Matched continuations distinguish adaptation to pruning from additional training (Appendix § 12.§ 4). On the same 50 prompts at 800M/16k, FS continuation scores 84/38 on S-NIAH-2/3 and FS-L scores 80/42. Thus short CPT preserves much of the harder-task retrieval while reducing attention cost from quadratic to linear.

S-NIAH-1 tests retrieval over a much longer range. At 340M, FS maintains 98–100 through 256k and 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. Raven also extrapolates well on this task, scoring 99–100 through 131k and 92 at 256k.

Short-context quality

Table 2 reports eight zero-shot tasks with task definitions from the Language Model Evaluation Harness [13]. We use acc_norm for HellaSwag, ARC-c, and OBQA, and acc for the other tasks; Avg is their arithmetic mean. At 340M, FS averages 51.9 and FS-L 51.0, compared with 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. Both FS-L checkpoints retain similar short-context quality.

Empirical scaling

To verify linear scaling empirically, we increase context from 4k to 256k on one A100-40GB. FS-L’s attention buffers remain constant at 766 MiB for the 340M model and 1149 MiB for the 800M model. CUDA-graph decoding runs at about 89 and 75 tokens/s, respectively, including retention updates. Prefill throughput stays near 2.1–2.2K tokens/s, so processing time grows approximately linearly with input length.

These timings use bf16 parameters; Appendix § 11 compares precision and execution paths.

The masked implementation prefills at 34.6–44.2K tokens/s but keeps a growing KV cache. Training at 340M/4k is also slower than full attention: 98.4K versus 303K tokens/s across eight GPUs; faster kernels for pruning, gathering, and sparse readout are future work (Appendix § 11). Reducing PP to 16 cuts 340M attention storage to 320 MiB with similar decode speed, but accuracy varies non-monotonically with PP (Appendix § 12.§ 5).

Length extrapolation and learned retention

We analyze length generalization through an information-bottleneck view: FS routes through cell summaries, and FS-L also restricts memory before queries arrive (Appendix § 12).

Position dependence. Position handling affects how attention transfers to longer sequences ([31, 20, 3]). FS uses RoPE only within trained local offsets and NoPE for long-range token attention, so longer contexts introduce no untrained rotary offsets. The erf prior and local RoPE depend only on relative offsets, so shifting tokens, cells and query blocks together preserves the operator at fixed content vectors (Appendix § 12.§ 1). Added tokens can still introduce competing cells.

The information bottleneck in FS. The router identifies useful cells from their mean keys and maximum key norms. Token attention then reads the selected cells’ original keys and values. We hypothesize that routing through these summaries encourages recognizable keypoints.

Each head reads at most KsK_s token values, regardless of prefix length. RMSNorm rescales the readout but cannot remove interference from irrelevant values; sparse selection controls which values can contribute. On a shared 256k prompt, both variants at both scales select the needle cell over 166,000 tokens away (Appendix § 12.§ 2).

The additional bottleneck in FS-L. FS-L discards cells before future queries arrive. This can tolerate growing background when useful information remains concentrated in the retained state, but not dense, independently queryable facts (§ 3.4).

CPT adapts the model to this restriction. At 340M/4k, it recovers S-NIAH-1 from 62 under immediate pruning to 76–90 across runs (90 for the evaluated FS-L); unpruned continuations retain 100 (Appendix § 12.§ 4). FS-L retains 14.3% of eligible cells at 340M/16k; Appendix § 12.§ 3 separates retention, selection, and answering.

Budgets and ablations. PP sets the high-norm cells retained per head; KK sets the cells read per query and head. Larger KK cannot recover a pruned cell; larger PP expands availability but need not improve answers. We test adapted budgets and retrieval among several independently queryable facts (Appendix § 12.§ 5).

The local NoPE control changes both rotation and local bias. It preserves S-NIAH-1 extrapolation but reduces downstream accuracy from 51.9 to 38.3. Removing the long-range norm-weighted erf term retains strong S-NIAH-1 recall, worsens S-NIAH-2, and improves S-NIAH-3 (Appendix § 12.§ 1). Since gh≥erf⁡(2)≃0.9953g_h \ge\operatorname{erf}(2) \simeq0.9953 for eligible cells, the term acts mainly as a norm bonus, so we do not credit extrapolation to its distance dependence (Appendix § 12.§ 1).

Related Work

Selective recurrent memory. Mamba, Mamba-2, and GDN compress history in recurrent states [14, 6, 44]; GSA and Raven use softmax over memory slots [47, 1]. FS preserves token keys and values; summaries locate evidence. Mixture-of-Experts and Mixture-of-Memories route to parameter experts or recurrent states [34, 10]; FS routes to token cells.

Native block-sparse attention. MoBA [26] also routes by mean keys and reads selected tokens, always including the causal current block. NSA [45] learns compressed keys and values, derives selection scores from compressed attention, and includes compressed values in its readout. FS adds norm priorities and local-only RoPE to mean-key routing and selected-token readout. Training scores all eligible cells but reads only selected values. FS-L prunes before query matching; FS-B searches key hierarchies over the archive. Both reuse learned token keys across memory and search budgets without a learned chunk compressor.

Sparse token retrieval. Landmark Attention uses learned landmarks [28]; InfLLM uses representative tokens [41]. DRT [18] and RAMba [17] learn chunk retrieval and extrapolate beyond training length; routing scores weight their chunk outputs. FS hard-selects by fixed mean/norm summaries, then applies one softmax over selected tokens. Keys learn through token readout and local attention, without gradients through selection indices (Appendix § 13.§ 5).

KV-cache selection and pruning. QUEST selects pages using key bounds [36]. H₂O and SnapKV prune using observed attention [48, 24]; Devoto et al. (2024) retain low-norm keys. FS-L retains high-norm cells and adapts representations to that fixed rule through CPT. Retention needs neither a future query nor accumulated attention scores. NAtS-L combines retained-token attention with GDN [8]; its softmax history can grow. StreamingLLM keeps sinks and recent tokens [42]; FS-L can retain cells from anywhere in the prefix.

Sparsity and length generalization. ASEntmax studies sparse weights and extrapolation [39]; FS uses softmax over selected tokens. Position interpolation and YaRN rescale RoPE [2, 30]. RoPE/NoPE hybrids [43, 32] combine local RoPE and global NoPE layers; Kimi Linear and Kimi K3 combine recurrence with global NoPE and train on long contexts (Kimi Team, 2025; 2026). FS couples local RoPE with sparse NoPE retrieval within each head, training at short context throughout. Its long-range branch never encounters unseen rotary offsets.

Limitations

Experiments stop at the 800M scale. FS-L’s fixed retention budget can discard evidence before a query arrives. Its current CPT recovers S-NIAH-1 lost to immediate pruning, but the resulting 800M model has a lower RULER mean than base FS at every evaluated length (Table 12). Finding a CPT objective that improves the suite mean within FS-L’s memory budget remains open. Retrieval-weighted CPT, as used for FS-B, motivates this direction (Appendix § 13.§ 4). FS-B keeps growing memory and improves the RULER mean, but trails Raven-full on 800M multi-query and multi-value retrieval (Table 4). Learning its search policy, rather than using a fixed inference algorithm, is another direction for future work.

Continuation armΔ\Delta 2kΔ\Delta 4kΔ\Delta 8kΔ\Delta 16k
SWA, 743M, plain−1.4+0.4+0.2−0.2
Raven-full, 723M, plain−7.2−5.6−1.4+0.8
Raven, 726M, plain−2.2−1.0−2.8−1.9
NSA, 1128M, plain−1.2−2.2+0.3+0.1
FS, 743M, plain−1.6−1.3−1.00.0
FS, 743M → FS-L (pruning)−2.2−2.0−2.0−0.8
Single-forest W32 ablation, 743M, weighted+0.4+1.2+1.2+2.2

Table 12. Only FS-B’s weighted CPT improves the RULER mean at all four lengths. Suite-mean changes at 800M scale (+ CPT minus base, points, on the same prompts and protocols as Table 1; the base means are the Table 1 rows). Each “+CPT” arm continues the Table 1 checkpoint of the same architecture with plain next-token loss at the FS-L budget (1.57B tokens). The FS-L arm instead keeps the pruning loop in training at the same budget. The single-forest ablation uses FS-B’s recall-weighted CPT, spending 0.42B tokens (27%; Appendix § 13.§ 4), and compares the full-prefix width-32 read before and after CPT (base means 40.9/36.0/30.4/28.2). FS-B itself denotes the two-forest design of Table 1.

Conclusion

FreeSolo’s central thesis is that memory summaries need only locate evidence; the evidence can remain in original token values. Mean summaries of learned token keys support hierarchical search, maximum token-key norms support pruning, and local-only RoPE keeps distant retrieval free of unseen rotary offsets. FS-L and FS-B show how this representation supports bounded memory or a growing archive after short CPT, with zero-shot retrieval at 16k and single-needle recall at 256k from 4k training. This separates learning useful memory keys from choosing the capacity, search effort, and read bandwidth of the memory.

Hyperparameters and experimental settings

Architecture. FreeSolo uses LLaMA-style decoders with RMSNorm, SwiGLU, and a 32k LLaMA tokenizer. Both scales have 24 layers and 16 heads. The 341M model has width 1024 and head width 64; the 743M model has width 1536 and head width 96. Attention uses w=512w = 512, B=128B = 128, s=32s = 32, K=4K = 4, σh=4\sigma_h = 4, and λh=1\lambda_h = 1. FS-L retains P=64P = 64 norm-ranked cells and W=8W = 8 recent cells.

Pretraining. We train at 4096 tokens in bf16 with AdamW, cosine learning-rate decay, weight decay 0.1, gradient clipping at 1.0, and 524,288 tokens per step. The 341M FS run and FS-L from-scratch control use peak learning rate 3×10−43 \times10^{-4}, floor 3×10−53 \times10^{-5}, and 1000 warmup steps. The 743M FS run uses 4×10−44 \times10^{-4}, 4×10−54 \times10^{-5}, and 2000 warmup steps. The base FS checkpoints are at 28,000 steps for 341M and 60,000 steps for 743M, corresponding to 14,680,064,000 and 31,457,280,000 training tokens. We refer to these scales by the rounded 15B/32B budgets. The smaller run makes about 2.2 passes over a 6.7B-token FineWeb-Edu subset; the larger run uses less than one pass over a 39B-token corpus.

Continued pretraining. FS-L starts from FS with a fresh AdamW optimizer and pruning enabled. The learning rate warms up to 4×10−44 \times10^{-4} and decays toward 4×10−54 \times10^{-5}. At 341M, the schedule warms up for 150 steps with a 1500-step cosine horizon, and we use the step-1400 checkpoint, selected on S-NIAH-1 (100 examples); the 1500-step continuations in Appendix § 12.§ 4 show the run-to-run range. At 743M, it warms up for 300 steps and we use the final step-3000 checkpoint. These correspond to 734,003,200 and 1,572,864,000 additional tokens. Both use the same 4096-token context, tokenizer, and corpus as FS; restarting the data order revisits pretraining tokens.

RULER evaluation. We use NVIDIA RULER at commit c3f5e3b4, the LLaMA tokenizer, base prompt template, seed 42, and 100 examples per task and length. Generation caps are 128 tokens for NIAH, 30 for variable tracking, 120 for common-word extraction, 50 for frequent-word extraction, and 32 for QA. Decoding is greedy with EOS stopping. Non-QA tasks use string_match_all and QA uses string_match_part, on a 0–100 scale. FS-L runs its bounded cache (P=64P = 64, W=8W = 8) with CUDA-graph decoding, FP32 parameters and BF16 autocast on A100 GPUs with 40 GB memory. MoBA and NSA recompute the full forward pass for each generated token. Lengths 2k through 64k denote 2048 through 65,536 tokens; table labels 131k and 256k denote 131,072 and 262,144 tokens.

Downstream evaluation. The eight zero-shot tasks are HellaSwag, PIQA, ARC-easy, ARC-challenge, WinoGrande, OpenBookQA, SciQ, and BoolQ, evaluated with the LM Evaluation Harness.

Baselines. At 340M, NAtS-L uses 21 layers and 64-token routing blocks. Table 3 lists the evaluated pretraining checkpoint of every model; all runs use 4096-token sequences. Raven is standalone at both scales, with 21 layers, four heads, 256 memory slots, top-32 writes, and gate_logit_normalizer=8; its 726M model has width 1536. Raven-full is the variant with full NoPE attention (§ 4.1). TF++ uses full RoPE attention, SWA a 512-token RoPE window, and InfLLM the TF++ checkpoint. NSA uses the paper’s configuration (compression blocks of 32 tokens with stride 16, 16 selected 64-token blocks, a 512-token window, and four key/value heads). Its larger parameter counts come from the key and value token-compression MLPs, which hold 208M parameters at 340M and 467M at 800M; NSA is 172M and 385M larger than the matching MoBA or FreeSolo backbone. For 800M GDN, RULER uses fla 0.5.2 and transformers 5.14.1; downstream tasks use versions 0.3.2 and 4.56.1, respectively, with LM Evaluation Harness 0.4.13.

Model340M Steps340M Tokens800M Steps800M Tokens
FS28,00014.68B60,00031.46B
TF++28,61015.00B60,00031.46B
SWA28,00014.68B60,00031.46B
MoBA28,00014.68B––
NSA28,00014.68B57,50030.15B
GDN28,61015.00B61,03532.00B
NAtS-L28,61015.00B61,03532.00B
Raven28,61015.00B61,03532.00B
Raven-full28,61015.00B61,03532.00B

Table 3. Evaluated pretraining checkpoints. Steps and training tokens at 524,288 tokens per step. MoBA is trained only at the smaller scale. FS-L and FS-B continue from the FS checkpoints: FS-L adds 0.73B (340M) and 1.57B (800M) CPT tokens; FS-B uses the FS-L weights at 340M and 0.42B retrieval-weighted CPT tokens at 800M (Appendix § 13.§ 4).

Full RULER task breakdown

Table 4 reports individual task scores. FS and FS-L improve long-context retrieval, while multi-key retrieval, variable tracking, and word aggregation remain difficult. Raven retains strong S-NIAH-1 recall at 800M, while FS-L performs better on S-NIAH-2/3 and the suite mean. FS-B has the highest super-linear suite means from 4k on at both scales (Table 1) but remains below Raven-full on 800M MQ- and MV-NIAH.

MK, MQ, and MV denote multi-key, multi-query, and multi-value NIAH; VT denotes variable tracking; CWE and FWE denote common- and frequent-word extraction. QA-2 is unavailable at 2k/4k, so the mean covers 12 tasks there and 13 at 8k/16k; ties share a mark. NAtS-L’s linear-time grouping assumes a bounded retained-token count (§ 4.1).

Efficiency benchmarks

The streaming implementation maintains fixed attention buffers and nearly constant decode throughput from 4k to 256k. Absolute throughput still lags optimized local and recurrent baselines. We measure training, prefill, and decoding separately. These benchmarks use the models’ available optimized kernels; the results depend on batch size, software stack, and execution mode as well as architecture.

Training. Table 5 reports aggregate forward-and-backward throughput on eight A100-40GB GPUs, with 4096-token sequences, bf16, and torch.compile. All rows use batch 1 per GPU. FS-B changes inference only: it uses the FS-L weights at 340M, and its CPT at 800M trains with FS selection, so it has no separate row. Raven and NAtS-L are measured with the fla/flame (FSDP) harness (sharded parameters and optimizer states), so their peak memory is not directly comparable and is omitted, and their throughput carries some FSDP communication overhead. Bold and underline mark the best and second-best results (higher throughput, lower memory).

ModelTrain tok/sPeak mem (GiB)
TF++ (full attention)303K15.0
SWA (sliding-512)228K15.5
GDN158K21.6
MoBA140K27.0
NSA28K31.9
Raven140K–
NAtS-L126K–
FS99.3K16.5
FS-L98.4K16.6

Table 5. Training throughput and peak memory at 340M scale on eight A100-40GB GPUs. Raven and NAtS-L use the fla/flame FSDP harness; see the text.

GDN uses flash-linear-attention, NSA uses its Triton kernel, MoBA uses SDPA, and FreeSolo uses fused indexed-cell attention. FS, TF++, and SWA run on PyTorch 2.5; the other models use PyTorch 2.9. Sparse long-range retrieval reduces scaling cost, but has overhead at the short training context.

Inference. Table 6 uses one A100-40GB, bf16, and batch 1. Prefill is one forward pass over the prompt; decode processes one new token using each model’s KV cache or recurrent state. All table entries use eager execution, without torch.compile or CUDA-graph capture. TF++ uses FlashAttention-2 [5]; FreeSolo uses fused indexed-cell prefill and a fused sliding-window local branch. The other baselines use their native attention or recurrent kernels, with an incremental reference path for NSA decoding.

FS-L prefill stays nearly flat from 4k to 131k, where FS runs out of memory, while several baselines decode faster. FS-B runs to 131k within 19 GiB, but the measured reference uses unfused forest construction, traversal and reranking and repeatedly copies growing cache buffers (Appendix § 13.§ 2). Its eager throughput (1.1–1.5K tokens/s prefill, 5.3–6.1 tokens/s decode) reflects this implementation rather than the O(Nlog⁡N)O(N \log N) search; with CUDA-graph decode it reaches 19.1–19.8 tokens/s. The benefit is sustained long-context retrieval with bounded query scoring, rather than the highest throughput at every length. Table 6 uses an FS-L implementation that stores all KV and rescans priorities (§ 3.5); Table 7 measures the streaming cache.

Compilation and CUDA graphs. With torch.compile, FS-L prefill reaches 62.8–68.2K tokens/s from 4k to 131k, and CUDA-graph capture raises its decode to 94.4–94.7 tokens/s through 64k; with the same capture, SWA, GDN, and Raven decode at about 380, 275, and 262 tokens/s.

Bounded cache. The streaming implementation updates FS-L’s top-PP pool exactly from newly eligible cells. Let C\mathcal{C} be the eligible prefix cells and D\mathcal{D} those newly eligible at the next query-block boundary. Fixed priorities aca_c and a common deterministic tie rule give

TopP⁡(C∪D)=TopP⁡(TopP⁡(C)∪D).(15)\operatorname{TopP}(\mathcal{C} \cup\mathcal{D}) = \operatorname{TopP}(\operatorname{TopP}(\mathcal{C}) \cup\mathcal{D}). \tag*{(15)}

A discarded cell already has at least PP cells ahead of it, so adding cells cannot improve its rank. Once it also leaves the recent queue and local window, its KV can be evicted.

The implementation keeps absolute cell indices for relative scores and computes RoPE locally; position counters require O(log⁡N)O(\log N) bits. Prefill processes the transformer in chunks of 2048 tokens, with retention updates every B=128B = 128 tokens. Decode uses a fixed local ring and compact cell buffers; pool updates occur outside the CUDA graph and are included in the timing.

Table 7 uses both CPT checkpoints, bf16 parameters and activations, and FP32 rotary frequencies on one A100-40GB. We report the median of three runs after one warmup, with 257 decode steps per run. Attention-buffer bytes count distinct physical allocations across all heads and layers, including retained, recent, local, pending, and graph input buffers. The implementation keeps duplicate compact buffers, so this exceeds the size of one packed retained set. Peak allocated GPU memory also includes parameters, activations, and graph workspace; input/output token IDs are excluded from the attention-buffer count.

LengthAttention buffers (MiB)Peak (GiB)Prefill (Ktok/s)Decode (tok/s)
340M scale
4k766.21.712.2089.3
64k766.21.742.2189.4
256k766.21.772.1788.3
800M scale
4k1148.82.962.0975.2
64k1148.82.982.1475.1
256k1148.83.022.1474.1

Table 7. Bounded FS-L inference. Throughput uses CUDA-graph decode; peak memory is the maximum across three trials.

This establishes bounded attention storage with linear streaming work, at a substantial prefill cost relative to Table 6. Both implementations apply the same pruning rule, but precision and reduction order can change generated answers. On 25 prompts per S-NIAH task at 4k and 16k, bounded execution at 340M matches all 150 correctness decisions of the masked implementation (FP32 parameters, bf16 autocast). The bf16 CUDA-graph configuration used for timing matches 60/60 decisions at 340M and 59/60 at 800M on ten prompts per task and length, and 58/60 for the adapted P=16P = 16 and P=32P = 32 checkpoints; both scales retrieve all three tested 256k S-NIAH-1 examples. FS-L results in Table 1 and Table 4 use the bounded cache on 100 examples per cell, with FP32 parameters and bf16 autocast (Appendix § 9). The FS-L continuation and adapted-budget accuracies in Appendices § 12.§ 4 and § 12.§ 5 also use bounded execution. The routing probes and eligible-prompt answer counts in Appendix § 12.§ 3 use the full-history masked implementation, which applies the same pruning rule without evicting stored KV.

Theory and ablation studies

In this section, we present additional theoretical analysis, ablation studies, and exploratory tests and visualizations (tagged Probe). The main findings are:

Ablations of short-range and long-range components (Appendix D.1).

  1. (Ablation) Short-range RoPE is crucial for commonsense accuracy; single-needle length extrapolation persists without it.

  1. (Theory, Probe) The long-range erf term acts mainly as a key-norm bonus; its residual distance dependence rarely changes selection.

Cell summaries and reading distance (Appendix D.2).

  1. (Theory, Probe) Cell summaries need only locate useful evidence: the readout accesses the selected tokens’ original values directly, including needle reads over 166k tokens away in the traced prompt.

  1. (Theory) Sparse readout limits interference from unrelated values; readout normalization alone cannot undo their mixing.

Norm pruning and retrieval coverage (Appendix D.3).

  1. (Probe) Norm pruning substantially reduces query-scoring work: FS-L retains about one-seventh of eligible cells at 16k.

  1. (Probe) On harder retrieval tasks, query-dependent selection remains a bottleneck even when the answer source survives pruning.

Continued pretraining (Appendix D.4).

  1. (Ablation) Short CPT helps FS-L adapt to the pruning constraint, recovering much of the S-NIAH-1 accuracy lost when pruning is applied without adaptation.

  1. (Ablation) Harder-task changes cannot be attributed to pruning alone: they vary across seeds and also occur with unpruned continuation.

  1. (Ablation) Retrieval-weighted CPT improves the RULER mean of the full-prefix single-forest ablation (W32) at every evaluated length using only short-context training.

Retention budgets and multi-fact retrieval (Appendix D.5).

  1. (Theory) Sustaining high accuracy when retrieving independently queryable random facts requires storage to grow with their number.

  1. (Ablation) Adapted models do not improve monotonically with retention capacity; a larger pool is not sufficient for better retrieval.

  1. (Probe) Multi-fact failures extend beyond pruning: unpruned and full-attention models also confuse values from the same prefix.

Ablations of short-range and long-range components

The ablations separate short-context quality from length extrapolation: changing the local branch sharply affects downstream accuracy, while distant retrieval persists. In long-range routing, the erf term acts mainly as a norm bonus at s=32s = 32 and σh=4\sigma_h = 4.

Position dependence. Local scores use qiTR(j−i)kj/d\mathbf{q}_i^{\mathsf{T}}\mathbf{R}(j-i)\mathbf{k}_j/\sqrt{d} with 0≤i−j≤w0 \le i-j \le w. Training at length L>wL > w covers every explicit rotary offset used at evaluation. Long-range token scores are NoPE. The cell prior gh(i−pc)g_h(i-p_c) is unchanged by shifting query and cell coordinates together, and approaches one with distance. At fixed content vectors and a consistent tie rule, translating tokens, cell partitions, query blocks, and causal boundaries together by a multiple of BB leaves the operator unchanged. These properties avoid new rotary offsets; they do not make contextual representations invariant to added tokens.

Trained ablations. We train both controls with the 341M FS recipe, 4k context, and 15B training tokens. SR-NoPE (short range without RoPE) replaces local RoPE with unrotated queries and keys and adds a log⁡erfc⁡(Δ/(2σh))\log\operatorname{erfc}(\Delta/(2\sigma_h)) bias with Δ=i−j\Delta= i-j, retaining the 512-token window; it therefore changes both rotation and local bias. LR-content-only keeps local RoPE and removes the entire λhacerf⁡((i−pc)/(2σh))\lambda_h a_c\operatorname{erf}((i-p_c)/(2\sigma_h)) routing term, so long-range routing uses the query–mean-key similarity alone.

ModelS-NIAH-12k4k8k16k32k64k131kS-NIAH-22k4k8k16kS-NIAH-32k4k8k16k
FS99991001009810098100774117581470
SR-NoPE100100100100100100100989071294723130
LR-content-only95979697959596805738147125111

Table 8. RULER ablations at 340M (0–100). Bold and underline mark the best and second-best scores, including ties.

ModelHellaS.PIQAARC-eARC-cWinoG.OBQASciQBoolQAvg
FS38.966.857.625.950.932.481.261.151.9
SR-NoPE28.455.736.923.749.225.648.238.738.3
LR-content-only39.366.157.126.952.831.883.260.052.1

Table 9. Downstream accuracy of the ablations at 340M (0–100), using the metrics in Table 2.

ModelParamsHellaS.PIQAARC-eARC-cWinoG.OBQASciQBoolQAvg
GDN335M39.266.855.828.251.933.083.259.852.2
FS341M38.966.857.625.950.932.481.261.151.9
TF++335M39.266.056.228.150.632.881.559.651.8
Raven357M37.665.255.827.651.232.280.660.851.4
SWA341M38.866.256.426.750.630.880.461.151.4
FS-L341M38.466.355.025.351.031.479.860.451.0
FS-B341M38.466.355.025.351.031.479.860.351.0
NAtS-L380M39.967.650.027.452.334.075.159.750.8
MoBA341M33.361.843.426.251.329.065.152.245.3
NSA513M32.362.643.824.951.928.866.445.044.5
≈800M scale
TF++743M48.970.963.932.954.334.487.461.956.8
FS743M49.570.064.631.756.034.486.758.856.5
Raven-full723M46.969.464.533.654.136.885.960.456.5
GDN694M47.469.164.832.853.837.088.158.256.4
SWA743M49.668.763.531.655.134.485.261.856.2
FS-B743M49.670.063.831.756.033.485.959.156.2
NSA1128M47.468.163.831.754.332.488.861.456.0
FS-L743M48.169.062.631.853.633.685.457.555.2
NAtS-L793M44.868.263.029.052.837.485.359.255.0
Raven726M45.868.763.431.754.035.884.453.254.6

Table 2. Table 2: Zero-shot downstream accuracy (0–100). Rows are ordered by average within each scale; bold and underline mark the best and second-best scores.

SR-NoPE preserves S-NIAH-1 extrapolation and improves S-NIAH-2, but lowers average downstream accuracy from 51.9 to 38.3. The local FS configuration therefore improves language-model quality without being required for single-needle retrieval. LR-content-only retains 95–97 on S-NIAH-1 and a downstream average of 52.1, while worsening S-NIAH-2 and improving S-NIAH-3. The norm bonus is therefore not needed for single-needle extrapolation; it shifts S-NIAH-2 and S-NIAH-3 in opposite directions.

A saturated norm prior. Every eligible cell satisfies (c+1)s≤bi≤i(c+1)s \le b_i \le i, so its center pc=(c+12)sp_c = \left(c+\frac{1}{2}\right)s obeys i−pc≥s/2i-p_c \ge s/2. Write the content term as κic=qiTkˉc/d\kappa_{ic} = \mathbf{q}_i^{\mathsf{T}}\bar{\mathbf{k}}_c/\sqrt{d}. For λh≥0\lambda_h \ge0, define the constant-gate score ric∞=κic+λhacr_{ic}^{\infty}=\kappa_{ic}+\lambda_h a_c. Then

0≤ric∞−ric=λhac erfc⁡(i−pc2σh)≤λhac erfc⁡(s4σh).(16)0 \leq r_{ic}^{\infty}-r_{ic}=\lambda_h a_c\,\operatorname{erfc}\left(\frac{i-p_c}{2\sigma_h}\right)\leq\lambda_h a_c\,\operatorname{erfc}\left(\frac{s}{4\sigma_h}\right). \tag*{(16)}

At s=32s=32 and σh=4\sigma_h=4, erfc⁡(2)≃0.004678\operatorname{erfc}(2)\simeq0.004678: the difference is at most 0.468% of the norm bonus. This is not a relative bound on the total score, which can include cancellation with the content term. Larger offsets further reduce the difference.

For a query ii and a fixed available set with more than KK cells, let γ∞\gamma_{\infty} be the gap between the KKth and (K+1)(K+1)st constant-gate scores and δmax⁡=max⁡cλhacerfc⁡((i−pc)/(2σh))\delta_{\max}=\max_c\lambda_h a_c\operatorname{erfc}((i-p_c)/(2\sigma_h)). If γ∞>δmax⁡\gamma_{\infty}>\delta_{\max}, replacing the constant gate by ghg_h leaves the top-KK set unchanged: a selected score falls by at most δmax⁡\delta_{\max}, while an unselected score cannot increase. The raw-token readout is then unchanged too. Equivalently, routing can change only when γ∞≤δmax⁡\gamma_{\infty}\leq\delta_{\max}. It applies to FS’s full prefix and FS-L’s retained set at fixed representations.

Fixed-state routing controls. On the 16k native traces described in Appendix D.3, replacing ghg_h by one keeps 99.998% of the native top-KK cells in the top-KK set in both 340M models. Removing the entire bonus instead preserves only 53.9/14.0/14.7% in FS and 73.3/32.5/32.7% in FS-L on S-NIAH-1/2/3. The norm bonus changes routing substantially, whereas its residual distance dependence rarely changes the selected set.

Cell summaries and reading distance

FS imposes a bottleneck on cell selection: a query selects cells using mean keys and maximum key norms, then reads the selected cells’ original keys and values. The routing summary need only locate useful evidence; it need not contain the answer. Sparse readout also bounds how many token values can interfere, independently of their distance from the query.

A keypoint can mark a cell. If a cell contains one nonzero key k⋆\mathbf{k}_{\star}, its mean is k⋆/s\mathbf{k}_{\star}/s, while ac=∥k⋆∥2a_c=\lVert\mathbf{k}_{\star}\rVert_2. The content match is diluted by 1/s1/s, but the norm bonus preserves the cue’s magnitude. One key can thus make a cell visible to the router. A high-norm distractor receives the same bonus, so query alignment still decides which cells are read.

Why sparse readout matters after RMSNorm. Let y=∑j∈Siℓijvj\mathbf{y}=\sum_{j\in S_i}\ell_{ij}\mathbf{v}_j, Y=∑j∈SiℓijY=\sum_{j\in S_i}\ell_{ij}, and g\mathbf{g} be the readout RMSNorm gain. Then

oilr=g⊙y∥y∥22/d+ϵY2.(17)\mathbf{o}_i^{\mathrm{lr}}=\frac{\mathbf{g}\odot\mathbf{y}}{\sqrt{\lVert\mathbf{y}\rVert_2^2/d+\epsilon Y^2}}. \tag*{(17)}

When ∥y/Y∥22/d≫ϵ\lVert\mathbf{y}/Y\rVert_2^2/d\gg\epsilon (ϵ=10−8\epsilon=10^{-8}), the scalar softmax denominator cancels. Normalization therefore removes amplitude dilution, but irrelevant values can still alter the output direction. Sparse selection restricts which values enter this sum, rather than merely reducing its softmax denominator. This distinction matters when relating FreeSolo to analyses of attention dilution and sparse length generalization [4] (Vaslyenko et al. 2026).

Reading the needle. Figure 4 traces 340M FS and FS-L while answering the same 256k S-NIAH-1 prompt. Both generate the correct value, 2338687, from tokens 95,394–95,400 in a 262,010-token input. For a direct comparison, we display the same head in both models: layer 10, head 15, the head that maximizes the smaller of the two models’ mean needle attention during the first answer. These are selected retrieval examples, not averages across heads or prompts.

Figure 4. Retrieving a number at 256k (340M). Selected cells, routing scores, prompt text, and attention during generation. Both answers are correct.

The upper plots show the four cells read when predicting the first value token. A stem’s height is the cell’s total long-range softmax weight; orange marks the cell containing the value. The letters link each read to its decoded 32-token text, including unrelated cells. Each row gives the routing score ricr_{ic} from Eq. (7) for the models that selected the cell. These scores include the content term and erf prior; they are distinct from the attention weights plotted above. The lower plot follows attention to the exact source value as each answer token is predicted, excluding other tokens in its cell. In this example, the needle cell receives 89%/96% of the displayed head’s long-range softmax weight in FS/FS-L at the first value token. Both heads continue to read the distant value during generation. These weights precede readout RMSNorm and branch mixing; they do not establish a causal contribution to the answer.

Read distance across the prompt. Unlike Raven, which measures memory by the tokens written to recurrent slots [1 Definition 4 and Figure 8], we measure where queries read. Selecting cell cc at query ii gives backward distance i−pci - p_c tokens. Figure 5 plots this distance against query position for the 800M checkpoints on the same 256k prompt. Both axes use tokens (1k=10241\mathrm{k} = 1024) and 2048-token bins. Color shows the fraction of cell selections per query bin, aggregated over the layer’s 16 heads, on a logarithmic scale. White denotes zero selections; gray lies beyond the available prefix.

Figure 5. Long-range read distance at 800M on one 256k S-NIAH-1 prompt. Orange guides mark the needle position and its distance from each query.

The needle occupies cell 2981, centered at p⋆=95,408p_{\star} = 95{,}408. The orange dotted line marks its position; the dashed diagonal follows its distance i−p⋆i - p_{\star} from later queries. Diagonal bands indicate repeated access to fixed earlier cells. Both checkpoints read the needle cell in layer 1. At the final prompt query, 166,601 tokens from its center, layer 24 selects it in 6/16 FS heads and 2/16 FS-L heads. Over the final 2048 queries, averaging all layers and heads, 93.6% of FS selections and 93.1% of FS-L selections lie at least 131,072 tokens behind the query. These counts show direct access to distant cells, without measuring their attention weights.

Retrieval on harder tasks. Figure 6 and Figure 7 show selected successful S-NIAH-2/3 examples at 64k/32k with the same 800M checkpoints. Each pair uses the same prompt and needle position; both models generate the correct value. The common-head rule above selects layer 11, head 6 for both tasks. For S-NIAH-2, the needle cell near token 16,217 receives 72%/66% of this head’s long-range softmax weight in FS/FS-L at the first value token. For S-NIAH-3, the cell near token 7,591 receives 47%/83%. The displayed text shows the number or UUID prefix alongside the selected essay excerpts. The UUID spans two cells; only its first cell is read at the snapshot shown, and the next cell is selected later during generation. The lower plots follow attention to the full source value across the answer.

Figure 6. Retrieving a number at 64k (800M). Selected cells, routing scores, prompt text, and attention to the S-NIAH-2 value. Both answers are correct.

Figure 7. Retrieving a UUID at 32k (800M). Selected cells, routing scores, prompt text, and attention to the S-NIAH-3 value. Both answers are correct.

Norm pruning and retrieval coverage

We measure how much norm pruning reduces the available prefix and how it affects retrieval. Key norm is a learned pruning heuristic: a smaller-norm cell can still be relevant to a future query. We therefore evaluate source access, selection coverage, and answer accuracy separately.

Separate retention from selection. A non-recent cell survives pruning when fewer than PP cells outrank it by aca_c. It is then read only if fewer than KK retained cells outrank it by ricr_{ic}. Raising KK cannot recover a cell already pruned. At fixed scores, retaining every FS top-KK cell preserves its selected-token readout, but partial overlap need not preserve the answer.

Probe protocol. We trace the FS and FS-L checkpoints of Table 1 at both scales on 50 examples per S-NIAH task at 2k/4k/8k/16k, totaling 600 prompts per model. Each trace covers all 24 layers and 16 heads on the final 16 prompt positions. The forward pass uses each model’s native routing. Alternative scores are computed on those same representations without changing the forward pass. Source-access measurements exclude prompts whose answer source overlaps the local window of any observed query. We average head/query rates within each prompt, then average prompts; heads are not independent observations.

Source availability and selection. Table 10 distinguishes source retention from query-dependent selection. FS keeps the full prefix, so its retention column applies the FS-L rule offline to FS keys. Its selection column uses native FS routing. FS-L’s columns both describe its native operation. These probes and the eligible-prompt answer counts below use the full-history masked implementation of FS-L, rather than the bounded cache used for the main accuracy tables.

TaskPromptsSource retained (%) — FS (offline)Source retained (%) — FS-LSource selected (%) — FSSource selected (%) — FS-L
340M scale
S-NIAH-14722.3127.9838.1517.55
S-NIAH-25018.3419.871.271.30
S-NIAH-34724.6425.762.492.65
800M scale
S-NIAH-14723.0722.0329.2114.99
S-NIAH-25016.2217.032.002.08
S-NIAH-34726.2926.423.553.52

Table 10. Source-cell availability and selection at 16k. The source is the cell containing the answer value. Rates average over all heads and the final 16 prompt positions within each prompt, then over prompts; FS (offline) applies the FS-L retention rule to FS keys.

At 340M, under the same norm rule, FS-L improves source availability by 5.66/1.54/1.11 percentage points on S-NIAH-1/2/3 (computed before rounding). Paired-prompt bootstrap 95% intervals are [5.05, 6.31], [1.14, 1.93], and [0.72, 1.49] (5000 resamples). These compare the two checkpoints and do not separate pruning adaptation from additional training. Native source selection is substantially lower in FS-L on S-NIAH-1 and similar on the harder tasks. Among head/query pairs where the source survives, FS-L selects it in 63.8/6.6/10.3% of cases, averaging the conditional rate within each prompt. Source access does not guarantee a correct answer: on the same eligible prompts, greedy answers are correct on 47/47, 9/50, and 0/47 for FS and 40/47, 9/50, and 0/47 for FS-L on S-NIAH-1/2/3 at 16k.

At 800M, the corresponding source-availability changes are −1.04/0.82/0.13 percentage points, with paired 95% intervals [−2.06, 0.07], [0.47, 1.16], and [−0.35, 0.64]. The increase at 340M therefore does not generalize uniformly across scales. Native S-NIAH-1 source selection is again lower in FS-L, while S-NIAH-2/3 selection changes little. FS-L selects a surviving source in 69.3/12.3/13.4% of eligible head/query pairs, averaging within each prompt. On S-NIAH-2/3, FS selects the source in only 1.3–3.6% of head/query pairs and FS-L selects a retained source in 6.6–13.4%, so selection rather than retention limits the harder tasks.

Compression. For each head, define the retained fraction ηi=∣Ai∣/∣Ci∣\eta_i = |A_i|/|C_i|. At 4k/8k/16k, native FS-L retains 58.8/29.0/14.3% of eligible cells across these probes, corresponding to 1.7/3.4/7.0× reductions in cells available for scoring. All lengths use P=64P = 64 and W=8W = 8. These fractions concern cell counts; Appendix § 11 measures physical storage.

Continued pretraining

CPT recovers much of the S-NIAH-1 accuracy lost under immediate pruning. Harder-task changes also occur with unpruned continuation and vary across seeds. These results support adapting an FS checkpoint to the pruning constraint through short CPT.

Learning with hard indices. As in § 3.3, top-PP and top-KK indices receive no loss gradient, and we use no auxiliary retention loss or straight-through estimator. A key receives no gradient through an access that excludes it, and the remaining gradients need not increase its norm; scores and norm ranks change only through the shared projections and contextual states.

CPT starts from FS’s retrieval representations and keeps pruning in the loop at the same 4096-token context. The constraint already binds during training: the last query block has 124 eligible cells, exceeding P+W=72P + W = 72. Optimization settings are in Appendix § 9.

Continuation controls. Table 11 compares pruning and continuation at 340M using the same first 50 examples per task at 4k. Immediate pruning applies FS-L’s P=64P = 64 retention rule without adaptation. The seeded controls start from the same FS checkpoint with a fresh optimizer, the same corpus and schedule, and 1500 steps (0.786B tokens); FS uses full-prefix routing and FS-L keeps pruning in training and evaluation. The main FS-L checkpoint uses 1400 steps. We repeat seed 42 with the same data order and run seed 43 once; changing the seed also changes data sampling.

ModelS-NIAH-1S-NIAH-2S-NIAH-3
FS base1007414
Immediate pruning627214
FS-L906414
FS, seed 42 (run 1)1005016
FS, seed 42 (run 2)1005220
FS, seed 43100746
FS-L, seed 42 (run 1)824412
FS-L, seed 42 (run 2)764618
FS-L, seed 4382828

Table 11. Pruning recovery and seed variation at 340M. Accuracy (%) on 50 shared prompts per task at 4k, the training context. FS-L is the 1400-step checkpoint of Table 1; seeded rows use 1500 CPT steps without (FS) or with (FS-L) pruning.

At 4k, immediate pruning reduces S-NIAH-1 from 100 to 62. FS-L recovers 90, while the seed-42 adapted runs recover 20 and 14 percentage points (paired-prompt bootstrap 95% intervals [4, 36] and [0, 28]). All three unpruned continuations retain 100. S-NIAH-2 declines under seed 42 even without pruning, whereas seed 43 reaches 82 with pruning versus 74 without it. Thus CPT supports S-NIAH-1 recovery, but harder-task changes vary across seeds and also occur without pruning. Intervals use 5000 prompt resamples and do not estimate seed uncertainty.

Harder-task gains also occur without pruning at 800M: after 3000 CPT steps (1.57B tokens), FS’s 16k S-NIAH-2/3 accuracy rises from 72/32 to 84/38 on 50 shared prompts per task.

Budget-matched continuation of unchanged architectures. To assess the effect of additional training alone, Table 12 reports selected 800M-scale baselines and FS continued from their Table 1 checkpoints with plain next-token loss. These controls match FS-L’s 3000 updates of 524,288 tokens each (1.57B total), using FineWeb-Edu at 4096-token context (Appendix § 9). The table also includes a separate single-forest width-32 ablation of FS-B’s recall-weighted recipe: 1600 updates of 262,144 tokens each (0.42B total, 27% of the matched budget), at the same context length (Appendix § 13.§ 4). Each before/after pair uses identical prompts and task sets: means cover 12 tasks at 2k/4k and 13 at 8k/16k, following the protocol of Table 1.

Plain CPT does not improve the baselines or unpruned FS consistently across all evaluated lengths. Only FS-B’s recall-weighted CPT improves the RULER mean at all four lengths in Table 12, as measured by the single-forest width-32 ablation: 40.9/36.0/30.4/28.2 becomes 41.3/37.2/31.6/30.4. FS-L recovers much of the S-NIAH-1 accuracy lost under immediate pruning (Table 11), but its suite mean remains below base FS at every length in Table 12.

Training from scratch. CPT gives a higher RULER mean than training from scratch at all four lengths (Table 13). The gain comes from S-NIAH-2/3, with a tradeoff on S-NIAH-1 and downstream accuracy.

RecipeS-NIAH-1S-NIAH-2S-NIAH-3RULER meanDown.
2k4k8k16k2k4k8k16k2k4k8k16k2k4k8k16kavg
From scratch10097989378498353113027.819.211.79.652.2
CPT998890879970342070179132.421.615.510.751.0

Table 13. FS-L training recipes at 340M (0–100). Both use pruning during evaluation, with 100 examples per RULER task and length. Bold marks the better recipe.

At 16k, the mean rises from 9.6 to 10.7, while S-NIAH-1 falls from 93 to 87. The eight-task downstream average falls from 52.2 to 51.0.

At 800M, training with pruning from scratch reaches a downstream average of 56.8 but S-NIAH-1 scores of only 32, 16, 8, and 0 at 2k, 8k, 16k, and 32k (25 examples), whereas CPT retrieves well (Table 1); we therefore use CPT at both scales.

Retention budgets and multi-fact retrieval

FS-L must retain information before knowing which question will be asked. The adapted budget sweep measures the resulting accuracy–memory tradeoff. The multiple-question test checks whether the models can answer questions about several facts near the training length.

The question distribution sets the budget. A small retained set can cover likely future questions when useful information is concentrated in a few cells. Consider instead FF independent key–value facts in separate cells, with a later question choosing one uniformly. Keeping m≤Fm \le F source cells gives direct access to only m/Fm/F of the possible targets. Contextual representations can copy information between cells, so this ratio is not an answer-accuracy bound. The accessible state includes all heads and layers, local buffers, and their contextual representations.

Compression does not remove this limit. If the FF values are independent and uniform over VV outcomes, the question reveals only which value to retrieve, and the state holds bb bits, Fano’s inequality bounds the mean accuracy by pˉ≤(1+b/F)/log⁡2V\bar{p} \le(1 + b/F)/\log_{2} V; any fixed accuracy with pˉlog⁡2V>1\bar{p}\log_{2} V > 1 therefore needs b=Ω(F)b = \Omega(F). This motivates testing memory budgets and preserving more cells when information is dense. It does not identify the bottleneck in a trained model: a wrong answer can reflect lost information, failed routing, or failure to use available evidence.

Adapted retention budgets. From the same base FS checkpoint, we adapt with P=16P = 16 and P=32P = 32, keeping W=8W = 8, K=4K = 4, and the same 1500-step schedule. Each model evaluates with its training budget on the same 50 prompts (Table 14). At 2k, S-NIAH-1 falls from 100 at P=64P = 64 to 98 at P=32P = 32 and 84 at P=16P = 16, but accuracy is not monotone in PP: at 16k, P=64/32/16P = 64/32/16 score 74–80/66/68, using the two seed-42 controls at P=64P = 64. S-NIAH-2/3 do not improve consistently with PP. These independently adapted operating points measure a training–memory tradeoff, not the effect of changing the budget in one fixed model. Only P=64P = 64 has repeated continuations. The local and temporary buffers also contribute to physical state, so changing PP by a factor of four does not change total memory by that factor.

ModelS-NIAH-1 2kS-NIAH-1 4kS-NIAH-1 8kS-NIAH-1 16kS-NIAH-2 2kS-NIAH-2 4kS-NIAH-2 8kS-NIAH-2 16kS-NIAH-3 2kS-NIAH-3 4kS-NIAH-3 8kS-NIAH-3 16k
P=16P = 1684646868100562414561442
P=32P = 329878726696503210742062
P=64P = 64, run 11008282809844222661282
P=64P = 64, run 21007670749646202581882

Table 14. Adapted retention budgets at 340M. Each model trains and evaluates with its stated PP.

Figure 8 relates these scores to the allocated attention buffers of the streaming cache (Table 15, protocol of Appendix § 11): reducing PP fourfold gives a 2.4× reduction in total buffers (which do not depend on length), while decode stays at 88–89 tokens/s. The P=64P = 64 row of Table 15 uses the Table 1 checkpoint, while the P=64P = 64 accuracies in Figure 8 average the two seed-42 continuations.

Figure 8. Accuracy versus attention storage at 340M. The P=64P = 64 points show the mean and range of two seed-42 continuations.

PPBuffers (MiB)Peak (GiB)Prefill (Ktok/s)Decode (tok/s)
16320.01.342.1388.4
32468.81.492.1988.8
64766.21.772.1788.3

Table 15. Retention budget and bounded inference at 340M, 256k.

Several facts at fixed context. Each synthetic prefix holds FF distinct key–value facts with seven-digit values, each outside the final 528 prefix tokens. The question is revealed only after the prefix, and each question continues an independent copy of the prefix state. We generate 16 tokens greedily and score whether the target value appears, with 50 prefixes per condition, querying every fact for F≤8F \le8 and eight sampled facts for F=16F = 16. Prefixes contain 4253–4277 tokens at 340M and 3946–3971 at 800M, where prefix, question and answer fit within 4096 tokens.

FS, FS-L, and FS-B pass a 90% single-fact threshold at both scales, but no model passes it with two or more facts (Table 16); FS-B scores highest at 340M; at 800M with four or more facts, full-attention TF++ and

Facts per prefix124816
Questions50100200400400
340M, 4253–4277 prefix tokens
FS9441197.752.75
FS-L9048218.003.25
FS-B1005628.513.04.25
800M, strictly within 4096 tokens
FS100492611.57.25
FS-L965321104
TF++8856382219.75
Raven1005728.592
FS-B100523216.58.75
Raven-full1006633.521.7513

Table 16. Multiple-question retrieval. Accuracy (%) on shared prefixes: an answer is correct if the target value appears in 16 greedy tokens; 50 prefixes per condition. Bold and underline mark the best and second-best score within each scale, including ties. FS-B prefills each question afresh; at 340M this raises FS and FS-L by about 2 points relative to the shared-prefix rows.

Raven-full lead instead. The decline also occurs with unpruned access, with full-attention TF++ and with Raven and Raven-full, and at 800M entirely within the training context, so it is not a pruning or length-extrapolation limit alone. At 800M with two facts, most wrong answers contain another value from the same prefix (42/47 for FS-L, 46/51 for FS, 48/48 for FS-B, 36/43 for Raven and 36/44 for TF++), consistent with confusion among stored facts. Because unpruned FS and full-attention TF++ decline in the same way, this test measures interference among facts near the training length rather than the retention limit above.

FS-B details

Section 3.4 defines FS-B. This appendix explains how the forests are built and searched, what they cost, and the CPT recipe, and relates FS-B to chunk and hierarchical retrieval.

Streaming forests

Causal availability. Cells contain s=32s = 32 tokens and query blocks contain B=128B = 128 tokens. At each block boundary, cells completed before that boundary are admitted to the forests by Eq. (10). The forests and their summaries then stay fixed throughout the block, while each token searches independently. Prefill and cached decoding use the same block-boundary availability as FS training. Filtering a cell from the second forest does not remove it from the first, nor its tokens from the local window. The threshold τℓh\tau_{\ell h} is fixed per checkpoint, so the second forest need not hold half of a particular prefix.

Chunks. Fix one head and one forest at a block boundary, and let c1,…,cMc_1,\ldots,c_M be its admitted cells in arrival order, with mean keys kˉc\bar{\mathbf{k}}_c, key norms aca_c and positions pcp_c (Eq. (5)). Write the binary decomposition

M=∑t=1r2ktwithk1>⋯>kr.M = \sum_{t=1}^{r} 2^{k_t} \quad\text{with} \quad k_1 > \cdots> k_r.

The active chunks are the consecutive runs

Gt={cj:ot<j≤ot+2kt},ot=∑u<t2ku,(18)G_t = \{c_j : o_t < j \le o_t + 2^{k_t}\}, \qquad o_t = \sum_{u<t} 2^{k_u}, \tag*{(18)}

so older cells sit in larger chunks; 13=8+4+113 = 8 + 4 + 1 gives {c1,…,c8}\{c_1,\ldots,c_8\}, {c9,…,c12}\{c_9,\ldots,c_{12}\} and {c13}\{c_{13}\}. A chunk never changes once complete, so its tree is built once and reused until two equal chunks merge into the next larger one.

Splitting a chunk. Each node vv holds a cell set C(v)\mathcal{C}(v) of size nvn_v; the root of GtG_t holds all of GtG_t. A node with nv>1n_v > 1 cells centers their mean keys, xc=kˉc−μv\mathbf{x}_c = \bar{\mathbf{k}}_c - \boldsymbol{\mu}_v, and estimates a principal direction with two power iterations started at the farthest cell:

u(0)∝xc⋆,c⋆=arg⁡max⁡c∈C(v) ∥xc∥2,u(t+1)∝∑c∈C(v)(xcTu(t))xc,t=0,1.(19)\mathbf{u}^{(0)} \propto\mathbf{x}_{c^\star}, \qquad c^\star= \underset{c \in\mathcal{C}(v)}{\arg\max}\,\lVert\mathbf{x}_c \rVert_2, \qquad\mathbf{u}^{(t+1)} \propto\sum_{c \in\mathcal{C}(v)} \left(\mathbf{x}_c^{\mathsf{T}}\mathbf{u}^{(t)}\right)\mathbf{x}_c, \qquad t = 0,1. \tag*{(19)}

Cells are sorted by xcTu(2)\mathbf{x}_c^{\mathsf{T}}\mathbf{u}^{(2)}; the first ⌈nv/2⌉\lceil n_v/2\rceil form the left child and the rest the right child. Recursion stops at single cells, so a chunk of 2k2^k cells gives a perfect binary tree of height kk whose leaves are ordered by content rather than position.

Node summaries. Every chunk-tree node stores

μv=1nv∑c∈C(v)kˉc,ρv=max⁡c∈C(v)∥kˉc−μv∥2,Av=max⁡c∈C(v)ac,pvmin⁡=min⁡c∈C(v)pc,(20)\boldsymbol{\mu}_v = \frac{1}{n_v}\sum_{c \in\mathcal{C}(v)} \bar{\mathbf{k}}_c,\qquad\rho_v = \max_{c \in\mathcal{C}(v)} \lVert\bar{\mathbf{k}}_c - \boldsymbol{\mu}_v\rVert_2,\qquad A_v = \max_{c \in\mathcal{C}(v)} a_c,\qquad p_v^{\min} = \min_{c \in\mathcal{C}(v)} p_c, \tag*{(20)}

the quantities scored by Eq. (11).

Joining chunk roots. A chain joins the chunk roots from the smallest chunk upward: JrJ_r is the root of GrG_r, and for t=r−1,…,1t = r - 1,\ldots,1 the join node JtJ_t has children root⁡(Gt)\operatorname{root}(G_t) and Jt+1J_{t+1}; J1J_1 is the forest root. A join node vv with children a,ba,b stores

nv=na+nb,μv=naμa+nbμbnv,ρv=max⁡u∈{a,b}(ρu+∥μu−μv∥2).(21)n_v = n_a + n_b,\qquad\boldsymbol{\mu}_v = \frac{n_a\boldsymbol{\mu}_a + n_b\boldsymbol{\mu}_b}{n_v},\qquad\rho_v = \max_{u \in\{a,b\}}\left(\rho_u + \lVert\boldsymbol{\mu}_u - \boldsymbol{\mu}_v\rVert_2\right). \tag*{(21)}

with Av=max⁡(Aa,Ab)A_v = \max(A_a, A_b) and pvmin⁡=min⁡(pamin⁡,pbmin⁡)p_v^{\min} = \min(p_a^{\min}, p_b^{\min}). By the triangle inequality its ball encloses every cell mean below it, so Eq. (11) remains an upper bound at join nodes. The root of Gt\mathcal{G}_t sits at depth min⁡(t,r−1)\min(t, r - 1) and its tree has height kt≤k1−t+1k_t \le k_1 - t + 1, so the forest height is k1+[r≥2]=⌈log⁡2M⌉k_1 + [r \ge2] = \lceil\log_2 M \rceil.

Beam search and reranking. Search expands the current beam level by level and keeps the WbW^b highest-priority nodes under Eq. (11). A leaf reached early on a short branch keeps its slot, while the remaining slots expand children. The bound holds for the mean-key score of Eq. (7), not for the token-level score of Eq. (12) or for a cell’s usefulness to the answer; larger cc favors subtrees with dispersed mean keys. We set c=8c = 8 on S-NIAH at 341M and use it unchanged at 743M. The two candidate sets are merged without a quota for either forest. In Eq. (12), the log-sum-exp term is the logarithm of a cell’s unnormalized token-attention mass, and the prior affects selection only. Node summaries never replace token values.

Streaming inference. Prefill processes query blocks in fixed-size chunks. During decoding, the cache keeps only the active chunk trees. A completed larger chunk replaces its constituent smaller trees, and unchanged chunks are reused. For MM admitted cells, these trees and their joining nodes contain fewer than 2M2M nodes, giving O(Md)O(Md) tree storage per head.

Cost

Let M≤⌊N/s⌋=⌊N/32⌋M \le\lfloor N/s \rfloor= \lfloor N/32 \rfloor be the number of admitted cells in a forest; the filtered forest can hold fewer cells than the full-prefix forest. For a balanced tree and Ci=∣Bi∣C_i = \lvert B_i\rvert candidates, search, token-key reranking and readout take O(d[Wblog⁡M+sCi+sK])O(d[W^b \log M + sC_i + sK]) work per query, with Ci≤2WbC_i \le2W^b for the two forests. Fixed budgets therefore give O(Nlog⁡N)O(N \log N) routing, reranking and token attention over the sequence, including the fixed local window.

Construction with radix sorting. Assume fixed-width keys for the split projections and stable radix sorting, so sorting mm projections costs O(m)O(m) work. Computing the principal direction, projections and summaries at a node costs O(md)O(md), hence a chunk of 2k2^k cells costs O(d2kk)O(d2^k k) over its kk split levels. At most ⌊M/2k⌋\lfloor M/2^k\rfloor chunks of that size complete, and completed trees are reused. Summing over chunk sizes gives

O(∑k=1⌊log⁡2M⌋M2kd2kk)=O(Mdlog⁡2M).(22)O\left(\sum_{k=1}^{\lfloor\log_2 M\rfloor}\frac{M}{2^k}d2^k k\right)=O(Md\log^2 M). \tag*{(22)}

Two forests change only the constant factor. Including search and readout, the algorithmic sequence cost is O(Nlog⁡2N)O(N\log^2 N) at fixed dimensions and budgets, still strictly subquadratic. This bound assumes that updates reuse stored chunks without copying the growing forest at every block. Comparison sorting at every split would instead give construction work O(Mdlog⁡2M+Mlog⁡3M)O(Md\log^2 M+M\log^3 M); the stated bound uses fixed-width radix sorting or linear-time median partitioning.

Reference streaming overhead. The reference cache reuses completed trees but reallocates its growing admitted-cell index array and repacks all active node tables after updates. At fixed block size, these copies can accumulate O(M2d)O(M^2d) memory traffic over a growing decode stream, outside the algorithmic construction bound. Geometric buffer growth and persistent chunk storage can avoid this copying without changing tree contents or search. The measured reference throughput includes these overheads. The token archive uses O(Nd)O(Nd) space and the active decode trees use O(Md)O(Md) storage.

Forest ablation

Table 17 compares FS-B’s two forests with single-forest ablations, changing only the inference-time candidate generator; the checkpoints and the four-cell token read are unchanged. At 800M, FS-B matches or exceeds the full-prefix width-32 ablation at every length, by up to 0.8 mean points at the displayed precision. The width-16 full-prefix ablation has the highest mean at 4k (37.9 versus 37.7 for FS-B). At 340M, the width-32 ablation leads the suite mean at all four lengths by up to 1.3 points. Its S-NIAH-2 scores match or exceed FS-B’s; its S-NIAH-3 scores are higher at 2k–8k, but lower at 16k (24 versus 27). At 800M, FS-B has higher FWE scores than the width-32 ablation at every length and higher MV-NIAH scores from 4k onward.

TaskFS-B (two forests) 2k4k8k16kfull, Wb=32W^{b}=32 2k4k8k16kfiltered, Wb=16W^{b}=16 2k4k8k16kfull, Wb=16W^{b}=16 2k4k8k16k
≈340M\approx340\mathrm{M} scale
S-NIAH-110099999910099999999999999100999999
S-NIAH-2100998960100100926797996849100997744
S-NIAH-391786427958471247561512290797026
MK-NIAH-127251924272823212924221930202319
MK-NIAH-22001200120012000
MK-NIAH-32000100011001000
MQ-NIAH23.822.518.512.523.822.219.015.522.821.816.810.224.821.518.514.0
MV-NIAH24.522.023.521.024.522.525.521.023.021.523.016.024.223.222.018.0
VT3.21.21.01.03.01.41.61.22.81.21.01.23.01.21.01.4
CWE5.210.36.51.86.710.06.62.05.010.66.61.85.310.47.31.3
FWE9.06.011.75.09.34.79.05.78.73.76.73.09.76.09.76.7
QA-123104422965181263231034
QA-2––96––106––87––76
Available-task mean34.231.126.620.234.531.727.920.631.929.623.717.934.430.826.018.4
≈800M\approx800\mathrm{M} scale
S-NIAH-197989710095989999979910099979998100
S-NIAH-2100100958810010095901001009581981008780
S-NIAH-396938784969387878888848193949082
MK-NIAH-150342831462530295228283048282726
MK-NIAH-294125412831311122
MK-NIAH-32100201010002000
MQ-NIAH45.828.328.827.345.030.227.227.840.529.229.025.838.229.025.025.5
MV-NIAH38.330.329.826.339.528.826.224.538.029.827.226.234.228.226.224.8
VT3.81.41.00.64.02.00.80.44.82.00.80.24.02.41.00.6
CWE7.826.48.94.47.829.28.13.410.024.99.93.29.630.17.42.3
FWE17.78.77.08.015.37.33.35.710.34.77.715.023.010.77.38.3
QA-138271310402914133926131140321412
QA-2––1714––1814––159––1411
Available-task mean42.137.731.830.441.337.231.630.440.736.231.629.641.537.930.728.8

Table 17. Forest ablation of FS-B (0–100, RULER protocol of Table 1). All arms run on the same checkpoints with the same four-cell token read; only the inference-time candidate generator differs: FS-B’s two forests as rendered in Table 1, the full-prefix forest alone with a width-32 or width-16 beam, or the norm-filtered forest alone with a width-16 beam. Bold marks the best of the four arms per column.

Two width-16 beams supply at most 32 distinct candidates after deduplication, so a width-32 single forest matches the maximum candidate count. A width-16 single forest has a smaller candidate budget and scores below width 32 at 8k–16k at both scales. Equal maximum candidate counts do not imply equal runtime. The norm-filtered width-16 ablation retains 41–74% of cells by task, using a median key-norm threshold calibrated on eight 4096-token FineWeb-Edu batches. Relative to FS-B, its suite mean is lower by 1.5–2.9 points at 340M and 0.2–1.5 points at 800M.

Retrieval-weighted CPT

Recall masks. Let ftf_t indicate a recall start or continuation, identified by a unique earlier four-token match more than 512 tokens away. A start matches the span beginning at the target token with a different preceding token; a continuation matches the preceding four tokens and their next target. Let χt\chi_t mark a recall start within 64 tokens of the previous start whose source is more than 64 tokens from the previous source, which distinguishes switching to another span from returning to the same one. The masks respect document boundaries and do not depend on the model’s confidence. Only natural FineWeb-Edu text is used; benchmark prompts and answers are never training examples or sources of loss weights.

Schedule. Starting from the base 800M FS checkpoint, CPT has two 800-step stages of 262,144 tokens per step with β=9\beta= 9; βsw\beta_{\mathrm{sw}} is 9 in the first stage and 49 in the second, so a switch token has weight 19 and then 59. In each stage the learning rate warms up for 20 steps to 4×10−54 \times10^{-5} and decays to 4×10−64 \times10^{-6}. The total is 1600 steps and 0.42B tokens, all at 4096 tokens per sequence, so evaluation beyond 4k remains zero-shot extrapolation. During CPT, FS scores the eligible prefix and reads 16 cells per head; at evaluation, FS-B searches the two forests and reads four. The forests are not in the training loop, and no routing parameters are learned.

CPT ablation with single-forest readout. Table 18 compares the base and CPT checkpoints under the single-forest ablation read paths, holding each selector fixed: the 0.42B-token continuation improves every arm and length, with the largest gains at 16k. The gains concentrate on the retrieval tasks that the weighting targets (S-NIAH-1/3 improve by 4–18 points and multi-key and multi-value retrieval by 4–8), with small regressions on CWE of up to 7.8 points and on FWE of up to 3.7. Reading the same CPT checkpoint with FS-B’s two-forest search gives 42.1/37.7/31.8/30.4 (Table 1), exceeding the full-prefix width-32 ablation at 2k–8k and matching it at 16k at the displayed precision. The per-task breakdown of the CPT arms is in Table 17. The pools store aggregate scores per task, so no prompt-level intervals are reported.

Read pathWeights2k4k8k16kMean
Full-prefix forest (W32)base FS40.936.030.428.233.9
Full-prefix forest (W32)+weighted CPT41.337.231.630.435.1
Norm-filtered forest (W16)base FS39.635.129.827.533.0
Norm-filtered forest (W16)+weighted CPT40.736.231.629.634.5

Table 18. Recall-weighted CPT under single-forest ablations (0–100; RULER available-task means over 12 tasks at 2k/4k and 13 at 8k/16k, protocol of Table 1). All rows start from the base 743M FS checkpoint; CPT rows are the Table 1 FS-B checkpoint evaluated with a single-forest ablation. FS-B denotes the two-forest design, whose results appear in Table 1.

Relation to chunk and hierarchical retrieval

Several methods retrieve distant chunks. HCAM [23] and the Hierarchical Sparse Attention of RAMba [17] score chunk summaries, attend within selected chunks, and combine the chunk outputs; DRT’s Grouped Cross-Attention [18] retrieves past chunks for each next chunk. Their routing scores weight the chunk outputs, which gives the router a gradient, and DRT and RAMba offload growing token memory to the CPU while keeping chunk keys on the GPU. FreeSolo instead uses hard cell selection followed by one softmax over the selected tokens, so its shared projections learn through the token readout and local attention; FS-L bounds the accessible cells by P+WP + W per head, and FS-B searches two content forests that together cover every cell. HMT [15] recalls compressed segment memories within a recurrent architecture, whereas FreeSolo keeps the token-level keys and values of every retrievable cell. Treeformer’s TF-attention [27] learns decision-tree partitions and attends to keys routed to the query’s leaf; FS-B builds balanced partitions from the mean keys of causally available cells and searches several branches with query-dependent priorities. The published protocols also differ: DRT uses task fine-tuning and RAMba’s RULER tests include synthetic fine-tuning at 4k, whereas our models use next-token pretraining only, so we do not compare published scores.

References

  1. [1]Arshia Afzal, Aviv Bick, Eric P. Xing, Volkan Cevher, and Albert Gu. Raven: High-recall sequence modeling with sparse memory routing, 2026. URL https://arxiv.org/abs/2607.25357.
  2. [2]Shouyuan Chen, Sherman Wong, Liangjian Chen, and Yuandong Tian. Extending context window of large language models via positional interpolation. arXiv preprint arXiv:2306.15595, 2023.arxiv.org/abs/2306.15595
  3. [3]Ta-Chung Chi, Ting-Han Fan, Alexander I. Rudnicky, and Peter J. Ramadge. Dissecting transformer length extrapolation via the lens of receptive field analysis. In Proceedings of the Association for Computational Linguistics (ACL), 2023.arxiv.org/abs/2212.10356
  4. [4]David Chiang and Peter Cholak. Overcoming a theoretical limitation of self-attention. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 7654–7664. Association for Computational Linguistics, 2022. doi: 10.18653/v1/2022.acl-long.527. URL https://aclanthology.org/2022.acl-long.527/.DOI
  5. [5]Tri Dao. FlashAttention-2: Faster attention with better parallelism and work partitioning. arXiv preprint arXiv:2307.08691, 2023. URL https://arxiv.org/abs/2307.08691.
  6. [6]Tri Dao and Albert Gu. Transformers are SSMs: Generalized models and efficient algorithms through structured state space duality. arXiv preprint arXiv:2405.21060, 2024.arxiv.org/abs/2405.21060
  7. [7]Tri Dao, Daniel Y. Fu, Stefano Ermon, Atrí Rudra, and Christopher Ré. FlashAttention: Fast and memory-efficient exact attention with IO-awareness. In Advances in Neural Information Processing Systems, volume 35, 2022.arxiv.org/abs/2205.14135
  8. [8]Difan Deng, Andreas Bentzen Winje, Lukas Fehring, and Marius Lindauer. Neural attention search linear: Towards adaptive token-level hybrid attention models, 2026. URL https://arxiv.org/abs/2602.03681.
  9. [10]Jusen Du, Weigao Sun, Disen Lan, Jiaxi Hu, and Yu Cheng. MoM: Linear sequence modeling with mixture-of-memories. arXiv preprint arXiv:2502.13685, 2025. URL https://arxiv.org/abs/2502.13685.
  10. [11]Lizhe Fang, Yifei Wang, Zhaoyang Liu, Chenheng Zhang, Stefanie Jegelka, Jinyang Gao, Bolin Ding, and Yisen Wang. What is wrong with perplexity for long-context language modeling? arXiv preprint arXiv:2410.23771, 2024.arxiv.org/abs/2410.23771
  11. [12]Yao Fu, Rameswar Panda, Xinyao Niu, Xiang Yue, Hannanesh Hajishirzi, Yoon Kim, and Hao Peng. Data engineering for scaling language models to 128k context. In Proceedings of the 41st International Conference on Machine Learning, volume 235, pages 14125–14134, 2024. URL https://proceedings.mlr.press/v235/fu24d.html.arxiv.org/abs/2402.10171
  12. [13]Leo Gao et al. A framework for few-shot language model evaluation, 2023. URL https://zenodo.org/records/10256836.
  13. [14]Albert Gu and Tri Dao. Mamba: Linear-time sequence modeling with selective state spaces. arXiv preprint arXiv:2312.00752, 2023.arxiv.org/abs/2312.00752
  14. [15]Zifan He, Yingqi Cao, Zongyue Qin, Neha Prakriya, Yizhou Sun, and Jason Cong. HMT: Hierarchical memory transformer for efficient long context language processing. In Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), pages 8068–8089. Association for Computational Linguistics, 2025. doi: 10.18653/v1/2025.naacl-long.410. URL https://aclanthology.org/2025.naacl-long.410/.DOI
  15. [16]Cheng-Ping Hsieh, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, Yang Zhang, and Boris Ginsburg. RULER: What’s the real context size of your long-context language models? arXiv preprint arXiv:2404.06654, 2024.arxiv.org/abs/2404.06654
  16. [17]Xiang Hu, Jiaqi Leng, Jun Zhao, Kewei Tu, and Wei Wu. Hardware-aligned hierarchical sparse attention for efficient long-term memory access. arXiv preprint arXiv:2504.16795, 2025a. URL https://arxiv.org/abs/2504.16795.
  17. [18]Xiang Hu, Zhihao Teng, Jun Zhao, Wei Wu, and Kewei Tu. Efficient length-generalizable attention via causal retrieval for long-context language modeling. In Proceedings of the 42nd International Conference on Machine Learning, volume 267 of Proceedings of Machine Learning Research, pages 24727–24743. PMLR, 2025b. URL https://proceedings.mlr.press/v267/hu25v.html.arxiv.org/abs/2410.01651
  18. [19]Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are RNNs: Fast autoregressive transformers with linear attention. In International Conference on Machine Learning, pages 5156–5165, 2020.arxiv.org/abs/2006.16236
  19. [20]Amirhossein Kazemnejad, Inkit Padhi, Karthikeyan Natesan Ramamurthy, Payel Das, and Siva Reddy. The impact of positional encoding on length generalization in transformers. In Advances in Neural Information Processing Systems (NeurIPS), 2023.arxiv.org/abs/2305.19466
  20. [23]Andrew K. Lampinen, Stephanie C. Y. Chan, Andrea Banino, and Felix Hill. Towards mental time travel: A hierarchical memory for reinforcement learning agents. In Advances in Neural Information Processing Systems, volume 34, 2021. URL https://arxiv.org/abs/2105.14039.
  21. [24]Yuhong Li, Yingbing Huang, Bowen Yang, Bharat Venkitesh, Acy r Locatelli, Hanchen Ye, Tianle Cai, Patrick Lewis, and Deming Chen. SnapKV: LLM knows what you are looking for before generation, 2024. URL https://arxiv.org/abs/2404.14469.
  22. [25]Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019. URL https://arxiv.org/abs/1711.05101.
  23. [26]Enzhe Lu, Zhejun Jiang, Jingyuan Liu, Yulun Du, Tao Jiang, Chao Hong, et al. MoBA: Mixture of block attention for long-context LLMs. arXiv preprint arXiv:2502.13189, 2025.arxiv.org/abs/2502.13189
  24. [27]Lovish Madaan, Srinadh Bhojanapalli, Himanshu Jain, and Prateek Jain. Treeformer: Dense gradient trees for efficient attention computation. In International Conference on Learning Representations, 2023. URL https://arxiv.org/abs/2208.09015.
  25. [28]Amirkeivan Mohtashami and Martin Jaggi. Random-access infinite context length for transformers. In Advances in Neural Information Processing Systems, 2023. URL https://arxiv.org/abs/2305.16300.
  26. [29]Guilherme Penedo, Hynek Kydlíček, Loubna Ben Allal, Anton Lozhkov, Margaret Mitchell, Colin Raffel, Leandro von Werra, and Thomas Wolf. The FineWeb datasets: Decanting the web for the finest text data at scale. arXiv preprint arXiv:2406.17557, 2024.arxiv.org/abs/2406.17557
  27. [30]Bowen Peng, Jeffrey Quesnelle, Honglu Fan, and Enrico Shippole. YaRN: Efficient context window extension of large language models. In International Conference on Learning Representations (ICLR), 2024.arxiv.org/abs/2309.00071
  28. [31]Ofir Press, Noah A. Smith, and Mike Lewis. Train short, test long: Attention with linear biases enables input length extrapolation. In International Conference on Learning Representations (ICLR), 2022.arxiv.org/abs/2108.12409
  29. [32]Krishna C. Puvvada, Faisal Ladhak, Santiago Akle Serrano, Cheng-Ping Hsieh, Shantanu Acharya, Somshubra Majumdar, Fei Jia, Samuel Kriman, Simeng Sun, Dima Rekesh, and Boris Ginsburg. SWAN-GPT: An efficient and scalable approach for long-context language modeling, 2025. URL https://arxiv.org/abs/2504.08719.
  30. [33]Noam Shazeer. GLU variants improve transformer. arXiv preprint arXiv:2002.05202, 2020. URL https://arxiv.org/abs/2002.05202.
  31. [34]Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. arXiv preprint arXiv:1701.06538, 2017. URL https://arxiv.org/abs/1701.06538.
  32. [35]Jianlin Su, Yu Lu, Shengfeng Pan, Ahmed Murtadha, Bo Wen, and Yunfeng Liu. RoFormer: Enhanced transformer with rotary position embedding. arXiv preprint arXiv:2104.09864, 2021.arxiv.org/abs/2104.09864
  33. [36]Jiaming Tang, Yilong Zhao, Kan Zhu, Guangxuan Xiao, Baris Kasikci, and Song Han. QUEST: Query-aware sparsity for efficient long-context LLM inference. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 47901–47911, 2024. URL https://proceedings.mlr.press/v235/tang24l.html.arxiv.org/abs/2406.10774
  34. [37]Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. LLaMA: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.arxiv.org/abs/2302.13971
  35. [38]Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in Neural Information Processing Systems, 30, 2017.arxiv.org/abs/1706.03762
  36. [39]Pavlo Vasylenko, Hugo Pitorro, André F. T. Martins, and Marcos Treviso. Long-context generalization with sparse attention. In International Conference on Learning Representations, 2026. URL https://arxiv.org/abs/2506.16640.
  37. [40]Yuhui Wu, Markus N. Rabe, DeLesley Hutchins, and Christian Szegedy. Memorizing transformers. In International Conference on Learning Representations, 2022. URL https://arxiv.org/abs/2203.08913.
  38. [41]Chaojun Xiao, Pengle Zhang, Xu Han, Guangxuan Xiao, Yankai Lin, Zhengyan Zhang, Zhiyuan Liu, and Maosong Sun. InfLLM: Training-free long-context extrapolation for LLMs with an efficient context memory. In Advances in Neural Information Processing Systems, 2024a. URL https://arxiv.org/abs/2402.04617.
  39. [42]Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. In International Conference on Learning Representations (ICLR), 2024b.arxiv.org/abs/2309.17453
  40. [43]Bowen Yang, Bharat Venkitesh, Dwarak Talupuru, Hangyu Lin, David Cairuz, Phil Blunsom, and Acyr Locatelli. RoPE to NoPE and back again: A new hybrid attention strategy, 2025a. URL https://arxiv.org/abs/2501.18795.
  41. [44]Songlin Yang, Jan Kautz, and Ali Hatamizadeh. Gated delta networks: Improving mamba2 with delta rule. In International Conference on Learning Representations, 2025b.arxiv.org/abs/2412.06464
  42. [45]Jingyang Yuan, Huazuo Gao, Damai Dai, Junyu Luo, Liang Zhao, Zhengyan Zhang, Zhenda Xie, et al. Native sparse attention: Hardware-aligned and natively trainable sparse attention. arXiv preprint arXiv:2502.11089, 2025.arxiv.org/abs/2502.11089
  43. [46]Biao Zhang and Rico Sennrich. Root mean square layer normalization. In Advances in Neural Information Processing Systems, volume 32, 2019.arxiv.org/abs/1910.07467
  44. [47]Yu Zhang, Songlin Yang, Ruijie Zhu, Yue Zhang, Leyang Cui, Yiqiao Wang, Bolun Wang, Freda Shi, Bailin Wang, Wei Bi, Peng Zhou, and Guohong Fu. Gated slot attention for efficient linear-time sequence modeling. In Advances in Neural Information Processing Systems, 2024. URL https://arxiv.org/abs/2409.07146.
  45. [48]Zhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen, Lianmin Zheng, Ruisi Cai, Zhao Song, Yuandong Tian, Christopher Ré, Clark Barrett, Zhangyang Wang, and Beidi Chen. H₂O: Heavy-hitter oracle for efficient generative inference of large language models, 2023. URL https://arxiv.org/abs/2306.14048.

Paper details

vlnc:W_3vrcjccd
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 4

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents