Recurrent Depth Networks: Transformers with Parameter Reuse

    This article explains how recurrent depth networks decouple a model's parameter count from its effective depth. It covers the distinction between storage depth and computational depth, an intuition based on repeated queries against a shared knowledge base, a formal loop block with entry and exit projections, adaptive computation strategies such as convergence checks and confidence-based early exit, and key training and engineering considerations, along with the scenarios where recurrence helps and where it does not.

    1. The Problem: Depth Locked by Parameters

    The capability ceiling of a standard Transformer has long been constrained by a simple fact: how many layers of distinct weights it stores. An L-layer model means L independent parameter sets, each used exactly once per forward pass. Making the network deeper requires more parameters, more GPU memory, and higher training cost, and parameter growth pushes up inference latency and deployment overhead almost linearly. This raises a key question: can a model “think one layer deeper” while the total parameter count stays fixed?

    Answering it requires splitting “depth” into two different meanings.

    2. Two Kinds of Depth: Storage Depth and Computational Depth

    In the standard structure, the hidden state passes sequentially through mutually different layers:

    1. h(l+1) = Block_l(h(l)), l = 0, 1, ..., L-1

    Each layer holds its own parameters θ_l, and depth is determined by the number of parameter sets. This can be called storage depth (depth in parameters).

    A recurrent structure introduces a second measure: the same parameter set θ is applied repeatedly T times:

    1. h(t+1) = Block_θ(h(t)), t = 0, 1, ..., T-1

    Storage depth is still 1, but computational depth is T. Depth thus changes from a constant into a runtime variable: hard samples get more iterations, easy samples exit early. Compute is traded for depth, and depth is traded for reasoning ability, while parameter and memory footprint stay roughly unchanged.

    3. Intuition: Repeated Queries Against an Index and a Database

    Think of self-attention as building an index over external information, and the feed-forward layer as a knowledge base compressed into weights. The recurrent structure repeatedly queries the same knowledge base under the guidance of that index, refining the answer step by step: if one pass does not get there, the intermediate result is carried into another pass.

    The analogy becomes clearer when each feed-forward layer is a mixture-of-experts structure: each expert resembles a distinct piece of knowledge, and attention handles analysis and retrieval. An ordinary model piles up parameters to go from “elementary school” to “university,” accumulating more and more knowledge. Once it reaches the “PhD stage,” where creative fusion across pieces of knowledge is required, adding parameters yields diminishing returns, and recurrent iteration becomes the path to repeatedly digest existing knowledge and generate new solutions. It can also be seen as an early form of a chain of thought inside the model.

    4. Formalization: Loop Unrolling, Weight Sharing, and Boundary Handling

    Unrolling the recurrent block yields a form with entry and exit projections, which avoids drastic shifts in the input and output distribution of each iteration:

    1. def loop_block(h, block, T, exit_gate):
    2. h = entry_proj(h) # align the input distribution
    3. for t in range(T):
    4. r = block(h) # shared parameters
    5. g = exit_gate(h) # scalar or per-channel gate
    6. h = h + g * (r - h) # residual-style update for stable convergence
    7. return exit_proj(h)

    Three design points:

    1. Entry and exit projections: only a small number of parameters are used for distribution alignment; the bulk of the parameters remain shared.
    2. Residual update and gating: each round becomes a correction to the previous hidden state rather than a rewrite.
    3. Shared normalization: normalization parameters are shared, reducing drift and memory fragmentation.

    5. Adaptive Computation: Making the Number of Rounds a Variable

    A fixed T wastes compute. Common approaches:

    • Convergence criterion: stop once the relative change of the hidden state between two adjacent rounds falls below a threshold, ||h(t+1)-h(t)|| / ||h(t)|| < ε.
    • Confidence-based exit: attach lightweight prediction heads at several intermediate rounds and return early when entropy is below a threshold.
    • Budget scheduling: allocate a per-sample round limit based on difficulty within a batch, balancing throughput against the latency tail.

    Sketch:

    1. for t in range(T_max):
    2. h_new = block(h)
    3. if norm(h_new - h) < eps * norm(h):
    4. break
    5. h = h_new

    6. Training and Engineering Notes

    • Unrolling and truncation: sample the number of rounds randomly during training (for example, 1 to T_max) so the model is robust at “any depth,” which is equivalent to data augmentation along the depth dimension.
    • Gradient stability: shared parameters are reused multiple times, so the gradient is the sum of contributions from all rounds. Gradient clipping, a smaller learning rate, and warmup are needed.
    • Inference caching: recurrence introduces no new inter-layer cache, but intermediate states of the iterations can optionally serve as an early-exit cache; KV cache strategy is the same as in a standard structure.
    • Cost model: memory and parameter count are unchanged, while latency grows with the actual number of rounds; under batching, early exit for short samples can significantly improve average latency.
    • Combined with sparsification: recurrence provides “depth elasticity” and expert sparsity provides “width elasticity.” The two are orthogonal and can be stacked.

    7. Applicability and Common Pitfalls

    Recurrent structures are not a cure-all. When the bottleneck is knowledge capacity rather than the number of reasoning steps, more rounds yield limited gains. If the hidden state barely changes per round, early exit degenerates the model into a shallow one. The round-sampling distribution used in training must match the inference budget, otherwise a “trained shallow, inferred deep” distribution shift appears. A sensible positioning is this: in parameter-constrained settings that need stronger multi-step reasoning and knowledge recombination, trade computational depth for a higher capability ceiling.

    8. Summary

    Recurrent Transformers free “depth” from storage constraints and turn it into a runtime-adjustable resource. Without changing parameter scale, they offer an engineering path to “thinking deeper without piling on parameters” through iterative refinement, adaptive exit, and orthogonal composition with sparse expert structures.