读这张图时需留意两个细节:其一,最右侧 Middle Looping(1 → 2...2 → 3) 中的底部模块 1、中部重复蓝块 2...2 与顶部模块 3,正好对应前文所述的 Prelude – Core – Coda 三段式分解;其二,Saunshi et al. 原图的符号 k 与 L 和本文定义恰好互换——图中的 (k ⊗ L) 表示将 k 个物理层循环 L 轮(而在本文正文中,物理核层数记为 $L_{\text{core}}$、循环轮数记为 $K$)。
对比这些具体结构配置就能注意到一个前提条件:被选入循环核的模块内部必须同时包含序列混合器(Attention 或线性状态层)与 FFN。这是因为标准 FFN 是纯粹的逐词独立映射,在位置方向上的通信半径严格为零。沿着一段两跳推理轨迹 A → B → C 追踪即可看清原因:假设上下文不同位置分别写有 A → B 与 B → C 两条事实,第 1 轮循环中 Attention 把位置 B 的中间线索读取并写入 A 所在的残差槽位;到了第 2 轮,Attention 才能凭借 A 槽位里刚写下的 B 继续跨位置检索 C,完成 A → C 组合。倘若只让 FFN 独自循环而把 Attention 剥离在循环外,第 2 轮 FFN 就完全看不到第 1 轮在其他位置上刚刚推算出的中间状态,跨位置的多跳信息组合能力在第一轮之后就会立刻断掉。
nostalgebraist (2020). interpreting GPT: the logit lens. LessWrong
David A. Mix Barrington (1989). Bounded-Width Polynomial-Size Branching Programs Recognize Exactly Those Languages in $\mathsf{NC}^1$. Journal of Computer and System Sciences, 38(1): 150–164.
Mostafa Dehghani et al. (2018). Universal Transformers. arXiv:1807.03819
William Merrill & Ashish Sabharwal (2023). The Parallelism Tradeoff: Limitations of Log-Precision Transformers. TACL 11, arXiv:2207.00729
William Merrill & Ashish Sabharwal (2024). The Expressive Power of Transformers with Chain of Thought. ICLR 2024, arXiv:2310.07923
Nikunj Saunshi et al. (2025). Reasoning with Latent Thoughts: On the Power of Looped Transformers. arXiv:2502.17416
William Merrill & Ashish Sabharwal (2025). A Little Depth Goes a Long Way: The Expressive Power of Log-Depth Transformers. arXiv:2503.03961
Jonas Geiping et al. (2025). Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approach (Huginn-0125). arXiv:2502.05171
In a standard decoder, layer $l$ transforms activations and hands them off to distinct layer $l+1$ without looking back. Unrolling a plain MLP dozens of times with the exact same weight matrix quickly explodes or collapses hidden states onto top eigenvectors. Yet looped Transformers routinely pass representations through the same shared weights 16, 32, or even 64 times.
Two foundational questions underlie this architecture. First, why does feeding identical weights back into themselves stay well-conditioned instead of overwriting earlier features? Second, can looping fixed weights in latent space actually compute classes of functions inaccessible to constant-depth models? The answers come from residual stream subspace geometry and uniform circuit complexity.
1. The Residual Stream: Subspace Addressing Across Shared Steps#
Pre-Norm Transformers support weight tying naturally because sublayers never replace earlier representations outright; instead, every pass reads from and adds deltas back onto one shared linear residual stream (Elhage et al., 2021):
Viewed through dynamical systems, the update $h_{t+1} = h_t + f_\theta(h_t)$ is the forward Euler discretization ($\Delta t = 1$) of an autonomous Neural ODE, $\frac{\mathrm{d}h(t)}{\mathrm{d}t} = f_\theta(h(t))$: because the vector field $f_\theta$ is time-independent, each iteration advances the state along a single stationary vector field.
Because every pass operates inside the exact same coordinate basis that ultimately projects into the unembedding matrix $W_U$, different iterations can reuse channels safely. Writing out single attention head $h$ ($d_h \ll d$) makes the mechanism explicit:
Right-multiplying $H$ by $W_V^h$ restricts reads to a low-rank column subspace $\mathrm{col}(W_V^h) \subset \mathbb{R}^d$, while $W_O^h$ adds results back into $\mathrm{row}(W_O^h)$. As long as $d_h \ll d$, high-dimensional residual space supplies plenty of nearly orthogonal slots so intermediate computations can communicate across steps without overwriting prior features.
Calculation
Worked Verification · 4D State Trace (Gated Non-Refiring): Suppose a token starts at $h^{(0)} = [0, 1, 0, 0]$, and the shared block implements two inhibitory-gated rules: $\Delta_3 = 2\,\mathrm{ReLU}(h_2 - h_3)$ and $\Delta_4 = 1.5\,\mathrm{ReLU}(h_3 - h_4)$. In Pass 1, $h_2 = 1,\, h_3 = 0$, giving $\Delta_3 = 2\,\mathrm{ReLU}(1 - 0) = 2$ and $\Delta_4 = 0$, updating the stream to $h^{(1)} = [0, 1, 2, 0]$.
In Pass 2, because dim 3 now holds $2 > h_2 = 1$, the inhibitory term $h_2 - h_3 = -1$ is clamped to $0$ by ReLU so step 1 does not re-fire; instead, the downstream channel reads $h_3 = 2$ and writes $\Delta_4 = 1.5\,\mathrm{ReLU}(2 - 0) = 3$, yielding $h^{(2)} = [0, 1, 2, 3]$ (settling at a fixed point at Pass 3). Because all steps share one coordinate basis, projecting intermediate states with Logit Lens (nostalgebraist, 2020) ($W_U h^{(t)}$) typically shows next-token confidence sharpening across iterations.
Backpropagation inherits the same identity shortcut:
While the $I$ term keeps gradients from decaying exponentially at initialization, it is not unconditional stability: eigenvalues of $J_t$ with $|1 + \lambda(J_t)| > 1$ still explode, and growing residual norms in unnormalized streams shrink Jacobians at subsequent Pre-Norm entrances. Stabilization strategies are analyzed in Keeping Deep Looped Transformers Stable: Norm Growth, Sandwich Norm, and TBPTT.
Figure 1: The residual stream acts as a shared bus enabling gated multi-step orthogonal subspace updates across iterations.
2. Physical Depth vs. Effective Depth, and Why Attention Stays Inside the Loop#
Evaluating looped models requires separating stored layer count from serial computation depth: a standard decoder locks execution to a single pass through $L$ distinct layers, whereas a looped core reuses one shared block across $K$ passes (see also David Louapre's interactive Looped Transformers Space). Moving from the 2018 Universal Transformer to modern looped language models required clearing four practical walls: (1) replacing brittle ACT halting (which suffers from zero gradients and step jumps) with fixed/randomized depth or KL convergence, (2) replacing full BPTT memory growth with shallow checkpointing or TBPTT($k$), (3) removing additive sinusoidal step encodings that drift when unrolling past training depth, and (4) buffering token embeddings and logit projections outside the loop via a Prelude + Core + Coda stack.
⤢ Zoom
Figure 2: Universal Transformer recurrent encoder and decoder blocks refining token states over T shared steps (arXiv:1807.03819). (Source: Dehghani et al., 2018, Fig. 2)
As the diagram shows, Embed Input Symbols feeds directly into the Recurrent Encoder Block (Multihead Self-Attention then Transition Function looped For T steps), passes to the Recurrent Decoder Block (For T steps), and exits straight into Softmax and Output Probabilities—with no untied Prelude or Coda layers buffering token embeddings or logit projections outside the recurrence. Denote untied prelude layers $L_{\text{pre}}$, shared core layers $L_{\text{core}}$ looped $K$ times, and untied coda layers $L_{\text{coda}}$:
Lightweight ends paired with a deep autonomous core
Inkling 2 Mini · 26.4B
24 · $6+12+6$
48 · $K=3$
Pass 1 (incl. ends) is 3.4B; 2 extra core passes add 2×1B → 5.4B
NVIDIA Dory 1.0-4B
36 · $8+20+8$
36 / 56 / 96 · $K=1/2/4$
Thick 20L core; latency increases in 20-layer steps
GLM-5.4 · ~750B
78 · $26+28+24$
106 · $2\times$ middle 28L
Frontier-scale partial middle-stack looping
On Inkling 2 Mini, note the active-parameter arithmetic carefully: 3.4B already includes pass 1 ($K=1$, spanning the Prelude, the first Core pass, and the Coda), so running $K=3$ middle passes adds 2 × 1B = +2B → 5.4B active compute. Empirically, Saunshi et al. (2025) establish a sharp capability split under equal compute: a 12L × 6 looped model matches a 72L untied baseline on multi-hop reasoning and math while lagging on closed-book factual memorization such as TriviaQA.
⤢ Zoom
Figure 3: Weight-tied looping (k ⊗ L) compared against iso-param (k ⊗ 1), iso-FLOP (kL ⊗ 1), and middle-looping baselines (arXiv:2502.17416). (Source: Saunshi et al., 2025, Fig. 1)
Two details help map this diagram onto our notation: first, the rightmost Middle Looping (1 → 2...2 → 3) panel—bottom peach block 1, repeated blue core blocks 2...2, and top lavender block 3—corresponds directly to Prelude–Core–Coda; second, Saunshi et al. swap k and L relative to our equations, using k for physical block layers and L for loop count in (k ⊗ L) (the reverse of our $L_{\text{core}}$ layers looped $K$ times).
A critical architectural invariant cuts across every one of those models: the looped core must contain Attention (or another sequence-mixing operator). An FFN transforms each position completely independently with zero communication diameter across tokens. Trace a 2-hop composition A → B → C stored across different context tokens: in Round 1, Attention lets token A read B and write that bridge into A's residual slot; in Round 2, Attention reads the newly written B from A to retrieve C, resolving A → C. Looping FFNs alone cuts step 2 off from intermediate values computed at other positions during step 1, halting cross-token multi-hop composition immediately after pass 1.
Figure 4: Proportional comparison of physical layers L_phys versus effective depth L_eff across architectures.
3. Why Constant Depth Stalls on $S_5$, While $\mathcal{O}(\log n)$ Loops Reach $\mathsf{NC}^1$#
Early Turing-completeness arguments for recurrent networks relied on unbounded loops or infinite scalar precision—neither of which holds on BF16 hardware. To model realistic finite-precision execution, Merrill & Sabharwal (2023, 2025) and Saunshi et al. (2025) analyze Transformers restricted to $\mathcal{O}(\log n)$-bit precision and $\mathrm{DLOGTIME}$-uniform circuits, positioning architectures inside standard complexity classes:
The notation decodes straightforwardly: C denotes Boolean circuit families; superscript 0 means $\mathcal{O}(\log^0 n) = \mathcal{O}(1)$ constant depth, while superscript 1 means $\mathcal{O}(\log^1 n) = \mathcal{O}(\log n)$ logarithmic depth (and $\mathsf{L} \subseteq \mathsf{NL}$ denote deterministic and nondeterministic log-space), while N, A, T, and modular-gate ACC specify gate fan-in and primitives. In particular, $\mathsf{NC}^0$ uses bounded fan-in gates and suffers from $2^d$ myopia: a depth-3 $\mathsf{NC}^0$ circuit can inspect at most $2^3 = 8$ input bits even out of a million-token input.
Circuit Class
Depth in $n$
Gate Type & Fan-in
Characteristic Power & Limits
$\mathsf{NC}^0$
$\mathcal{O}(1)$ constant
Bounded fan-in AND/OR/NOT
Sees at most $2^d$ inputs; cannot compute global parity
$\mathsf{AC}^0$
$\mathcal{O}(1)$ constant
Unbounded fan-in AND/OR
Global parallel lookup; still misses Parity and majority
$\mathsf{TC}^0$
$\mathcal{O}(1)$ constant
Unbounded fan-in threshold gates
Bounds fixed-depth Transformers; solves counting and Dyck-1
$\mathsf{NC}^1$
$\mathcal{O}(\log n)$ log depth
Bounded fan-in Boolean gates
Solves nested Boolean formulas and $S_5$ multiplication
Any Transformer whose depth remains constant as context length $n$ grows stays confined inside $\mathrm{DLOGTIME}$-uniform $\mathsf{TC}^0$. Somewhat surprisingly, checking balanced single-type parentheses (Dyck-1) is already solvable in $\mathsf{TC}^0$: map ( to $+1$ and ) to $-1$; layer 1 uses uniform causal attention to compute every prefix average $s_i / (i+1)$ and emit a per-position violation flag $\mathbf{1}[s_i < 0]$, and layer 2 applies uniform attention over those violation flags $\mathbf{1}[s_i < 0]$ across $i \le n$ while verifying $s_n = 0$—strictly $\mathcal{O}(1)$ constant depth.
What exposes $\mathsf{TC}^0$'s structural ceiling is non-commutative function composition and nested evaluation, canonically represented by nested Boolean formula evaluation and iterated multiplication in the symmetric group $S_5$ ($f_n \circ \dots \circ f_2 \circ f_1$). Why does the boundary sit right between $S_4$ and $S_5$? $S_4$ is a solvable group (its derived series terminates at the identity through abelian quotients), keeping iterated $S_4$ word multiplication inside $\mathsf{ACC}^0 \subseteq \mathsf{TC}^0$. Starting at $S_5$, however, the alternating subgroup $A_5$ is a non-abelian simple group, which by Barrington's theorem (1989) makes $S_5$ word multiplication $\mathsf{NC}^1$-complete. Under the standard conjecture $\mathsf{TC}^0 \subsetneq \mathsf{NC}^1$, no constant-depth Transformer can reliably compose arbitrarily long $S_5$ chains.
Why does $\mathcal{O}(\log n)$ recurrence break through? Because associative composition permits parallel tree reduction. Consider a 4-cup shell game executing four sequential swaps 1↔2, 2↔3, 3↔4, 2↔4. Tracking one ball serially takes 4 steps, yet two workers can reduce each half independently into a start-to-end permutation table:
Worker A (1↔2, 2↔3): builds the first-half table [1→3, 2→1, 3→2, 4→4];
Worker B (3↔4, 2↔4): builds the second-half table [1→1, 2→4, 3→2, 4→3];
Final merge: even though Worker B built its table without knowing where the ball sat after Worker A finished, composing the two tables (1→3→2) matches the 4-step serial outcome exactly.
Saunshi et al. (2025) prove that a single Transformer block looped $\lceil \log_2 n \rceil$ rounds can evaluate arbitrary finite-group word problems such as $S_5$. A natural question is how a stepless weight-tied block doubles its lookback stride $2^{k-1}$ automatically on iteration $k$ without explicit step embeddings: the same orthogonal residual-bus mechanism stores a self-updating binary/phase counter slot that the FFN advances after each pass, allowing identical $W_Q/W_K$ weights to match offset $2^{k-1}$ and execute a causal Hillis–Steele prefix scan on elements $f_1, f_2, f_3, f_4$:
Step $k = 1$ (stride $2^{0} = 1$): Position 2 fetches $f_1$ to compute $f_2 \circ f_1$; position 3 fetches $f_2$ to compute $f_3 \circ f_2$; position 4 fetches $f_3$ to compute $f_4 \circ f_3$.
Step $k = 2$ (stride $2^{1} = 2$): Position 3 fetches $f_1$ across stride 2 and composes $(f_3 \circ f_2) \circ f_1 = f_3 \circ f_2 \circ f_1$, while position 4 fetches $f_2 \circ f_1$ from position 2 and composes $(f_4 \circ f_3) \circ (f_2 \circ f_1) = f_4 \circ f_3 \circ f_2 \circ f_1$.
This short runnable Python script verifies the Hillis–Steele prefix scan over eight non-commuting $S_5$ permutations: $\lceil \log_2 8 \rceil = 3$ parallel rounds match the 8-step serial product exactly:
PYTHON
defcomp(a, b):
returntuple(a[i] for i in b)
swaps = [
(1, 0, 2, 3, 4), (0, 2, 1, 3, 4),
(0, 1, 3, 2, 4), (0, 1, 2, 4, 3),
(4, 1, 2, 3, 0), (0, 3, 2, 1, 4),
(2, 1, 0, 3, 4), (0, 1, 4, 3, 2),
]
serial = [swaps[0]]
for x in swaps[1:]:
serial.append(comp(x, serial[-1]))
cur, stride, rnd = list(swaps), 1, 0while stride < len(swaps):
cur = [comp(cur[i], cur[i - stride]) if i >= stride
else cur[i] for i inrange(len(swaps))]
stride *= 2
rnd += 1assert cur == serial
print("rounds:", rnd, "final:", cur[-1]) # 3 rounds, (4,2,3,0,1)
Doubling the effective reach on every iteration evaluates every causal prefix in $\lceil \log_2 n \rceil$ passes. Extending the same mechanism to iterated boolean matrix multiplication lifts $\mathcal{O}(\log n)$-step looped Transformers into $\mathsf{TC}^1 \supseteq \mathsf{NC}^1$, capturing directed graph reachability ($\mathsf{NL}$). Meanwhile, explicit autoregressive Chain-of-Thought (CoT) acts as a manual loop unrolled across output tokens, trading $\mathrm{poly}(n)$ serial token steps to reach $\mathrm{P}$.
Figure 5: Resource scaling (depth vs. width vs. CoT steps) required for regular-language recognition as context length grows (arXiv:2503.03961). (Source: Merrill & Sabharwal, 2025, Fig. 1)
Tracing the regular-language recognition curves in the plot shows the separation directly: the orange width curve explodes vertically near context length ~100, the grey CoT steps line grows linearly at $\mathcal{O}(n)$ (500 steps at length 500), whereas the blue depth curve remains nearly flat on a logarithmic trajectory (~20–25 out to length 512). For problems beyond regular languages, extending linear $\mathcal{O}(n)$ CoT steps to $\mathrm{poly}(n)$ explicit tokens bridges the same unrolling mechanism to the complexity class $\mathrm{P}$.
Caveat
Caveat · Three Theoretical Bounds: First, $\mathsf{TC}^0 \subsetneq \mathsf{NC}^1$ remains an unproven separation conjecture in complexity theory. Second, classical Turing-completeness proofs assume unbounded runtime or infinite precision, whereas real inference clips both step count and floating-point mantissas. Third, circuit classes describe asymptotic scaling as $n \to \infty$; on short bounded inputs, wide untied networks can still memorize and match many iterative functions.
Circuit complexity marks a clear theoretical boundary: fixed-depth networks hit an algebraic ceiling at $\mathsf{TC}^0$ on deep non-commutative state tracking, whereas a logarithmic number of tied iterations breaks through inside a shared linear basis. Practically, though, real prompts rarely multiply 512-element $S_5$ chains—and 12L×6 still trails an untied 72L baseline on closed-book TriviaQA—so the tangible payoff in systems like Huginn or GLM-5.4 comes more from iterative latent refinement and compositional inductive bias than from asymptotic $\mathsf{NC}^1$ separation alone.
nostalgebraist (2020). interpreting GPT: the logit lens. LessWrong
David A. Mix Barrington (1989). Bounded-Width Polynomial-Size Branching Programs Recognize Exactly Those Languages in $\mathsf{NC}^1$. Journal of Computer and System Sciences, 38(1): 150–164.
Mostafa Dehghani et al. (2018). Universal Transformers. arXiv:1807.03819
William Merrill & Ashish Sabharwal (2023). The Parallelism Tradeoff: Limitations of Log-Precision Transformers. TACL 11, arXiv:2207.00729
William Merrill & Ashish Sabharwal (2024). The Expressive Power of Transformers with Chain of Thought. ICLR 2024, arXiv:2310.07923
Nikunj Saunshi et al. (2025). Reasoning with Latent Thoughts: On the Power of Looped Transformers. arXiv:2502.17416
William Merrill & Ashish Sabharwal (2025). A Little Depth Goes a Long Way: The Expressive Power of Log-Depth Transformers. arXiv:2503.03961
Jonas Geiping et al. (2025). Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approach (Huginn-0125). arXiv:2502.05171