Manuscript Offprint

arXiv:2609.39892

Shared Weights, Selected Computations: How Looped Transformers Route What Each Loop Does

Jiaju Wu, Yi Hu, Muhan Zhang

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

ABSTRACT

Looped Transformers repeatedly apply the same set of Transformer layers, giving them a recurrent architecture for latent computation. Their strong performance on iterative reasoning and length-generalization tasks suggests an appealing explanation: recurrence may provide an inductive bias that lets the model reuse a learned algorithm across loops. However, weight sharing alone does not imply that every loop performs the same operation. This raises a basic question: is each loop actually repeating the same computation, and if not, what routes the shared parameters to different operations? We study this question using graph walks as a test case. In the model's native trajectories, decoded predictions can advance by different numbers of graph steps or remain at a reached target, showing that recurrent progress need not follow a fixed one-loop-one-step pattern. We then show that a frozen loop can be steered toward different transitions by modifying its entering hidden state: a learned linear layer J selects the desired transition without changing the shared Transformer layers. To test how this steering works, we use activation patching and find that attention patterns can recover its effects and switch the selected transition. Across five matched pairs of graph models, changing intermediate supervision during backbone training changes which transitions J can induce. This suggests that J selects computations learned by the backbone rather than creating new algorithms. Together, these results show that the hidden state can control shared computation, with attention routing as a causal pathway.

Code and reproduction materials: https://github.com/wjjpku/howloop

1 INTRODUCTION

Recent work on latent reasoning studies how models can carry out multi-step reasoning within their hidden states, without generating every intermediate step as text (Saunshi et al., 2025; Geiping et al., 2025). Recurrent architectures provide a natural way to support this kind of computation: the same parameters can be applied repeatedly while the internal state continues to evolve. Looped Transformers bring this idea to Transformer models (Vaswani et al., 2017) by reusing the same set of Transformer layers over multiple loops (Dehghani et al., 2019; Yang et al., 2024). This recurrent design provides a useful inductive bias for iterative computation. Looped Transformers can learn iterative learning algorithms and multi-step optimization procedures (Yang et al., 2024; Gatmiry et al., 2024), improve length generalization on tasks with iterative solutions (Fan et al., 2025), and use additional loops as a source of latent test-time computation at language-model scale (Geiping et al., 2025; Zhu et al., 2025). These results suggest that recurrent depth can provide a way to reuse learned computation over multiple internal steps.

These results naturally suggest an iterative view of Looped Transformers: the shared layers may repeatedly apply the same learned procedure as computation progresses. For example, in a graph walk, one might expect every loop to move one step along the path. Yet weight sharing does not imply such a fixed correspondence. The parameters are shared across loops, but the hidden state entering those parameters changes as computation proceeds. The same network is therefore applied to

1^{1}Institute for Artificial Intelligence, Peking University. 2^{2}School of Mathematical Sciences, Peking University. Correspondence to: Muhan Zhang muhan@pku.edu.cn.

different internal states, so weight sharing alone does not specify what operation each loop performs. The training objective can also leave the intermediate trajectory underdetermined. When only the final answer is supervised, the loss does not require the model to follow any particular sequence of intermediate steps. This leads to a basic question: is each loop actually repeating the same computation, and if not, what routes the shared parameters to different operations? Answering this question is important for understanding the inductive bias of recurrent depth and the internal process of latent reasoning. It also affects when additional loops provide useful computation and whether recurrent test-time computation can be controlled.

Prior work has gradually moved from asking whether recurrence can implement algorithms to studying how learned computation is organized across loops. Constructive results show that fixed-weight Looped Transformers can execute multi-step programs, while learning-based analyses show that looped models can learn iterative optimization procedures (Giannou et al., 2023; Yang et al., 2024; Gatmiry et al., 2024). These results establish that shared parameters can support reusable algorithmic computation, but they do not specify how that computation is distributed across loops after training. Mechanistic work therefore turns to the learned recurrent trajectory itself. Blayney et al. (2026) identify layer-wise fixed points, cyclic latent trajectories, and repeated stages of inference across loops. Probing studies likewise find that intermediate recurrent states do not always form a simple, directly readable latent chain of thought (Lu et al., 2025). More recently, Zhang et al. (2026) study task progress across loops directly. They show that training can select computation frontiers with different speeds, so the amount of progress associated with one loop is learned rather than fixed by weight sharing. Together, these studies characterize how recurrent computation is learned and organized across loops, but leave open whether the state entering a loop can causally select what the same frozen layers compute next, and how this selection is implemented inside the model.

We address these gaps by testing whether the entering hidden state can redirect the next computation of a frozen loop, and by tracing this control to attention routing (Figure 1). We begin with the recurrent trajectories that arise without intervention. In graph-walk tasks, native readouts can advance

Figure

