Manuscript Offprint

arXiv:2610.19768

Learning to Compute Is Not Learning to Retain or Reuse in Looped Transformers

Peilong Zhou, Hongtao Zhang, Yulong Huang, Cangyuan Li, Mingyu Chen, Ying Wang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Looped transformers compute by applying one block repeatedly, so they can run for more loops than they were trained with. Recurrent reasoners are known to overthink: iterating past the trained depth can turn a correct answer into a wrong one. Such a late error can reflect failed computation, loss of retention, or a state that later computation cannot reuse. We separate these cases in in-context Mealy-machine execution, where a simulator supplies intermediate targets and exact counterfactuals for hidden-state interventions. Models trained to answer at loop 32 are fully correct there but keep only 22% of these answers at loop 64. Retention depends on what training asks for: supervising one randomly chosen position per example, instead of always the last, keeps 99.8%, and randomizing the number of training loops also helps; truncating gradients, as in progressive training against overthinking, does not. The computation itself is exact: position k is computed at loop k, and swapping its loop-k hidden vector for the one from another input redirects every later position to that input's exact continuation (237/237 pairs in each of ten models). Retention, however, is not reuse. Even in models that keep nearly all answers, holding each position k fixed from loop k drops accuracy to 4–6%, whereas holding it from loop k+4k + 4 is harmless. A released recurrent maze network trained to avoid overthinking behaves the same way. Learning to compute is thus not learning to retain, and avoiding overthinking does not make a state reusable when its answer first appears.

1 INTRODUCTION

Looped transformers turn recurrent depth into a computation budget: one block is applied repeatedly, so a model can run for more loops than it was trained with (Dehghani et al., 2019; Giannou et al., 2023; Geiping et al., 2025). Whether those extra loops help depends on what happens to an answer after it has been computed.

Empirically, running past the trained depth can hurt. Recurrent networks trained on small instances can solve larger ones by iterating longer (Schwarzschild et al., 2021), but further iteration can also turn a correct answer into a wrong one. Bansal et al. (2022) call this failure overthinking and prevent it with input recall and progressive training, which applies the loss at a random depth and blocks gradients to the loops before a random starting point. Later work relates extra computation to path independence and shows that training and stopping objectives change the learned trajectory (Anil et al., 2022; Zhang et al., 2026; Kuo et al., 2026; Popescu et al., 2026); analysis of recurrent language models separates whether content is readable from whether it is transported and can be steered (Wang & Reid, 2026). Much of this evidence tracks accuracy or readouts across loops. An overthinking curve, however, can mean three different things: the answer was never computed, it was computed but not retained, or the state that carries it cannot be reused by later computation. Telling these apart requires knowing what a correct alternative execution would be. We therefore ask: when a looped model learns to compute an answer, what does it learn about retaining that answer and reusing its internal state?

In-context execution of Mealy machines makes these distinctions measurable (Figure 1). Each example gives a transition table and an input sequence of length H. A simulator supplies the correct state and output at every position, including after any counterfactual change, so an intervention can be scored against a unique correct continuation rather than by whether the output changed. We apply one shared transformer block for R loops and train only on the readout after the last loop, the exit; the main models use R = H, one loop per input symbol, and compare objectives that differ only in which answers must be correct at that exit: the last position (FINAL-ONLY), every position (ALL-PREFIX), or one uniformly sampled position per example (SAMPLED-PREFIX). Endpoint accuracy requires both the state and the output at the last position to be correct. In the models we analyze, position k first becomes correct at or near loop k; we call the diagonal r = k the frontier. Because the loop at which each answer first appears is known, a state can be tested at exactly that moment. We intervene on the recurrent trajectory in three ways: replacing a hidden vector in a base run with the corresponding vector of a source run on a different input prefix (Geiger et al., 2024), resetting a position to its own earlier vector, and freezing each position at a chosen loop. At the frontier, one position's hidden vector suffices to drive the rest of the execution, so the same unit lets us compare what a state makes readable with what it lets later computation do.

