Manuscript Offprint
arXiv:2610.34180Write What Matters: Disentangling Token Selection from Slot Allocation in Recurrent Memory
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Long-sequence models must retain earlier information. Full attention keeps all past tokens but grows expensive, and recurrent-memory models compress history into fixed slots for linear-time processing. Limited capacity makes writes consequential: distractors can interfere with useful content, while skipped evidence cannot be recalled. Existing multi-slot memories write every token to the same number of slots, merging whether to store it with how many slots to update. We introduce Factorized Write Routing (FWR), which first keeps or skips each token and then chooses a fixed or token-adaptive number of slots. Queries still read all slots. Across ten seeds on two synthetic tasks that query facts after long contexts, we observe a density-dependent reversal. With four slots per write, long-context accuracy favors always writing on dense Feature Recall (0.472 vs 0.337), but learned selective writing on sparse-fact Passkey (0.222 vs 0.048). The tested adaptive rule underperforms fixed allocation under the learned gate on both tasks. A diagnostic oracle given fact labels unavailable at deployment reaches 0.372 on Passkey, showing headroom in filtering distractors. The results suggest avoiding missed writes in information-dense contexts and filtering distractors when they dominate.
1 Introduction
Transformer attention provides random access to past tokens but incurs quadratic cost in sequence length (Vaswani et al., 2017). Linear attention, state-space models, and recurrent memory architectures instead compress history into a bounded state (Katharopoulos et al., 2020; Schlag et al., 2021; Gu and Dao, 2024; Dao and Gu, 2024). This compression enables constant-memory decoding, yet it creates a harder problem: once an update overwrites or contaminates the state, the original token may no longer be recoverable. Empirical and theoretical work has consequently identified retrieval and copying as persistent weaknesses of fixed-state models (Arora et al., 2024a; Jelassi et al., 2024; Wen et al., 2024). Multi-slot recurrent memories mitigate this bottleneck by maintaining several independently updated states. Recent systems route each token to a small Top-K subset of slots (Zhang et al., 2024; Afzal et al., 2026). Top-K is an effective answer to where a token should be written, but the usual fixed-K rule silently assumes that every token should be written and deserves the same update budget. That assumption is mismatched to long-context retrieval. A context may be information-dense, in which nearly every token can be queried later, or information-sparse, in which a few facts are surrounded by distractors. The same routing sparsity need not suit both regimes.
This paper asks a narrower and, we argue, more fundamental question: In a bounded multi-slot memory, how should the model separate whether to write a token from how many slots to update, when the future query is not yet known? We study this question through Factorized Write Routing (FWR), which decomposes routing into a binary write variable and a conditional slot count . The decomposition organizes controls along two explicit axes: always-write versus learned or oracle token selection, and fixed versus adaptive slot allocation. It therefore exposes the two routing choices instead of packaging them in an inseparable “adaptive router.”
Our results challenge two tempting generalizations. First, sparse writing is not universally beneficial: on high-density Feature Recall, dense writing significantly outperforms at long lengths across ten paired seeds. Second, token-adaptive is not sufficient by itself. Prespecified paired contrasts in the ten-seed mechanism study show a task-dependent reversal: at the same fixed width , learned gating is worse than always writing on Feature Recall but better on sparse-fact Passkey. Under learned gating, fixed allocation is favored over the tested adaptive rule on both tasks. At K = 4, an oracle token-type gate also outperforms the learned gate on Passkey, revealing headroom in fact–distractor selection without assuming knowledge of the eventual query. Holding K constant makes the fixed-family comparisons controlled tests of the gate policy within the tested recurrence.
Our contributions are threefold:
• We formulate multi-slot writing as two decisions: token selection and slot allocation, and provide FWR, an implementation-compatible framework for independently controlling them.
• We give a ten-seed counterexample to the idea that a small fixed K is a robust default: harms long recall when most context tokens remain relevant.
• Through pre-specified matched-K paired contrasts and token-type oracle controls, we document a task-dependent reversal between learned and always-write gates, and show that our adaptive-K rule underperforms validation-selected fixed K under learned gating on both tasks.
Memory for long context. Transformer-XL recurs over cached hidden states (Dai et al., 2019); Compressive Transformer and Memorizing Transformer extend access through compressed or non-parametric memories (Rae et al., 2020; Wu et al., 2022). Recurrent Memory Transformer carries dedicated memory tokens across segments (Bultov et al., 2022), whereas Longformer uses sparse token-to-token attention (Beltagy et al., 2020). These methods differ in how much past information remains directly addressable. In bounded recurrent memory, writes must summarize or overwrite history, making routing quality as important as read quality.
Slot memories and conditional routing. Gated Slot Attention increases recurrent-state capacity with several independently updated slots (Zhang et al., 2024). RAVEN adds sparse routing and reports task-dependent optima for the number of updated slots (Afzal et al., 2026). Our work does not propose that dense or sparse routing universally supersedes RAVEN; it isolates a missing decision upstream of Top-K: whether a token should update memory at all. Conditional computation offers related routing mechanisms. Mixture-of-experts models send tokens to a small subset of parameters (Shazeer et al., 2017; Fedus et al., 2022), while adaptive computation and Mixture-of-Depths vary token-level computation (Graves, 2016; Raposo et al., 2024). Their objective is compute allocation; ours is the preservation of future-relevant information under a fixed recurrent state.
Long-context evaluation. LongBench and RULER demonstrate that nominal context length can overstate usable retrieval length (Bai et al., 2024; Hsieh et al., 2024), while position-controlled analyses expose failures when evidence lies away from prompt boundaries (Liu et al., 2024). We use synthetic tasks because they provide exact labels for future-relevant and distracting tokens, enabling direct measurement of write recall and false-positive rates. This controlled diagnosis complements, but does not replace, evaluation on natural text.
3 Factorized Write Routing
3.1 Method Overview
Our method decomposes memory writing into two decisions: whether the current token should be stored and how the write should be allocated across memory slots. This factorization allows the model to suppress uninformative tokens without constraining the slot-allocation mechanism used for informative ones.
Let denote the representation at sequence position . The model maintains recur-

