Manuscript Offprint

arXiv:2611.04327

Anchor: Augmented Cross-Layer Recurrent State for Long-Context Retrieval in Test-Time Training

Vimal William, Yuanzhe Li, Danella Zhao, Huanrui Yang

ABSTRACT

Parameter-efficient linearization turns a pretrained autoregressive Transformer into an efficient model by hybridizing sliding-window attention (SWA) with a constant-size recurrent memory. But does every layer's recurrent state contribute to long-context retrieval? Investigating an SWA and Test-Time Training (TTT) hybrid, we find that retrieval is sparse across depth, concentrated in a few anchor layers, and that the remaining states hold similar information expressed through layer-specific transformations. We exploit both observations in ANCHOR: TTT memory placed only at the anchor layers, and a cross-layer recurrent state written once and read by many layers, each through its own learned read map that realizes a layer-specific stretch and rotation, along with demonstrated generalization to other hybrid attentions. On Llama-3.1-8B and Mistral-7B, ANCHOR delivers 2.3–3.1× higher recall and 6.7–8.9 points higher MMLU accuracy than LoLCATs with a 10× smaller recurrent state, retains 91–95% of the teacher's MMLU accuracy, and cuts end-to-end latency by up to 4.3× relative to softmax attention.

1 INTRODUCTION

The self-attention mechanism at the core of large language models (LLMs) computes a similarity between every query and every preceding key, so both compute and memory grow with the sequence length. During autoregressive decoding, the keys and values of all previous tokens are retained in a KV cache that grows linearly with context, requiring O(Nd)\mathcal{O}(Nd) memory per layer for a sequence of length NN and head dimension dd, while attention over the full sequence costs O(N2d)\mathcal{O}(N^2d). This cache is what gives attention its defining property: every earlier token remains individually addressable, and recall over long contexts stays exact. It is also what makes long-context inference expensive. The cache must be held for the lifetime of a request and re-read at every decoding step, so it, rather than arithmetic, bounds the batch size a server can sustain and therefore the throughput it can deliver. As context windows extend from thousands to hundreds of thousands of tokens, the memory required to preserve exact recall becomes the dominant cost of deployment. This tension, between the growing state that gives attention its recall and the bounded state that makes inference affordable, motivates architectures that retain long-range information in a memory whose size does not grow with the context.

A natural response is to impose an upper bound on the state.

Figure

Figure 1. Recurrent states across layers are redundant, so one shared state suffices. Left: Debiased CKA between the TTT states of every pair of layers in Llama-3.1-8B, measured on WikiText for targets beyond the local window. The anchor layers ( ℓ∈{0,1,28,…,31}\ell \in \{0, 1, 28, \ldots, 31\}, dashed boxes) are strongly aligned with one another (mean CKA 0.92), whereas the interior layers are not (0.49). Right: Number of recurrent states per block as the ratio of hybrid to softmax-attention layers grows. A per-layer design keeps one state per hybrid layer; ANCHOR keeps a single shared state, reducing the count by 3−6×3-6\times.

Recency-based and importance-based architectures do so by restricting which past positions each query may attend to: sliding window attention (Beltagy et al., 2020) retains the w most recent tokens, and sparse attention (DeepSeek-AI et al., 2025) selects a fixed budget of earlier positions. The cache is then bounded at O(wd)\mathcal{O}(wd) and the per-token retrieval cost becomes independent of the sequence length, restoring a predictable memory footprint at serving time. The bound, however, is enforced by discarding information rather than

1^{1}School of Electrical, Computer & Software Engineering, University of Arizona, Tucson, AZ, USA. Correspondence to: Huanrui Yang huanruiyang@arizona.edu.

Preprint.

by compressing it. A token outside the retained set is no longer addressable at any later step, and no subsequent computation can recover it. The width ww therefore fixes the receptive field of the architecture, and recall falls away once the distance between a query and its target exceeds that width. Bounding the state exchanges one limitation for another: the memory cost no longer grows with context, but neither does the span over which the model can retrieve.

The observed inefficiency in the recall accuracy due to the limitation in the receptive field motivates extending the receptive field through embedding a constant-sized recurrent state (Chen et al., 2021; Dong et al., 2024; Arora et al., 2025; Zhang et al., 2025; Lan et al., 2025; William et al., 2026) to enable longer-context retrieval without a major increase in memory footprint and with the retrieval complexity of O(d2+wd)\mathcal{O}(d^2 + wd). The recurrent state extends the span over which information is retained, but it remains an imperfect substitute for an explicit cache. Its capacity is limited by the low rank of the outer-product update, and because the state is written at every step with no mechanism for forgetting, recent tokens progressively overwrite earlier ones. A line of work addresses these limitations by modifying the update rule rather than the state itself: gating and decay terms control how much of the existing state is preserved at each step (Yang et al., 2023), and attentional-bias formulations replace the plain key-value association with an objective optimized online (Behrouz et al., 2025; von Oswald et al., 2026), connecting the update to the in-context learning behavior observed in large language models (von Oswald et al., 2026). These refinements improve how the state is written. The state itself, however, remains a single fixed-size summary maintained independently in every layer, and how much of it each layer actually requires has not been examined. This gap in understanding how long-term memory is distributed across depth leads us to ask: does long-context retrieval require a recurrent state in every layer and do states share information?

As a first step toward answering this question, we study the behavior of recurrent states in a hybrid attention formulation on the associative recall (AR) benchmark, and measure the similarity between the states of different layers using centered kernel alignment (CKA) and cosine similarity. Two observations follow (Figure 1): long-context retrieval is sparse across depth, concentrated in a small set of layers, and the states that carry it hold closely related information. Together these motivate ANCHOR, a recurrent state shared across layers rather than maintained independently in each, which we instantiate as a family of configurations spanning training and deployment. Our contributions are as follows:

  1. Linearization for TTT states. We extend the two-stage linearization recipe to Test-Time Training recurrent states, and show that supervising attention transfer

with a next-token objective prevents the collapse that output matching alone produces (Section 3.1).

  1. The anchor effect. We find that long-context recall is concentrated in a small set of boundary layers: disabling the TTT update in the remaining 26 layers leaves perplexity unchanged while shrinking the recurrent state by 5.3×5.3\times (Section 3.1).

  2. Cross-layer recurrent state. Layer states turn out to encode closely related information in different bases, which lets a single state serve many layers through learned per-layer read-maps χℓ(⋅)\chi_\ell(\cdot) (Section 3.2).

  3. ANCHOR. The resulting family spans training and deployment and reaches 4.3×4.3\times higher end-to-end throughput compared to vanilla softmax attention at 16×16\times smaller recurrent state than per-layer hybrids, at comparable accuracy (Section 4.2).

References (43)