Looped Transformers: Two-Pass Reasoning and GPU Memory Trade-Offs

    Looped Transformers reuse the same layers to add computational depth without multiplying parameter count. This article examines how gated updates, shared global KV caches, and reusable sparse attention indices can make a second reasoning pass more practical. It also explains where gains are most likely, why they do not guarantee executable outputs, and which memory, latency, and failure metrics matter for deployment.

    Looped computation is more than simply running the same forward pass twice. In a standard Transformer, effective depth roughly corresponds to the number of stacked layers: each layer processes the context, produces updated hidden states, and passes them to the next layer. Parameter count and memory requirements grow with depth and width.

    A looped architecture instead treats a group of layers as a reusable computational block, running it twice—or more—within a single response. The parameters remain the same, but the computation graph extends across additional iterations. Intuitively, this gives the model another opportunity to revisit its representations before producing the final token: the first pass establishes an overall picture, and the second refines it.

    The benefits have limits and costs. An additional pass increases computation roughly linearly. If every pass materializes a separate, full-length key-value cache (KV cache), memory usage also grows with the number of passes, quickly making long-context deployment impractical.

    A deployable looped architecture therefore needs to answer three questions:

    • How does the second pass avoid overwriting useful information established in the first?
    • Which memory can be shared across passes?
    • Which retrieval structures can be reused rather than recomputed?

    Effective Depth Is Not the Same as Parameter Count

    Larger parameter counts are often associated with stronger reasoning, but many difficult tasks depend on the number of sequential computational steps, not just model width. Competition-style mathematical derivations, constraints spanning multiple sections of a long document, and generation tasks that require planning before writing can all benefit from additional intermediate-state updates.

    Looped layers add computational depth, not a new set of independent parameters. They are closer to increasing the number of iterations within a fixed-capacity network: representations can be revised repeatedly, but the model does not gain several times the independent memory capacity.

    It is not rigorous to extrapolate relative improvements from small-scale controlled experiments directly to much larger models. Small models are more likely to be constrained by insufficient depth, so an extra pass may offer a larger marginal benefit. Large models already have substantial depth, and the same loop may address only the remaining difficult cases.

    Evaluations should report the number of passes, active parameter count, context length, and decoding strategy together. Comparing only final scores hides what the additional FLOPs actually buy.

    Gated Progressive Updates: Draft and Revision, Not Repeated Overwriting

    If the second pass rewrites first-pass hidden states through the same residual pathways, two failure modes can emerge. Repeated scaling can cause numerical drift, while local noise can overwrite global semantics that were already well aligned.

    Gated progressive updates let the network decide how much of the previous state to retain and how much new computation to incorporate.

    The gate can be understood as a soft switch operating per token and per channel. The first pass is suited to coarse-grained aggregation: identifying paragraph topics, long-range dependencies between entities, and the overall structure of task constraints. The second pass can concentrate updates on positions that remain uncertain, such as ambiguous terms, unresolved references, or passages that conflict with later constraints.

    For easier tokens, the gate tends to permit smaller changes. Tokens the model considers more difficult may receive more attention during the first pass and more detailed refinement during the second. The two passes thus function as “draft and revision,” rather than identical repetitions.

    Gate initialization and numerical range require careful engineering. If gates remain saturated fully open or fully closed, the loop can become uncontrolled rewriting or effectively collapse to a single pass.

    Training should include samples across difficulty levels. Otherwise, the model may learn to leave the second pass almost inactive on simple instructions without developing the ability to revise difficult cases in production.

    At inference time, average gate activation can also be logged as a diagnostic of whether the additional pass is making meaningful updates. It should complement, rather than replace, evaluation of the final answer.

    Shared Global KV and Separate Sliding-Window Caches

    During autoregressive decoding, the KV cache is often a major contributor to GPU memory usage. Its size scales approximately with the number of layers, attention heads, and sequence length. If each loop maintains a separate full-length KV cache, two-pass processing can directly double the long-context cache footprint.

    A more practical split is to share global memory across passes while retaining a separate cache only for the local window currently being processed.

    After the first pass scans the full text—or the currently generated prefix—it produces a reusable global KV cache. The second pass reads that shared memory instead of allocating another equally large cache for the entire history. Only tokens within the current sliding window require recomputation or incremental writes to a smaller local KV cache.

    Additional memory then depends on window size rather than full sequence length multiplied by the number of passes. At million-token context lengths, whether this remains manageable depends on the window size, global KV precision and paging strategy, and whether intermediate activations are released between passes.

    Sharing introduces a consistency problem, however. First-pass keys and values are computed from hidden states that have not yet been revised. If the second pass substantially changes the meaning of earlier tokens while continuing to use their old KV entries, the retrieved context may be stale.

    This is why cache sharing is often paired with gating. Most positions change little, leaving their existing KV entries useful. Recalculation is limited to the sliding window or positions marked as highly uncertain. This is a trade-off between quality and memory usage, not a lossless equivalent of maintaining separate caches.

    The following pseudocode illustrates the data flow only; it does not represent any specific framework API:

    1. round1_hidden = layers(tokens)
    2. global_kv = project_kv(round1_hidden) # One cache for the full sequence
    3. local_kv = empty_window(window_size) # Current sliding window only
    4. for step in decode_or_second_pass:
    5. q = query(current_states)
    6. ctx = attend(q, global_kv, local_kv)
    7. updated, gate = gated_residual(current_states, ctx)
    8. local_kv = write_window(local_kv, updated)
    9. current_states = updated

    Reusing Sparse Attention Indices to Avoid Another Full Scan

    Sharing KV caches does not eliminate all repeated work. If the second pass scores the entire sequence again and selects a new top-k set, attention computation and bandwidth requirements can still approach twice the original cost.

    Sparse attention typically builds an index of positions worth attending to, using block-level importance, local windows, or candidate sets derived from first-pass scores. In a looped architecture, the second pass can reuse those selected indices and apply more detailed attention only within the candidate set.

    This assumes that the first-pass index remains broadly appropriate for the second pass. The assumption is more reliable when the topic is stable and task constraints are clearly stated near the beginning. In those cases, retrieval overhead can fall substantially, and the quality penalty may be small relative to the cost of rescanning the full sequence.

    The assumption is weaker when the task changes midway through the text or later passages invalidate earlier information. An old index can miss newly important sentences.

    A limited amount of index refresh is therefore useful. For example, the model can reassess block importance every few layers or force tokens with large gated updates into the candidate set. Never refreshing saves the most time, but it can produce sharp quality drops on examples whose answers depend on new information in the latter part of the context.

    Where the Gains Are Most Likely

    Looping is more likely to help with:

    • Reasoning problems that require multiple intermediate conclusions.
    • Reading comprehension over very long material with several simultaneous instructions.
    • Planning-oriented generation that first establishes a structure and then fills in details.

    In small-scale controlled comparisons where looping is added without otherwise changing the training recipe, mathematics, difficult scientific question answering, long-document reasoning, and instruction following are often more likely to show gains than language fluency alone.

    This is consistent with the mechanism: the additional pass mainly revises uncertain representations rather than expanding vocabulary knowledge.

    Looping does not automatically improve engineering robustness. In complex frontend development or 3D scene generation, failures often result from duplicate variable declarations, incorrect initialization order, or references to undefined symbols—not insufficient reasoning depth.

    A second pass may help the model describe a scene more coherently while the first generated executable artifact still fails because of scope or initialization errors. If evaluation checks only whether the output runs, a looped model may take longer yet repeatedly encounter the same basic mistakes.

    Acceptance criteria should therefore separate reasoning quality from first-attempt executability:

    • Reasoning quality: Are constraints satisfied, and are intermediate steps internally consistent?
    • First-attempt executability: Is the syntax valid? Are there duplicate declarations, undefined references, or resource-loading failures?

    Retry policies can also distort comparisons. Repeatedly sampling within a time limit until an output happens to run measures search budget, not single-attempt architectural capability.

    A cleaner protocol fixes the number of sampling attempts and the maximum latency, while recording time to first token, total token count, peak GPU memory, and the distribution of failure types.

    Deployment and Acceptance Checklist

    Before deployment, evaluate the following rather than relying only on whether public benchmark scores appear stronger:

    • Pass count and compute budget: Is the default one pass or two? Can difficult inputs trigger additional passes? Does the total FLOP multiplier relative to the baseline fit the service-level agreement?
    • Memory scaling: As sequences grow, does peak memory approximate one global KV cache plus one sliding-window cache, rather than multiplying with the pass count?
    • Gate behavior: Second-pass updates should be noticeably smaller for easy inputs than for difficult ones. Similar update magnitudes across both groups may indicate that the passes have not learned distinct roles.
    • Index staleness: Use probes in which later information overturns earlier statements. If reused indices cause a substantial quality drop, increase the refresh frequency.
    • Failure categories: Track syntax errors, undefined symbols, omitted instructions, and factual errors separately. An aggregate score can conceal problems looping does not solve.
    • Latency percentiles: Placing the second pass before the first token or during decoding changes the user experience. Measure both P50 and P99 latency.

    The value of looped Transformers lies in trading a controlled amount of additional depth for better reasoning, while using shared memory and index reuse to contain GPU memory and retrieval costs. They are not a free substitute for parameter scale.

    Architecture documentation should state the pass count, cache partitioning, and whether attention indices are refreshed. Deployment acceptance should examine both gains on difficult tasks and failure categories in executable outputs. Only when both sides hold up is the additional pass doing useful work, rather than merely adding another forward pass to the bill.