Figure 1: Comparison of context storage and retrieval mechanisms between existing methods and ours. Standard attention retains token-level keys and values and allows the query to attend directly to all preceding tokens, whereas Linear attention compresses the context into a shared recurrent state to alleviate the huge KV cache memory. RAVEN maintains M recurrent slots but routes every token to a fixed number K of slots. Our Factorized Write Routing (FWR) first uses a token-level gate to decide whether to write, and then allocates the retained token to a token-adaptive number of slots. Both RAVEN and FWR read densely over all M slots, they differ in their write policies. The labels and illustrate tokens that are relevant and irrelevant, respectively, to the future query q; these relevance labels are unavailable to the learned gate at inference time.
rent memory slots,
where is the content of slot before processing . The number of slots is fixed, while their contents evolve as the sequence is processed. For each token, a learned write gate first predicts
where indicates that the token should be written to memory and indicates that it should be skipped. In a separate routing branch, the slot router assigns scores to the memory slots:
where is the routing logit for slot m.
The allocation module determines the number of slots to update and selects a corresponding slot set
The allocation width may be fixed for all tokens or predicted adaptively from the routing scores. The selected scores are normalized to obtain the slot-allocation weights:
The final write-routing weight combines token selection and slot allocation:
Therefore, the routing weights satisfy
When , all routing weights are zero and the memory is carried forward unchanged. When , the token is distributed over the selected slots according to their normalized routing scores.
Each slot is then updated through the recurrent memory operator:
Thus, only slots with nonzero routing weights are modified. Write routing determines where information is stored, whereas read attention independently determines which stored information is retrieved for the current query.