The three properties come apart. In the order of the paper, we find:

• Retention is set by what training requires (Section 3). On shared length-32 test inputs, FINAL-ONLY models are 100% correct at the trained exit but 22.3% at loop 64 (Figure 2). ALL-PREFIX gives 94.3%, and SAMPLED-PREFIX gives 99.8% with the same single supervised position per example as FINAL-ONLY. At a matched expected budget, drawing the exit as R=H+UR = H + U with U uniform on {0,…,8}\{0, \ldots, 8\}, instead of fixing R=H+4R = H + 4, raises loop-64 accuracy from 30.0% to 85.6%. Truncated gradients do not help: our adaptation of progressive training learns length 32 in one of three seeds, whereas a MATCHED RANDOM EXIT control with identical exits and full gradients learns it in all three and keeps 97.9% at loop 64.

• Computation is exact, but its answers are transient (Section 4). Replacing one hidden vector at the frontier redirects every later frontier readout to the exact counterfactual execution in all 237 pairs whose counterfactual differs, in each of ten FINAL-ONLY models (Figure 3). These answers fade soon after they are computed, in swapped and unmodified runs alike.

• Answers become readable before their states become reusable (Section 5). Freezing each position k from the loop at which its answer first becomes readable, as per-position halting would and with no other run or label involved, reduces endpoint accuracy from 100% to 4.1% under SAMPLED-PREFIX and to 6.3% under MATCHED RANDOM EXIT, two objectives that retain answers well (Figure 4). Freezing two to four loops later restores it. A released recurrent maze network that never loses a solved maze solves none of 32 mazes when each pixel is frozen at its answer's arrival, and all of them when frozen four iterations later.

These interventions separate the three properties; they do not identify a microscopic cause of ordinary decline or give a general repair. The main evidence comes from one synthetic task family and one architecture, with a limited external check (Section 7).