Figure 1: Overview of looped computation and state steering. Phenomenon: intermediate readouts reveal different patterns of progress across weight-shared loops. Control: a learned linear layer changes the state entering the next loop to select a different transition while the backbone remains frozen. Mechanism: patching attention patterns from a steered run into an unsteered run transfers routing while preserving the receiving run's values, recovering steering effects. Flames mark trainable components; snowflakes mark frozen components.

at different numbers of graph steps or remain at an already reached target. A learned trajectory therefore need not follow a fixed “one loop = one algorithmic step” rule (Section 3). This variation makes the entering hidden state a natural candidate for controlling the next computation. We freeze the shared Transformer layers and learn a linear layer at the loop boundary. Changing only the entering state selects one-hop or two-hop targets for the same frozen loop (Section 4). Having established this control, we ask how it is implemented inside the loop. Patching attention patterns recovers much of the steering effect in the graph case study and the Ouro multi-hop language task. Patching patterns between one-hop and two-hop runs also switches the semantic target, providing causal evidence that routing carries the choice of transition (Section 5). Finally, we test how backbone training and repeated execution shape this control. Across five matched pairs of graph models, intermediate supervision during backbone training changes which computations J can steer. This supports the view that J controls computations learned by the backbone rather than creating new algorithms (Section 6). The controllers can be composed across two successive loops, but accuracy is order-dependent and drops with longer compositions (Section 4.2).

