How Recurrent Transformers Reuse Layer Computation and Increase Effective Depth
Recurrent Transformers share a block of layers across multiple inner loops so hidden states can be refined without duplicating weights. This article explains what weight sharing does and does not buy you, how to read a “28 layers, two loops” design, why gating and cache reuse matter, and which quality, latency, and memory trade-offs to measure.
Core idea of a recurrent Transformer
A typical Transformer stacks many layers, each with its own parameters. Representations pass through attention and feed-forward blocks in sequence, and depth is a path of distinct modules.
A recurrent Transformer reorganizes that path. It treats a set of layers as a recurrent block and runs the same parameters for several inner loops. The hidden state after one loop is not the final answer; it becomes the input to the next. What changes is the internal numerical representation, not already generated text.
Think of one workflow applied repeatedly to a working draft: the procedure is not copied, but the draft is updated each time. The analogy helps with weight sharing; the model actually passes high-dimensional vectors that encode context and features, not readable natural language.
A simplified flow:
input representation↓pre-processing↓shared recurrent block: loop 1↓updated hidden state↓shared recurrent block: loop 2↓post-processing↓output prediction
If the block is a function F and the initial state is h₀, two loops are:
h₁ = F(h₀)h₂ = F(h₁)
Both calls use the same parameters, but different inputs, so h₁ and h₂ usually differ. Recurrence is not repeating the same input, and it is not resubmitting the first-round answer as text.
Shared weights are not free compute
Parameter count and compute must be separated.
Parameters are the weights that must be stored or trained. If the block shares weights across two loops, a second full copy of those layers is not required, so that portion of the parameter count does not double just because the block runs twice.
Compute is the arithmetic actually executed in a forward or training pass. Shared weights still run every loop. A 28-layer recurrent block run twice expands, roughly, as:
28 layers × 2 loops = 56 layer evaluations
That expands the recurrent segment only. It does not mean the whole model has exactly 56 layers, and it does not imply doubled parameters. There may still be layers outside the block, plus structures for routing, state control, or cache management.
Weight reuse mainly means a more compact parameter set for a deeper effective compute path. Extra compute still costs latency, training time, and memory, which depend on implementation, sequence length, attention, batching, and hardware.
What “28 layers, two loops” means
If a model groups 28 base layers into a shared block and runs it twice, the same layer parameters are invoked twice in one forward pass, and the second loop sees the first loop’s updated representation.
That increases compute depth for that segment without cloning a second set of weights of the same size. It is not the same as rewriting the whole network as “original depth times two,” because paths outside the block remain and layers can have different roles.
“Two loops” is internal computation, not two stretches of generated text. Loop count is also not chain-of-thought token count: chain-of-thought is explicit token sequence; recurrence happens on hidden states before the next-token prediction. They can both affect quality, but they are different mechanisms.
Why extra design is needed
Repeating a block looks simple; in practice you face representation stability, attention caches, and redundant work. Without supporting design, extra loops may not help and may raise serving cost.
1. Control how much the state updates each loop
Each loop produces a candidate representation. Writing it back unchecked can push activations out of a stable range and make training and inference harder.
A common idea is a gate that scales how much of the candidate overwrites the previous state:
h_next = h + gate × (candidate - h)
candidate is the block output; gate is the update scale. This is the idea of gated residual updates, not a formula from a specific model. It helps keep prior information while absorbing new computation.
2. Manage attention cache across loops
Attention often stores keys and values so history is not recomputed. Extra loops change how caches are reused, which affects memory and speed.
One pattern is to separate global from local-window information: reusable global cache can be shared across loops; recent or local content is kept per loop. The goal is less redundant storage and compute while keeping needed context. Savings depend on cache layout, sequence length, and the attention implementation—not loop count alone.
3. Avoid repeating sparse retrieval
Sparse attention selects a subset of positions. The second loop may face a similar retrieval problem. Reusing first-loop indices can cut selection cost if correctness and quality still hold.
Reuse does not freeze second-loop computation. Hidden states have changed, so useful positions may change. Whether to reuse, recompute, or partially refresh indices should be decided by training and evaluation, not assumed for every recurrent design.
Training and serving trade-offs
Shared weights change training: the same parameters receive gradients from every loop, so the block must work at several stages of the state, not only as a single transform.
At serving time, look at end-to-end metrics, not parameter count alone. Longer compute paths can raise per-request latency; cache reuse and sparsity can offset some cost. Batch size, input and output length, and hardware parallelism still matter.
Useful checks:
- Quality: whether an extra loop gives stable gains on the target tasks.
- Latency: time to first token and full generation time.
- Resources: stored parameters, runtime memory, and cache footprint.
- Scaling: whether more loops keep helping or show diminishing returns.
- Stability: quality across input lengths and task types.
Compare under the same data, hardware, and inference settings. Parameter size alone does not describe compute cost; a single-task quality bump does not prove the architecture is generally effective.
When recurrence is worth considering
The point is extra inner processing with shared weights, not larger parameter counts for their own sake. If the application benefits from stepwise refinement of representations and can afford extra compute, the design is worth evaluating. If latency or inference budget is tight, weigh gains against cost.
More loops are not always better. Extra loops deepen compute but lengthen the path, can make training harder, and complicate caches. Ablate loop count and supporting mechanisms and check that quality gains cover the engineering cost.
Summary
A recurrent Transformer repeatedly applies a shared-parameter block so hidden states update loop by loop. That can increase effective depth without cloning a full set of weights each loop, but each loop still runs real compute—reuse is not free.
Read “28 layers, two loops” as two invocations of that segment, not doubled parameters, not a simple doubling of every layer in the network, and not a longer chain of thought. Practical systems still need stable state updates, attention-cache reuse, and control of retrieval cost, then validation on quality, latency, and resource metrics.