References (66)

  • Path independent equilibrium models can better exploit test-time computation
  • End-to-end algorithm synthesis with recurrent networks: Extrapolation without overthinking
  • Universal transformers
  • Looped transformers for length generalization
  • Causal abstractions of neural networks
  • Finding alignments between interpretable causal variables and distributed neural representations
  • Scaling up test-time compute with latent reasoning: A recurrent depth approach
  • Looped transformers as programmable computers
  • Stabilizing extrapolation in looped transformers via learned stochastic stopping (opens arXiv in a new tab)
  • (How) do language models track state? In International Conference on Machine Learning (ICML), 2025
  • Transformers learn shortcuts to automata
  • Adaptive depth in looped transformers: Diagnosing learned halting gates and trajectory readouts (opens arXiv in a new tab)
  • Can you learn an algorithm? Generalizing from easy to hard problems with recurrent networks
  • Looped Transformers under the Jacobian Lens: Does the Global Workspace Survive Recurrence?
  • When does recurrence become an algorithm? convergence selection in weight-tied looped transformers (opens arXiv in a new tab)
  • Finite state automata inside transformers with chain-of-thought: A mechanistic study on state tracking
  • Generation fixes an internal initial state $S_0$ and first makes every state reachable
  • A training batch contains 256 examples of the same sampled horizon
  • It blocks all access to future actions
  • Dropout is zero
  • Both task losses have weight 1 and use mean cross-entropy over the selected valid positions
  • The endpoint curve reports $N^{-1} \sum_{i} Q_{i,H}^{r} Y_{i,H}^{r}$
  • On a separate clean grid (evaluation stream 20260903, 512 examples per model), all ten models have $\tau(k) = k$ at every position $k = 1, \ldots, 32$, with state and output accuracy 1.000 on the diagonal
  • The clean base run is not jointly readable there either (mean per-position agreement 38.1% over positions 9–32), so this contrast concerns readout time; it shows neither erased information nor a unique state code
  • Independent patch scans replace a width-one window of positions at loop l
  • It samples 256 different-state pairs and 256 same-state pairs per checkpoint, in sixteen batches of sixteen per pair kind
  • It crosses source collection at c or $c + a$ with base insertion at those same two loops, reading position $c + d$ after exactly d further updates
  • Same-symbolic-state sources come from another history and are a substantive intervention, not an identity control
  • Model seeds are independent parameter initializations, whereas reused machine/pair samples are paired observations
  • The existing FINAL-ONLY and ALL-PREFIX checkpoints are re-evaluated; no baseline is retrained or selected by its score
  • We adapt the progressive loss of Bansal et al. (2022) to the same FSM Transformer
  • The first four conditions reach 100% endpoint accuracy at r = 32 for all three seeds
  • Table A8 evaluates the frozen Slack-4/Jitter-8 models on the same length-32 stream, evaluation seed 20260909, with 512 examples per model
  • Thus the all-prefix result is not only a more reliable final readout; it preserves a substantially larger fraction of complete recurrent trajectories
  • Slack-8 is a deterministic extra-slack dose control: its H32 endpoint means are $100.00\%$ at its trained exit $R = 40$, then $92.74\%$, $57.94\%$, and $44.21\%$ at $r = 48, 64, 96$, respectively (six seeds, same stream and model recipe)
  • It is a maximum over sampled horizons, not a proof of correctness at every intermediate or greater length
  • The 256 different-state pairs are shared across models; 242 have distinguishable counterfactual targets
  • At exit 32, clean exactness is .007 versus 1.000 and source exactness is .002 versus .722
  • Swap at position 16; six paired models per condition
  • Clean results score the unmodified base run's own suffix over all 256 pairs; swap results score the source counterfactual on the fixed 242 eligible pairs
  • >Readout</td><td rowspan=
  • All vectors are at position 16
  • Twelve paired budget-sweep files and ten original swap files matched byte-for-byte between the local and remote evidence stores
  • The reported conclusions depend on the fixed-checkpoint behavioral evaluations, full-vector interventions, and paired training comparison described above
  • six FINAL-ONLY and six ALL-PREFIX models, with paired seeds 9–14
  • (a) The base run is held at loop 20 (gray band)
  • After loop 20, a single post-block, pre-final-normalization hook performed a $2 \times 2$ intervention:
  • It was neither factual accuracy nor suffix exactness
  • The ALL-PREFIX late clean arm has zero counterfactual accuracy because it correctly retains the distinct factual answer; its factual joint accuracy on these pairs is 100%
  • These are descriptive within-model contrasts, with model seeds as the replication unit, rather than significance tests that pool reused task pairs as independent replications
  • Fresh sources were jointly correct on all different-state pairs in both conditions
  • Fresh source plus reset restores 95.18%, matching the fresh reference and its roughly 4.8% substitution damage
  • All preserved the corresponding clean predictions; saved pre-intervention invariants also passed
  • The aged-source comparison shows that downstream restoration alone does not make every readable source interchangeable
  • The schedule is fixed before scoring: models trained at $R = H$ use $s(k) = k$
  • The larger models use $d = 512$ and four layers per block and a batch size of 32, so they are not paired input by input with the other rows
  • It was specified after inspecting their clean retention results and before inspecting their freeze results; it is exploratory
  • Min. diagonal
  • The reference schedule $s(k) = k$ is fixed before evaluation and is not estimated from the new labels
  • For a delayed arm, the endpoint has not yet been captured at $r = 32$
  • Immediate freezing reduces mean endpoint accuracy to 4.10% for SAMPLED-PREFIX and 6.25% for MATCHED RANDOM EXIT, with zero whole-trajectory exactness in every model
  • The recurrence was replayed by an external loop that reproduces the released forward pass exactly; a never-triggering hook reproduced the clean arm, and every arm matched clean before its first capture
  • The limits are substantial
  • Capture +d
  • Pooled over the $d = 128$ models, the position-31, position-32, and combined resets recover 585, 143, and 771 of 771 members of $E$
  • Its success therefore localizes the first failure to the last two positions; it does not show that a restored state persists