Recurrent Transformers Explained: How 28 Shared Layers Run Twice

    Running the same 28 Transformer layers twice creates a 56-layer execution path without storing a second set of weights. This article explains what changes between passes, why internal computation differs from generated reasoning tokens, and how training, attention caching, and inference costs affect whether a recurrent design is worth adopting.

    1. What Problem Do Recurrent Transformers Solve?

    To predict the next token, a language model converts its input into an internal representation, processes that representation through multiple layers, and produces a probability distribution over candidate tokens. A token is the basic unit the model processes; it does not necessarily correspond to a single character or word.

    In a conventional stacked Transformer, each layer typically has its own parameters. As information moves through the stack, earlier and later layers may represent it at different levels of abstraction. Adding layers increases computational depth, but when each new layer has its own parameters, weight storage, training state, and deployment requirements grow as well.

    A recurrent Transformer takes a different approach: it runs an existing block of layers more than once. The hidden state produced by one pass becomes the input to the next, so the same weights operate on a different representation each time.

    The point is not to duplicate the model. It is to use parameter sharing to add internal computation steps. That architectural choice does not guarantee better output, faster inference, or a single pass count that works well for every task.

    2. What Does It Mean to Run 28 Layers Twice?

    Consider a model with input processing, a shared block of 28 layers, and output processing. Two passes through the shared block would look like this:

    1. Input tokens
    2. ↓
    3. Input processing
    4. ↓
    5. Initial hidden state h₀
    6. ↓
    7. Shared 28-layer block: first pass
    8. ↓
    9. Intermediate hidden state h₁
    10. ↓
    11. Same 28-layer block: second pass
    12. ↓
    13. Final hidden state h₂
    14. ↓
    15. Output processing and projection
    16. ↓
    17. Probability distribution for the next token

    The 28-layer block is an illustrative example, not a specification for any particular product. It does not tell us what other components a real model uses, how it was trained, or how it performs.

    If (B_\theta) denotes the shared block and (\theta) denotes its parameters, the two passes can be written as:

    [
    h1 = B\theta(h0), \qquad h_2 = B\theta(h_1)
    ]

    Both calls use the same parameters. The second call takes the updated hidden state as input, so reusing the weights does not mean repeating the same transformation on the same data.

    The block accounts for 56 layer executions, but it stores weights for only 28 layers. That is not equivalent to a 56-layer model with independent weights: in an untied stack, each of the 56 layers can learn its own transformation. In the recurrent design, each layer applies the same learned transformation across passes. Repetition deepens the execution path without increasing the number of independent parameters in proportion.

    3. The Loop Updates Hidden States, Not Draft Answers

    A hidden state is a high-dimensional numerical representation. It carries contextual information, but it is not a natural-language draft that someone could read.

    The first pass may integrate information from the input, while the next pass continues transforming the updated representation. This gives information at different positions and in different features another opportunity to interact. It does not mean each pass has a fixed, interpretable role.

    Nor does another pass necessarily improve the result. A shared block may learn useful iterative updates, make too little progress, discard useful information, or yield diminishing returns. The outcome depends on the training objective, data distribution, recurrent design, and optimization process.

    Think of the same team reviewing a document twice: the material gets another round of work without adding more reviewers. The analogy stops there. The model transforms continuous numerical representations; it does not edit a draft sentence by sentence.

    4. Parameter Count, Internal Computation, and Chain-of-Thought Tokens

    These three quantities describe different things and should not be used interchangeably.

    Parameter count: How many learned values the model stores

    Running a shared block twice does not require storing two copies of its weights. The full model can still contain input and output projections, layers before and after the block, and, in some designs, pass-specific parameters. The number of layers in the shared block alone does not determine the model’s total parameter count.

    Internal computation: How much work a prediction requires

    Reusing weights does not eliminate the work of applying them. Every pass still performs attention, feed-forward transformations, and related operations. All else being equal, adding passes increases the cost of executing the block.

    End-to-end inference cost also depends on input length, output length, hardware utilization, caching, and scheduling. Two passes through a block therefore do not imply exactly twice the total latency.

    Chain-of-thought tokens: How much intermediate text the model generates

    An explicit chain of thought is a sequence of generated text tokens. Recurrent computation takes place in hidden states and can proceed through several passes without producing any additional text.

    The two mechanisms can coexist. A model can run recurrent computation and then generate intermediate text, or it can return a short answer. A short answer is not evidence of limited internal computation, and a long explanation is not evidence of a recurrent architecture.

    5. Why Reusing Parameters Does Not Make Computation Free

    A recurrent design can reach a given execution depth with fewer independent weights, but it still has to perform the operations in every pass. For inference, it helps to separate three costs:

    • Weight storage: Memory needed to hold model parameters.
    • Intermediate states and caches: Memory needed to retain representations and attention information for reuse.
    • Computation: Time and compute resources needed to execute each pass.

    Parameter sharing directly reduces weight storage relative to an equally deep untied stack. It does not guarantee corresponding reductions in cache memory or computation.

    Training involves a similar trade-off. Sharing can reduce parameter-related storage compared with an equivalent unrolled design with independent weights, but backpropagation must still account for dependencies across passes. Recomputing activations can reduce how many intermediate values must be stored, at the cost of extra computation.

    Parameter efficiency and throughput should therefore be measured separately. Whether recurrence reduces costs depends on the quality target, hardware, and request workload.

    6. Why Training Involves More Than Calling the Block Twice

    Adding another call to a shared block may be simple in code. Training a model to make good use of that call is a different problem.

    Shared layers must handle different input distributions

    The first pass receives the initial representation. The second receives a transformed representation whose statistical properties may differ. The shared weights have to work with both.

    If a model was trained with one pass, adding a second at deployment does not guarantee useful computation. Pass count should be part of the training and validation design, not an arbitrary inference-time change.

    Gradient contributions accumulate across passes

    Because the same parameters are used in multiple passes, they receive gradient contributions through each of those uses. This allows the block to learn a transformation that is useful when applied repeatedly, but it can also make optimization harder.

    Residual connections, normalization, initialization, and gradient control all deserve attention. Weight sharing alone does not guarantee stable training; the design must be validated experimentally.

    More passes do not guarantee continued gains

    Additional passes may improve the representation, but gains can plateau. For some inputs, repeated updates may even discard useful information.

    Evaluation should compare multiple pass counts to identify diminishing returns and task-specific regressions. If the design uses dynamic stopping, the stopping criterion must also be defined and tested. A hidden state cannot be assumed to converge to the correct answer on its own.

    7. Attention Caching Is a Key Implementation Constraint

    During autoregressive inference, a key-value (KV) cache typically stores attention keys and values for previous tokens. This avoids recomputing all of that history every time the model generates a new token.

    In a recurrent Transformer, the same weights receive different hidden states in different passes. As a result, they can produce different keys and values. Sharing weights does not mean the passes can share the same KV cache entries. The cached values depend on the input to the pass, not just on the weights that produced them.

    An implementation needs to define:

    • Which historical representations each attention pass reads.
    • Whether cache entries are organized separately by layer and pass.
    • How each pass updates the cache for a new token.
    • How positional encodings, causal masks, and pass-specific states remain consistent.

    Different recurrent designs can route information differently, so there is no universal cache layout. Define the computation graph first, then verify that caching preserves its behavior. Do not merge cache entries merely to save memory.

    8. How to Evaluate Whether a Recurrent Design Is Worth Using

    Layer count and parameter count alone cannot establish whether recurrence is a good fit. A useful evaluation compares both quality and resource use.

    Compare like with like

    Three comparisons answer different questions:

    • At similar parameter counts: Which architecture delivers better task quality?
    • At similar compute budgets: Which design performs better?
    • At similar quality levels: Which design uses fewer resources or has lower latency?

    A quality improvement achieved with more computation does not, by itself, make one architecture better across the board.

    Measure input processing and generation separately

    Input processing and token-by-token generation have different execution characteristics. Results can also vary between short and long inputs or between low- and high-concurrency workloads.

    Measure time to first token, latency for subsequent tokens, throughput, peak GPU memory, and cache usage. Track tail latency as well as averages so that slow or inconsistent requests are not hidden by aggregate results.

    Break down results by task type and difficulty

    Tasks that require several steps of information integration may benefit more from extra internal computation, but that needs to be tested. Simple classification, output formatting, or short text transformations may not need the same depth.

    Alongside aggregate scores, check factual errors, formatting failures, repeated output, and answer consistency. This helps reveal whether gains in one area come at the expense of another.

    9. What Gets Reused Is the Weights. What Gets Added Is Computation.

    A recurrent Transformer applies shared layers to an updated hidden state. Running 28 layers twice creates a deeper execution path, but it is neither a 56-layer stack with independent weights nor two rounds of explicit chain-of-thought text.

    For developers and teams deploying these models, pass count matters less than what it costs to reach the target quality: how much computation is required, how much memory the weights and caches occupy, whether latency meets workload requirements, and whether training and inference behave consistently.

    Recurrent architectures offer a way to increase internal processing depth without adding an independent set of weights for every pass. To judge whether that trade-off pays off, measure parameters, internal computation, text generation, and system overhead separately.