Figure 2: FWR separates token selection from slot allocation. A skipped token changes no slot; a kept token updates either a fixed or token-adaptive number of slots. Reading remains dense, so a query need not predict the write-time slot identity.
3.2 Token-Conditional Write Gate
The write gate determines whether the current token should modify the memory. Given the token representation , we compute its write probability as
where and are learned parameters. The corresponding hard write decision is
Because the threshold operation is non-differentiable, we use a straight-through estimator during training:
where denotes the stop-gradient operator. Equation 11 evaluates to in the forward pass, while its backward gradient is taken through .
The gate is applied before slot allocation. If , all routing weights are zero:
and the memory remains unchanged. If , the token is passed to the slot-allocation module, which determines how many slots should be updated and how the write should be distributed among them.
We encourage selective writing using the soft write-rate penalty
3.3 Fixed and Adaptive Slot Router
The slot router first converts the positive routing scores into a probability distribution over the M memory slots:
(14)
We write , where and .
For fixed-width routing, the number of selected slots is . For adaptive routing, let
denote the components of sorted in descending order. We first find the smallest prefix whose cumulative probability reaches a mass threshold :
The actual allocation width is then bounded by and :
The selected set contains the slots with the largest routing probabilities. We use , , and in the adaptive-routing experiments. Because the hard selection of does not provide a convenient gradient for controlling allocation width, we use the entropy of the routing distribution:
We define the differentiable effective-slot count as
The quantity measures how many slots are effectively supported by the routing distribution. Before clipping, equals for an ideal distribution that is uniform over slots and zero elsewhere. We cap this value at . Unlike the discrete , is used only as a differentiable proxy in the slot-allocation regularizer .
3.4 Training objective
Let Q denote the set of query positions in a mini-batch. For each , let be the predicted answer logits and the target answer class. We train the model using the query-level cross-entropy loss
This loss supervises only the answer predictions at query positions. The write gate and slot router receive no direct token-level relevance supervision. Instead, they are trained indirectly through the effect of earlier memory writes on subsequent query predictions.
We then define the normalized slot-allocation cost as
Minimizing this term encourages the routing distribution to concentrate on fewer slots. In implementation, the expectation is additionally averaged over the examples and routing heads in each mini-batch.
The complete training objective is
where and control the penalties on slot-allocation width and write frequency, respectively.
3.5 Dense Readout over Sparse Writes
Although each token is written to only a subset of memory slots, a query can read from all M slots. Let denote the query representation at position . We compute a relevance score between the query and every slot:
where is a learned key projection. The read-attention weights are normalized over all slots:
The retrieved representation is
where is the corresponding value projection.
No predefined mapping assigns a fact or query to a particular slot. Instead, the write router, slot representations, and read attention are jointly optimized through the task loss. Consequently, a query does not need to know which slots were selected when a fact was written. It compares against all available slots at read time. The write width therefore controls how many slots are modified by the current token, and hence the potential write interference, but it does not restrict the M slots available for subsequent retrieval.
4 Experimental Setup
4.1 Tasks
We construct key-value recall sequences followed by 16 queries. Keys and values are sampled from vocabularies of size 1,024 and 64, respectively, and query tokens contain a key but mask its value. Accuracy is exact value-token accuracy at query positions.
Write-gate controls. We compare the learned gate with two diagnostic controls. The always-write control sets for every token and therefore removes token-level filtering. The oracle control writes fact tokens and skips filler and query tokens using the ground-truth token-type labels provided by the synthetic data generator. The oracle is used only for diagnosis, it is unavailable in realistic inference and does not guarantee perfect accuracy because slot routing, memory updates, and retrieval may still fail.
Feature Recall (high density). Every context token is a unique key-value fact, and each query asks for a fact sampled from that context. The model trains at context length 32 and is tested through 512. Because nearly all context tokens are potential query targets, skipping writes risks false negatives.
Passkey (low density). Facts are placed randomly among filler tokens drawn from a disjoint key range. Training uses 32 facts in 128 context tokens; testing scales both facts and context proportionally up to 256 facts in 1,024 tokens. Only one quarter of context tokens are facts, so indiscriminate writing introduces avoidable memory interference.
Table 1 summarizes the controlled difference. Both tasks require length extrapolation, but they impose different future-relevance densities.
| Feature Recall | Passkey | |
|---|---|---|
| Training context | 32 | 128 |
| Training facts | 32 | 32 |
| Test contexts | 32–512 | 128–1,024 |
| Queries | 16 | 16 |
| Fact density | high | 25% of context |
| Distractor tokens | none | 75% of context |
Table 1: The tasks share the same key–value recall objective but differ in future-relevant information density.
4.2 Compared Methods and Evaluation
All comparisons use the same RAVEN recurrent-memory backbone (Afzal et al., 2026); the methods differ only in token selection and slot allocation. RAVEN-FIXED denotes the original always-write policy with a fixed Top-K allocation, and RAVEN-DENSE is its all-slot control with . FWR-NOGATE uses adaptive but always writes, thereby isolating slot-count adaptation. FWR-FIXED and FWR-ADAPTIVE use the learned write gate with fixed and adaptive allocation, respectively. The oracle variants replace the learned gate with ground-truth fact labels and are diagnostic, not deployable.
We conduct two complementary ten-seed comparisons. Table 2 uses the official RAVEN backend and paired random seeds 1–10 to compare RAVEN-FIXED (K = 2) with RAVEN-DENSE (K = M = 16). This experiment tests whether a small fixed K is a reliable default; it does not use the proposed learned gate. Table 3 uses the same seed set and a RAVEN-compatible recurrence to cross always-write, learned, and oracle gates with fixed or adaptive allocation. Hyperparameters are selected on validation data and fixed before test evaluation.
The primary metric is exact value-token accuracy at query positions. LONGMEAN averages accuracy over context lengths strictly longer than training: 64–512 for Feature Recall and 256–1,024 for Passkey. Table 3 reports the mean and sample standard deviation across ten seeds. For Table 2 and the five pre-specified mechanism contrasts in Appendix Table 7, we compute differences within matched seeds and report paired 95% Student-t intervals and Cohen's ; “favored” means that the interval excludes zero. The three fixed-family contrasts hold K = 4 constant and therefore compare gate policies directly within the tested recurrence. The adaptive-versus-fixed contrasts also change the realized write budget. Active writes is , and write fraction is . Further implementation details appear in Appendix E.
5 Results
5.1 Fixed Top-K versus All-Slot Writing
Table 2 isolates slot-allocation width within the official RAVEN backbone. RAVEN-FIXED writes every token to its top two slots, whereas RAVEN-DENSE writes every token to all slots. The two method columns report exact query accuracy at each context length. We define , so positive values favor all-slot writing. The paired confidence interval is computed from the ten within-seed differences, and LONGMEAN excludes the training length.
On high-density Feature Recall, RAVEN-DENSE is favored at lengths 128, 256, and 512. Its LONGMEAN is 0.3772, compared with 0.2882 for RAVEN-FIXED, giving a paired improvement of 0.0890, a CI of [0.0148, 0.1633], and Cohen's . The intervals at lengths 32 and 64 include zero and are therefore inconclusive. Thus, writing every token to only two slots can under-allocate memory capacity when nearly every context item may be queried later.
On Passkey, every confidence interval includes zero. RAVEN-DENSE has a slightly higher LONG-MEAN than RAVEN-FIXED (0.1751 versus 0.1580), but their difference is only 0.0171 with a wide CI of . This experiment establishes neither a dense-writing advantage nor equivalence between the methods. Together, the two tasks reject the stronger claim that a small fixed is universally preferable.
5.2 Separating Token Selection from Slot Allocation
Table 3 compares the RAVEN controls with the proposed FWR variants. The Method, Gate, and Allocation columns state the routing factors used by each row. LONGMEAN is long-context accuracy, active writes is the mean number of updated slots per token, and write fraction is the proportion of token-head decisions that trigger a write. Deterministic routing counts are shown without error bars.
High-density Feature Recall. Across ten seeds, the highest deployable mean is obtained by RAVEN-FIXED with (), compared with for RAVEN-DENSE
Table 2: Ten-seed comparison of two RAVEN write-allocation rules. Positive favors RAVEN-DENSE; “dense favored” means that the paired confidence interval excludes zero. LONGMEAN averages only context lengths longer than training.
| Task | Context length | RAVEN-FIXED (K = 2) | RAVEN-DENSE (K = M = 16) | Δ | Paired 95% CI for Δ | Evidence |
|---|---|---|---|---|---|---|
| Feature Recall | 32 | .7732 | .8800 | +.1068 | [-.0536, .2673] | inconclusive |
| 64 | .5663 | .7088 | +.1425 | [-.0004, .2853] | inconclusive | |
| 128 | .3244 | .4426 | +.1182 | [.0284, .2080] | dense favored | |
| 256 | .1698 | .2363 | +.0665 | [.0212, .1118] | dense favored | |
| 512 | .0923 | .1212 | +.0289 | [.0066, .0512] | dense favored | |
| LONGMEAN | .2882 | .3772 | +.0890 | [.0148, .1633] | dense favored | |
| Passkey | 128 | .4267 | .3904 | -.0363 | [-.2769, .2044] | inconclusive |
| 256 | .2602 | .2793 | +.0191 | [-.1576, .1958] | inconclusive | |
| 512 | .1392 | .1640 | +.0248 | [-.0754, .1250] | inconclusive | |
| 1,024 | .0745 | .0818 | +.0074 | [-.0416, .0563] | inconclusive | |
| LONGMEAN | .1580 | .1751 | +.0171 | [-.0900, .1242] | inconclusive |
Table 3: Ten-seed mechanism comparison on LONGMEAN. Non-deterministic entries report mean ± standard deviation across matched seeds 1–10. Hyperparameters are fixed before test evaluation. Bold marks the highest deployable mean per task. Oracle methods (†) use ground-truth token-type labels and are diagnostic. Paired inference for five pre-specified contrasts appears in Appendix Table 7.
| Task | Method | Gate | Allocation | LONGMEAN ↑ mean ± SD | Active writes mean ± SD | Write fraction mean ± SD |
|---|---|---|---|---|---|---|
| Feature Recall | RAVEN-DENSE | Always | Dense (K = 16) | .3855 ± 0.0124 | 16.000 | 1.000 |
| RAVEN-FIXED | Always | Fixed (K = 4) | .4716 ± 0.0101 | 4.000 | 1.000 | |
| FWR-NOGATE | Always | Adaptive | .3978 ± 0.0150 | 5.488 ± 0.0182 | 1.000 | |
| FWR-FIXED | Learned | Fixed (K = 4) | .3369 ± 0.0216 | 1.602 ± 0.0872 | .401 ± 0.0218 | |
| FWR-ADAPTIVE | Learned | Adaptive | .2776 ± 0.0206 | .588 ± 0.0231 | .179 ± 0.0184 | |
| ORACLE-FIXED† | Oracle | Fixed (K = 4) | .3360 ± 0.0195 | 3.600 ± 0.0332 | .900 ± 0.0125 | |
| ORACLE-ADAPTIVE† | Oracle | Adaptive | .4217 ± 0.0264 | 4.294 ± 0.0251 | .900 ± 0.0207 | |
| Passkey | RAVEN-DENSE | Always | Dense (K = 8) | .0456 ± 0.0024 | 8.000 | 1.000 |
| RAVEN-FIXED | Always | Fixed (K = 4) | .0475 ± 0.0021 | 4.000 | 1.000 | |
| FWR-NOGATE | Always | Adaptive | .0609 ± 0.0026 | 4.493 ± 0.0278 | 1.000 | |
| FWR-FIXED | Learned | Fixed (K = 4) | .2216 ± 0.0082 | .882 ± 0.0044 | .221 ± 0.0035 | |
| FWR-ADAPTIVE | Learned | Adaptive | .1991 ± 0.0067 | 1.199 ± 0.0138 | .299 ± 0.0046 | |
| ORACLE-FIXED† | Oracle | Fixed (K = 4) | .3723 ± 0.0075 | .965 ± 0.0124 | .241 ± 0.0043 | |
| ORACLE-ADAPTIVE† | Oracle | Adaptive | .3311 ± 0.0037 | .849 ± 0.0052 | .241 ± 0.0027 |
and for FWR-NOGATE. The learned-gate variants obtain and , with write fractions of and . At matched K = 4, the pre-specified learned-fixed versus always-fixed contrast favors always writing ( , CI ; Appendix Table 7), directly showing that the learned gate is harmful in this dense-relevance task. Together with Table 2, the results suggest that an intermediate fixed allocation can outperform either extreme in this setting, but do not establish a universal optimal K.
Low-density Passkey. The always-write variants remain low (0.0456–0.0609), whereas the learned-gate variants reach and while using and active writes. At matched K = 4, the paired learned-fixed versus always-fixed contrast favors learned gating ( , CI [0.1688, 0.1794]), isolating the benefit of selective writing in this sparse-fact task. Also at K = 4, oracle-fixed exceeds learned-fixed ( , CI [0.1451, 0.1563]). The oracle knows fact/filler type rather than the eventual query, so this gate-policy gap indicates token-selection headroom but does not measure future-query prediction.
Adaptive allocation is not consistently superior. The two pre-specified learned-gate allocation contrasts both favor fixed allocation: adaptive minus fixed is -0.0593 on Feature Recall (CI [-0.0744, -0.0442]) and -0.0225 on Passkey (CI [-0.0279, -0.0171]). Other gate conditions show mixed mean directions, so the adaptive rule has no task-independent advantage. Because the com-pared policies use different write budgets, these results reject a universal benefit for this adaptive- rule but do not prove that fixed allocation is intrinsically superior.
6 Discussion
A conditional routing hypothesis. The matched-K gate contrasts reverse direction across tasks: learned-fixed is worse than always-fixed on Feature Recall but better on Passkey. Holding K = 4 constant rules out allocation width as the explanation and supports write recall when nearly every token can be queried, but write precision when facts are embedded among distractors. The two tasks still differ in more than density, so these results do not identify density as the sole causal variable; a controlled continuous density sweep remains necessary.
What the oracle gap establishes. At time t, the writer observes the current prefix but not an arbitrary later query. Our oracle supplies only generator-provided fact/filler labels: it writes every fact and skips fillers and queries, but it does not know the eventual query target. The paired Passkey contrast holds K = 4 fixed, removing allocation width as a confound, but query handling still differs between gates. The gap therefore establishes headroom in the tested gate policy, not the value of perfect future-utility prediction. Query-conditioned gates, read-only-query controls, and an oracle defined by eventual query membership are needed for the stronger claim.
Write-read consistency. Sparse writing does not require a query to reproduce the writer's discrete slot choice. All slots participate in the read softmax (Eq. 25); training only needs useful information to induce a query-compatible key in at least one slot. The unresolved risk is earlier: if , no read rule can recover the omitted information. This asymmetry further motivates recall-oriented supervision for the write gate.
Logical sparsity is not physical speed. Our implementation constructs sparse logical routes but currently passes a dense routing tensor to the recurrent kernel. Consequently, characterizes update sparsity, not realized acceleration. Claims about efficiency require a sparse kernel and direct measurements of latency, throughput, peak memory, and energy. Accuracy–cost Pareto conclusions in this paper are therefore architectural, not systems-level.
Query-time updates are a confound. The recurrence updates memory before reading the current token. Dense and always-write policies therefore allow query tokens themselves to alter the state; the oracle skips them, and a learned gate may do either. Although all compared variants use the same base recurrence, part of the oracle gap could reflect query handling rather than context filtering alone. Read-before-write and read-only-query ablations are necessary follow-up experiments.
7 Conclusion
We separated token selection from slot allocation in bounded multi-slot recurrent memory. The first paired ten-seed study shows that dense writing beats K = 2 on high-density long recall. In the mechanism study, matched-K (K = 4) paired contrasts show that learned gating is worse than always writing on Feature Recall but better on sparse-fact Passkey; an oracle token-type gate further improves Passkey. Fixed allocation also beats the tested adaptive rule under learned gating on both tasks, although these allocation contrasts do not match realized write budgets. Overall, the evidence supports a conditional hypothesis—balance write precision and recall according to relevance density, and treat adaptive slot count as a separate capacity problem—that should next be tested with controlled density sweeps and natural text.
Limitations
Both studies use ten paired seeds, and Appendix Table 7 reports intervals for five pre-specified mechanism contrasts; it does not provide an exhaustive significance map for all rows in Table 3. The fixed-family contrasts hold K = 4 constant, but the adaptive-versus-fixed contrasts use unequal write budgets, limiting causal attribution about allocation. The two synthetic tasks also differ in more than relevance density and omit ambiguous relevance, discourse, and natural-text generation. The oracle uses unavailable fact/filler labels, neither knows the future query nor constitutes an upper bound, and update-before-read confounds query handling. Scaling may change the trade-offs, while dense routing tensors make logical cost a sparsity proxy rather than hardware efficiency. Independent replication, equal-budget allocation controls, read-only-query ablations, and a continuous density sweep are needed.
Ethical Considerations
The experiments use procedurally generated symbolic data and do not involve people, private information, or annotator labor. The main downstream risk is overgeneralization: an oracle gate that recognizes task-defined facts should not be interpreted as evidence that demographic or clinical attributes are universally irrelevant. In real applications, relevance depends on the user query, decision context, and fairness requirements. Selective memory systems can silently discard information, so deployment in high-stakes domains would require domain-specific recall audits, subgroup analysis, traceable write decisions, and a fallback that preserves the original record.
References
Arshia Afzal, Aviv Bick, Eric P. Xing, Volkan Cevher, and Albert Gu. 2026. Raven: High-recall sequence modeling with sparse memory routing. Preprint, arXiv:2607.25357.
Simran Arora, Sabri Eyuboglu, Aman Timalsina, Isys Johnson, Michael Poli, James Zou, Atri Rudra, and Christopher Ré. 2024a. Zoology: Measuring and improving recall in efficient language models. In The Twelfth International Conference on Learning Representations.
Simran Arora, Sabri Eyuboglu, Michael Zhang, Aman Timalsina, Silas Alberti, James Zou, Atri Rudra, and Christopher Ré. 2024b. Simple linear attention language models balance the recall-throughput tradeoff. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 1763–1840. PMLR.
Yushi Bai, Xin Lv, Jiajie Zhang, Hongchang Lyu, Jiankai Tang, Zhidian Huang, Zhengxiao Du, Xiao Liu, Aohan Zeng, Lei Hou, Yuxiao Dong, Jie Tang, and Juanzi Li. 2024. LongBench: A bilingual, multitask benchmark for long context understanding. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 3119–3137. Association for Computational Linguistics.
Iz Beltagy, Matthew E. Peters, and Arman Cohan. 2020. Longformer: The long-document transformer. Preprint, arXiv:2004.05150.
Aydar Bulatov, Yuri Kuratov, and Mikhail S. Burtsev. 2022. Recurrent memory transformer. In Advances in Neural Information Processing Systems, volume 35, pages 11079–11091.
Zihang Dai, Zhilin Yang, Yiming Yang, Jaime Carbonell, Quoc V. Le, and Ruslan Salakhutdinov. 2019.
Transformer-XL: Attentive language models beyond a fixed-length context. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 2978–2988. Association for Computational Linguistics.
Tri Dao and Albert Gu. 2024. Transformers are SSMs: Generalized models and efficient algorithms through structured state space duality. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 10041–10071. PMLR.
William Fedus, Barret Zoph, and Noam Shazeer. 2022. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. Journal of Machine Learning Research, 23(120):1–39.
Alex Graves. 2016. Adaptive computation time for recurrent neural networks. Preprint, arXiv:1603.08983.
Albert Gu and Tri Dao. 2024. Mamba: Linear-time sequence modeling with selective state spaces. In First Conference on Language Modeling.
Cheng-Ping Hsieh, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, Yang Zhang, and Boris Ginsburg. 2024. RULER: What's the real context size of your long-context language models? Preprint, arXiv:2404.06654.
Eric Jang, Shixiang Gu, and Ben Poole. 2017. Categorical reparameterization with gumbel-softmax. In International Conference on Learning Representations.
Samy Jelassi, David Brandfonbrener, Sham M. Kakade, and Eran Malach. 2024. Repeat after me: Transformers are better than state space models at copying. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 21502–21521. PMLR.
Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. 2020. Transformers are RNNs: Fast autoregressive transformers with linear attention. In Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pages 5156–5165. PMLR.
Diederik P. Kingma and Jimmy Ba. 2015. Adam: A method for stochastic optimization. In International Conference on Learning Representations.
Nelson F. Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, and Percy Liang. 2024. Lost in the middle: How language models use long contexts. Transactions of the Association for Computational Linguistics, 12:157–173.
Hao Peng, Jungo Kasai, Nikolaos Pappas, Dani Yogatama, Zhaofeng Wu, Lingpeng Kong, Roy Schwartz, and Noah A. Smith. 2022. ABC: Attention with bounded-memory control. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 7469–7483. Association for Computational Linguistics.
Jack W. Rae, Anna Potapenko, Siddhant M. Jayakumar, Chloë Hillier, and Timothy P. Lillicrap. 2020. Compressive transformers for long-range sequence modelling. In International Conference on Learning Representations.
David Raposo, Sam Ritter, Blake Richards, Timothy Lillicrap, Peter C. Humphreys, and Adam Santoro. 2024. Mixture-of-depths: Dynamically allocating compute in transformer-based language models. Preprint, arXiv:2404.02258.
Imanol Schlag, Kazuki Irie, and Jürgen Schmidhuber. 2021. Linear transformers are secretly fast weight programmers. In Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 9355–9366. PMLR.
Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc V. Le, Geoffrey Hinton, and Jeff Dean. 2017. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. Preprint, arXiv:1701.06538.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In Advances in Neural Information Processing Systems, volume 30.
Kaiyue Wen, Xingyu Dang, and Kaifeng Lyu. 2024. RNNs are not transformers (yet): The key bottleneck on in-context retrieval. Preprint, arXiv:2402.18510.
Yuhuai Wu, Markus N. Rabe, DeLesley Hutchins, and Christian Szegedy. 2022. Memorizing transformers. In International Conference on Learning Representations.
Songlin Yang, Jan Kautz, and Ali Hatamizadeh. 2024a. Gated delta networks: Improving Mamba2 with delta rule. Preprint, arXiv:2412.06464.
Songlin Yang, Bailin Wang, Yikang Shen, Rameswar Panda, and Yoon Kim. 2024b. Gated linear attention transformers with hardware-efficient training. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 56501–56523. PMLR.
Songlin Yang, Bailin Wang, Yu Zhang, Yikang Shen, and Yoon Kim. 2024c. Parallelizing linear transformers with the delta rule over sequence length. Preprint, arXiv:2406.06484.
Yu Zhang, Songlin Yang, Rui-Jie 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, volume 37, pages 116870–116898.
A Reproducibility Details
Data generation. Feature Recall samples unique context keys and random values; its 16 query keys are sampled from the context. Passkey samples random filler keys, inserts fact key–value pairs at uniformly sampled context positions, and draws queries only from fact keys. Fact and filler key ranges are disjoint for diagnosis. Targets are defined only on the query suffix.
Length grids. Feature Recall trains and validates at length 32 and tests at 32, 64, 128, 256, and 512. Passkey trains and validates with 32 facts in 128 context tokens and tests (context, facts) . All examples append 16 query tokens; reported context lengths exclude this suffix.
Randomness and hardware. Both the primary comparison and the mechanism study use seeds 1–10 with deterministic PyTorch execution on an NVIDIA RTX A6000 and the same optimizer schedule. The captured environment reports PyTorch 2.13.0+cu130 and Flash Linear Attention 0.5.2. Runs use bfloat16 and Gumbel-perturbed routing during training.
Implementation checks. Automated router mechanism tests pass. With fixed K, the modified backend matches the official implementation exactly at sequence lengths 32 and 96 (maximum absolute and relative error zero). For M = 8, where the chunked kernel's backward path is unsupported in the tested library version, training and evaluation use the mathematically equivalent fused recurrent fallback; gradients are finite at length 96.
B Complete Variant Definitions
C Further Diagnostic Results
In a retained seed-1 routing diagnostic, the observed 10th/50th/90th percentiles of among written tokens were 1.00/2.55/7.89 for learned-gate Feature Recall, 3.00/5.36/8.00 for always-write Feature Recall, 2.50/4.00/5.50 for learned-gate Passkey, and 3.50/4.50/6.00 for always-write Passkey. These ranges verify that the adaptive router does not collapse to a constant allocation
| Variant | Token selection | Slot allocation |
|---|---|---|
| Dense | always write | fixed K = M |
| Always/fixed | always write | fixed K |
| Always/adaptive | always write | Eq. 17 |
| Learned/fixed | learned | fixed K |
| Learned/adaptive | learned | Eq. 17 |
| Oracle/fixed | fact labels | fixed K |
| Oracle/adaptive | fact labels | Eq. 17 |
Table 4: The symmetric factorial design distinguishes token selection from slot allocation.
in that run. Because the percentile diagnostic has not been aggregated over all ten seeds, it is mechanistic evidence only; the accuracy conclusions rely on Table 3.
D Planned Confirmatory Tests
A submission-strength follow-up should (i) replicate the five paired contrasts in Table 7 on an independent seed set, (ii) sweep future-relevant token density while controlling fact count, distance, and query count, (iii) compare fixed and adaptive allocation at matched write budgets and cross with , (iv) compare update-before-read, read-before-write, and read-only query handling, and (v) add natural-text retrieval benchmarks plus measured latency and memory.
E Implementation and Configuration Details
Model and optimization. All runs use a two-layer recurrent model with hidden dimension 256, four heads, an expansion factor of four, no positional encoding, and approximately 1.91M parameters. Key, value, and token-type embeddings form the input, and value embeddings are visible only at fact positions. Models are trained for 2,000 steps with AdamW (Kingma and Ba, 2015), batch size 16, learning rate , weight decay 0.01, gradient clipping at 1.0, and bfloat16 arithmetic. Gumbel perturbations (Jang et al., 2017) are applied to routing logits during training. Checkpoints are selected by validation accuracy, with validation loss used to break ties.
Routing search space. The fixed-width grid is , subject to ; dense routing uses . Adaptive routing uses , , mass threshold , and gate threshold 0.5. For the learned-gate and no-gate adaptive variants, we search . The reported mechanism study uses . Within each task and method family, we retain configurations within 0.005 validation accuracy of the family best and select the one with lowest .
Table 5: Validation-selected configurations for the mechanism study in Table 3. These are configuration details, not additional test results.
| Task | Method | Selected config. |
|---|---|---|
| Feature Recall | RAVEN-DENSE | K=16 |
| RAVEN-FIXED | K=4 | |
| FWR-NOGATE | ||
| FWR-FIXED | K=4 | |
| FWR-ADAPTIVE | ||
| ORACLE-FIXED | K=4 | |
| ORACLE-ADAPTIVE | ||
| Passkey | RAVEN-DENSE | K=8 |
| RAVEN-FIXED | K=4 | |
| FWR-NOGATE | ||
| FWR-FIXED | K=4 | |
| FWR-ADAPTIVE | ||
| ORACLE-FIXED | K=4 | |
| ORACLE-ADAPTIVE |
Evaluation and implementation checks. The primary comparison uses M = 16, seeds 1–10, and 30 evaluation batches per test condition. The mechanism study also uses seeds 1–10, with M = 16 for Feature Recall, M = 8 for Passkey, and 10 evaluation batches per condition. Runs use deterministic PyTorch execution on an NVIDIA RTX A6000. The modified fixed-K path matches the official RAVEN implementation exactly at sequence lengths 32 and 96. For M = 8, we use the mathematically equivalent fused recurrent kernel because the tested chunked-kernel backward path does not support that slot dimension. The two-sided intervals in Tables 2 and 7 are Student-t intervals over ten within-seed differences; Table 3 reports sample standard deviations across seeds.
F Auxiliary Comparison of Single-State and Multi-State Memory
The main experiments begin with a memory divided into recurrent slots. Within this setting, FWR asks two questions: whether the current token should write to memory, represented by , and, conditional on writing, how many slots it should update, represented by . This appendix steps back to a more basic architectural question: why use multiple recurrent memory slots in the first place? Specifically, we examine whether separating one recurrent state into several routed states
Table 6: Auxiliary comparison of single-state and multi-state memory under the earlier prototype protocol. The metric is best validation accuracy, not the LONGMEAN test metric used in the main experiments. Three-run entries are mean standard deviation; rows without error bars contain one run. GLA-style is an internal lightweight gated baseline rather than an official GLA implementation. Bold marks the highest observed value within each pilot task, not a statistically established winner.
| Pilot task | Train-evaluation setting | Model and memory organization | Runs | Best val. accuracy |
|---|---|---|---|---|
| Feature Recall | 32 → 256 facts | Linear: one state | 1 | .661 |
| GLA-style: one gated state | 3 | .673 ± .005 | ||
| CRLA: 16 soft-routed states | 3 | .861 ± .005 | ||
| Feature-Passkey | context/facts:128/32 → 512/128 | Linear: one state | 1 | .678 |
| GLA-style: one gated state | 3 | .715 ± .010 | ||
| CRLA: 16 soft-routed states | 3 | .818 ± .029 | ||
| Softmax: full-prefix access | 3 | .805 ± .043 |
Table 7: Pre-specified paired contrasts across seeds 1–10 for the validation-selected configurations in Table 3. favors the first method. Confidence intervals are two-sided Student-t intervals over seed-wise differences. The three fixed-allocation contrasts hold K = 4 constant.
| Task | Contrast | ΔLONGMEAN | Paired 95% CI | Evidence | |
|---|---|---|---|---|---|
| Feature Recall | Learned vs. always, fixed K = 4 | -0.1347 | [-0.1481, -0.1213] | -7.20 | Always favored |
| Feature Recall | Adaptive vs. fixed, learned gate | -0.0593 | [-0.0744, -0.0442] | -2.81 | Fixed favored |
| Passkey | Learned vs. always, fixed K = 4 | +0.1741 | [0.1688, 0.1794] | 23.60 | Learned favored |
| Passkey | Adaptive vs. fixed, learned gate | -0.0225 | [-0.0279, -0.0171] | -2.98 | Fixed favored |
| Passkey | Oracle vs. learned, fixed K = 4 | +0.1507 | [0.1451, 0.1563] | 19.14 | Oracle favored |
can improve associative recall.
We study this question using an earlier auxiliary prototype, Capacity-Routed Linear Attention (CRLA). The Linear and GLA-style controls maintain one recurrent state per head. CRLA-16 instead maintains 16 such states and uses soft routing weights to distribute every token across them. In the notation of the main paper, CRLA has neither a binary write decision nor a discrete allocation width : every token writes, and all 16 states receive weighted updates. CRLA also uses a different recurrent update from RAVEN. Thus, this pilot compares one recurrent state with multiple softly routed states, whereas the main RAVEN/FWR experiments compare write policies after the -slot memory architecture has been fixed.
The pilot predates the controlled RAVEN study and differs from it in model scale, recurrent update, checkpoint selection, seed coverage, and evaluation metric. We therefore report it separately and do not compare its numerical values directly with Tables 2 and 3.
Within this separate protocol, the 16-state prototype has the highest observed validation accuracy on both pilot tasks. On Feature-Passkey, its observed accuracy is also numerically similar to softmax attention. This pattern is consistent with the motivation for using multiple recurrent memory slots: separating stored associations across routed states may reduce interference. It does not, however, establish a controlled architectural ranking. The seed coverage is unbalanced, the metric is selected on validation data, and CRLA differs from the controls in more than state count alone. Most importantly, the pilot does not test either the FWR write gate or adaptive- allocation; its role is only to motivate the multi-slot starting point used by the main RAVEN/FWR study.