arXiv:2610.24135cs.LGOct 2026

Manuscript Offprint

arXiv:2610.24135

Inside the Loop: A Mechanistic Study of Weight-Tied Transformers on Depth-Bound Algorithmic Tasks

Magnus Sesodia, Juil Sock, Philip Torr, Christian Schroeder de Witt

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

Abstract

Solving algorithmic tasks with many sequential steps typically requires scaling up transformer depth or chain-of-thought length, incurring unfavorable parameter and inference-compute costs, respectively. Looped transformers, which reuse one block of layers across many iterations, are poised to address this, since they scale effective depth without adding parameters or tokens. Yet, it remains unclear what each iteration is actually computing, or whether the loop merely simulates a deeper untied stack. Here, we study directed permutation traversal, in which a model follows HH hops from a starting node and reports the node it reaches, so every intermediate hop has a known ground truth. We find that a minimum effective depth is necessary to solve the task, beyond which the degree of weight tying becomes the determining factor. For instance, a looped transformer with a four-layer block iterated eight times solves the task in every seed, while an identically-trained untied transformer of the same effective depth never does, succeeding only with a lower learning rate or supervision of its intermediate layers. Probing and intervening on the residual stream, we find that the looped model advances through the intermediate nodes gradually, forming a staircase that adapts to its iteration budget, whereas the untied model, at that lower rate, exposes them only in its final layers. Taken together, our results recast looped transformers as iterative program learners, which allocate their iterations to successive steps of the algorithm and solve tasks that identically trained untied models of the same effective depth do not. Code is available at https://github.com/magnus-sesodia/insidetheloop.

Reference hop

Figure

Figure 1: Looped model forms a staircase. Linear-probe selectivity for each hop of the 8-hop DEPO task (illustrated at left), in a 4×84 \times 8 looped model (left map) and an untied 32-layer model (right map), both trained at η=3×10−4\eta = 3 \times 10^{-4}. White dots mark where a hop first reaches selectivity 0.5, and crosses mark hops that never do.

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

1 Introduction

Looped transformers have become an active front in latent reasoning thanks to their ability to scale computation without adding parameters or tokens. Where an untied transformer passes each input through its stack of layers just once (T = 1), a looped model passes it T≥2T \geq 2 times by feeding the hidden state at the end of each iteration back to the start, multiplying the effective depth by T. While the idea of a depth-recurrent transformer is not new (Dehghani et al., 2019; Lan et al., 2020), it had been sitting largely dormant until recent strong performance at multi-billion-parameter scale (Geiping et al., 2025; Zhu et al., 2025) brought this paradigm back into the spotlight, triggering a proliferation of work spanning new variants, scaling laws and theory.

The most obvious benefit of looping is parameter efficiency, since a block reused T times occupies a T-th of the storage of an untied stack of the same depth. A second advantage is latent bandwidth, since looped models reason exclusively in hidden states, which forgoes the need to throttle intermediate computation into discrete chain-of-thought tokens (Hao et al., 2025; Xu and Sato, 2026). But the strength of looped models which we investigate in this paper is their purported inductive bias toward iterative computation (Giannou et al., 2023; Saunshi et al., 2025). Logically, weight tying should favor the learning of a repeated function, predisposing looped models to multi-hop reasoning and step-by-step algorithms. Yet it is unclear whether a looped model actually runs such an algorithm, advancing the solution by one step per iteration, or merely simulates a deeper untied stack with fewer parameters. The distinction matters for model design, since if the loop runs an algorithm, its iteration budget sets how many steps each iteration must take. So far, mechanistic studies of hidden-state trajectories have not settled this question (Blayney et al., 2026; Chen et al., 2026; Curth et al., 2026; Lu et al., 2025), in part because natural text offers no ground truth for intermediate states.

We work in a controlled setting using directed permutation traversal (DEPO), a task from the physics-of-LMs lineage (Allen-Zhu and Li, 2025; Ye et al., 2025) akin to the knowledge-graph walks that Kohli et al. (2026) use to study recurrent-depth transformers. Here, the model is presented with the edges of a cycle of N nodes in shuffled order and reports the node reached after H hops from a given start node (Figure 2). This gives us a clear difficulty knob in the number of hops required H and, crucially, every intermediate hop h has a known node. Thus, we can ask not just whether the final answer is correct but where in the network each intermediate node becomes decodable, although none is ever supervised. This separates the two explanations, as an iterative algorithm predicts that the state after iteration t encodes hop t, while a simulated deep stack need not tie nodes to iterations.

We begin by asking: do looped models outperform untied models at matched effective depth? If they do, a natural explanation is that weight tying steers training toward an iterative algorithm, in which one update is reused at every iteration. Such an algorithm should leave evidence in the model's intermediate states, motivating the follow-up question: does each loop iteration advance the computation by a fixed number of hops? We answer it using linear probes on the hidden state after every layer, the model's own logit lens and activation patching.

References (49)