References (100)

  • A mechanistic analysis of looped reasoning language models (opens arXiv in a new tab)
  • Universal Transformers (opens arXiv in a new tab)
  • Looped Transformers for length generalization
  • Bridging the gap between latent and explicit reasoning with looped Transformers (opens arXiv in a new tab)
  • Can looped Transformers learn to implement multi-step gradient descent for in-context learning? In Proceedings of the 41st International Conference on Machine Learning, volume 235, pp. 15130–15152
  • Scaling up test-time compute with latent reasoning: A recurrent depth approach (opens the publisher in a new tab)
  • Looped Transformers as programmable computers
  • Latent chain-of-thought? decoding the depth-recurrent transformer (opens arXiv in a new tab)
  • Adaptive depth in looped Transformers: Diagnosing learned halting gates and trajectory readouts (opens arXiv in a new tab)
  • Reasoning with latent thoughts: On the power of looped Transformers (opens arXiv in a new tab)
  • Dense supervision is not enough: The readout blind spot in looped language models (opens arXiv in a new tab)
  • Representation surgery: Theory and practice of affine steering
  • Steering Language Models With Activation Engineering
  • Attention is All you Need
  • Interpretability in the wild: A circuit for indirect object identification in GPT-2 small (opens arXiv in a new tab)
  • Looped Transformers are better at learning learning algorithms
  • When does recurrence become an algorithm? convergence selection in weight-tied looped Transformers (opens arXiv in a new tab)
  • Scaling latent reasoning via looped language models (opens arXiv in a new tab)
  • Backbone training uses lengths 1–20, and map training uses lengths 20–40
  • At measured lengths 505–1000, accuracy is instead 47.55% without J and 36.40% with J (Figure 9a)
  • On an independent held-out cycle subset, accuracy falls from 97.42% at loops 9–16 to 35.11% at loops 17–32
  • Token IDs 0 and 1 represent bits, 2 marks the separator, and 3 marks padding
  • With padding, the first example becomes 1 0 1 1 2 3 3, and the target from the separator onward is 1 3 3
  • Backbone training uses lengths 1–20
  • We use causal attention without positional encodings
  • Backbone training uses 100,001 AdamW updates, batch size 64, learning rate $10^{-4}$, weight decay 0.01, and gradient clipping at 1.0
  • lengths 20–24 for 256 updates with batch size 64, lengths 20–32 for 512 updates with batch size 48, and lengths 20–40 for 1,024 updates with batch size 32
  • The extended evaluation starts at length 500 and samples every fifth length with 128 paired examples
  • The parity heatmaps use 256 examples for each input length and loop count up to 60
  • We estimate the positions of the accuracy bands from the period-four Fourier component along the offset between loop number and input length
  • This estimate describes the visible accuracy bands; it does not establish an oscillator in the hidden state
  • Near length 60, steering shifts the best nearby integer readout from $t = n - 1$ to $t = n$
  • Drift is measured in loops per 100 tokens; MAE is the mean absolute deviation from the fitted phase line
  • The query continues to specify depth 8 even when execution extends beyond eight loops
  • We use the final checkpoint
  • Training excludes both graph pools
  • The broad evaluation sample contains 8,192 unique graphs drawn uniformly without replacement from all 40,320 eight-node permutations, using seed 2026092402
  • We average over starting nodes and graphs, then over maps and backbones
  • Each value averages the two fixed maps
  • Its results are separate from the broad-sample curve
  • Appendix B gives the complete native readouts
  • Let $\hat{d}_t$ be the unique most frequent decoded path position across these 5,120 examples at loop $t$
  • Model readout increments through the final supervised loop; – marks an undefined increment due to a tie
  • Its edge records are EDGE 0 1, EDGE 1 2, and so on through EDGE 9 0
  • Both maps start from the same D8L6 state after loop 6 and are followed by one frozen loop
  • They replace internal attention quantities in already trained runs; they do not introduce a new training target
  • Target selection uses the ten-node D8L6 model trained with seed 6, at update 16,000
  • The input, backbone weights, and number of additional loops remain fixed
  • It uses pre-layer normalization, a layer-normalized readout, and no dropout
  • Both maps have the form $J(h) = h(D + AB) + b$, with hidden dimension 256 and rank 48
  • Only the map is trained
  • The following details describe the original seed-6 evaluation
  • All 1,024 identities are excluded from backbone training, map training, earlier mechanism evaluations and their generated variants, and the preceding 1,024-graph evaluation of the main D8L6 backbone
  • Recovery is scored among eligible clean transitions broken by query replacement, giving 4,413 and 4,417 cases
  • For each map fit, we bootstrap 5,000 samples of the 512 graph pairs
  • Sampling seed 2026092501 draws 512 fresh graphs from the training-excluded reserve, excluding previous evaluation graphs and their generated variants
  • We patch post-softmax patterns at all token positions and all four heads of layer 2
  • The first continuation applies a map to $h_6$ and executes the seventh loop
  • Each control that omits the second map is scored against the same cumulative target as the corresponding two-map sequence
  • Model parameters remain unchanged, and model, map, data, and code hashes are recorded
  • The primary set contains the same 3,200 instances with distinct $u, \ldots, f_G^4(u)$ at every sequence length
  • Successful control over one or two loops therefore does not ensure that the resulting states remain controllable over longer sequences
  • Mixed averages the 32 fixed random strings
  • The final column gives the mixed-sequence target accuracy at the eighth additional call
  • For seed 6, the four two-step accuracies are close to those in the original evaluation
  • We record the answer after $J$ but before $F$ and a baseline that simply copies $u$
  • Columns count additional calls after $h_6$
  • Seed 6 is the original case study
  • They follow the visual conventions of Figure 2
  • We average the fits within each backbone, then average the three backbone accuracies with equal weights
  • The selected second-layer heads are H0 and H3, respectively; seed 6 retains H2
  • Discovery and confirmation sets are disjoint
  • Patching between steered and native runs uses 4,044 instances for seed 6 and 4,111 for each new backbone
  • The comparison head is the next head modulo four
  • Alice passes the letter to Bob
  • The prompt includes all ten rules
  • We fine-tune the backbone on 1–4-step requests with four recurrent loops
  • The same map acts on every token before loops 2–4, and answer supervision remains at loop 4
  • Each update contains eight task examples
  • All Ouro mechanism tests use the letter-walk Ouro-2.6B checkpoint saved after 200 backbone updates and its dense affine map saved after 500 map updates
  • Each intervention experiment uses a separate evaluation set
  • The patched run keeps its own keys and values
  • We evaluate the third answer with a reference run that combines that graph and starting person
  • The controls patch only the steered values, patterns from an unrelated graph, loop-2 patterns into loop 4, or steered patterns at sixteen disjoint comparison heads matched by layer
  • Same-run output replacement and restoration of every affected output both yield zero maximum logit error
  • No generation is truncated, so the distinction holds under both scoring rules
  • Full steering reaches 251/256
  • It uses ten-node D8L8 models trained separately from the D8L6 control models and the eight-node continuation models
  • Adding the intermediate losses changes the total loss and gradient scale; these quantities are not normalized to match final-only training
  • Gradients pass through all eight loops
  • Three separately fitted maps target $u = f_G^8(s)$, $f_G(u)$, or $f_G^2(u)$ after one additional call to $F$
  • It acts on all tokens and starts as the identity
  • We use the same 4,137 instances with distinct $u$, $f_G(u)$, and $f_G^2(u)$ in every condition
  • Every fitted stay map reaches 100% accuracy in both regimes
  • Lines connect the two supervision regimes for the same backbone seed
  • Each pair of columns reports the two independently fitted maps for that target
  • >Seed</td><td rowspan=
  • Two-hop accuracy reverses this ordering: $50.5 \pm 15.2\%$ for final-only models and $13.2 \pm 6.8\%$ for stepwise models
  • At each step, the rule removes the leftmost adjacent antonym pair and joins the remaining words in their original order
  • Which two words are deleted on deletion number 2? Answer with only those two words in their original left-to-right order

Couldn't load all references. Reload the page to try again.