Loop Depth Architecture: Technical Highlights and Engineering Design

    This article breaks down loop depth (recursive depth) architecture for large language models, a structural approach that adds computation without adding parameters. It explains how a trained dense base model can be converted by folding consecutive layers into a loop block, then details three key engineering changes: token-level gated progressive updates, KV cache sharing across loops with an independent sliding window, and sparse attention index reuse. It also covers the scaling-based validation method, where the gains come from structure rather than extra compute, and the practical tradeoffs teams should weigh before adoption.

    1. The Starting Point: Fixed Parameters, Growing Depth

    The “intelligence level” of large models has long been tied to two curves: parameter count and training compute. But once scale reaches the hundreds-of-billions parameter range, the marginal return from adding more parameters starts to shrink, while inference cost, memory footprint, and training time climb roughly linearly or even faster. As a result, the industry has begun looking for a third path: increasing not the weights, but the “time dimension” of computation.

    Loop depth architecture (loop / recursive depth) is a representative example of this path. Its premise is simple: in a standard Transformer, each layer’s weights are used only once, and signals flow upward in a single direction. A loop structure repeatedly invokes a set of layers with shared weights over multiple rounds, with each round reading the hidden state from the previous round and refining it further.

    A fitting analogy is iterating on a proposal. The traditional approach keeps hiring new people to take over the next stage, and the team keeps expanding. The loop approach does not expand headcount; instead, the same group of experts reviews the same draft over several rounds. Headcount stays the same, the number of review rounds goes up, and the quality of the proposal can still improve.

    It is worth emphasizing that this is not a new idea. Around 2018, academia had already proposed deep recursive structures with weight sharing. The previous difficulty was that, under an equal compute budget, weight-sharing models often underperformed models with more layers and independent weights in fitting capability. So the viable route in recent years is not to pretrain a loop model from scratch, but to first train a mature dense base model, then “convert” several of its layers into a loop block and continue training—trading a small amount of compute in the post-training stage for depth gains at inference time.

    2. Structural Conversion: Folding Consecutive Layers into a Loop Block

    A typical approach takes a segment of consecutive layers from the base model (for example, 28 layers in the middle-to-late section), folds them into a loop block, and runs two rounds at runtime: the first round performs initial aggregation of global information, and the second round does one refinement pass on the same weights. Formally, if the loop block is denoted f and the hidden state is h, then:

    1. # Pseudocode: two-round loop depth forward pass
    2. h = embed(tokens)
    3. h = trunk_bottom(h) # layers before the loop block
    4. for r in range(num_loops): # num_loops = 2
    5. delta = block(h, r) # same weights; the round is only a gating input
    6. h = h + gate(h, r) * delta # gate writes back into the residual stream by ratio
    7. h = trunk_top(h) # layers after the loop block and the output head

    The key engineering challenge here is not “whether it can loop,” but “whether it can converge stably after looping and whether cost can be controlled.” A naive implementation runs into problems in three places: activation scale drift, doubled cache memory, and repeated attention index computation. The three designs below target exactly these three points.

    3. Three Key Engineering Changes

    3.1 Token-Level Gated Progressive Updates

    If each round directly overwrote the old value with the newly computed hidden state, the activation norm would inflate rapidly across rounds, and the input received by later layers would deviate from the numerical scale familiar from pretraining, making training prone to instability.

    The solution is to configure an independent gate for each round and write the candidate change back into the residual stream by ratio at a token level, rather than replacing it wholesale:

    1. g = sigmoid(W_gate_r(h)) # independent gate per round, applied per token
    2. h = h + g * candidate(h) # progressive write-back, suppressing norm explosion

    A notable post-training phenomenon is spontaneous division of labor: the gate values in the first round are generally small, favoring gentle writes, with the main task of establishing a global context state; the gate values open up in the second round, reusing the information already formed in the first round for thorough refinement. In other words, the multi-round structure differentiates on its own during training into two roles—“mapping” and “refining”—rather than simply repeating the same computation.

    3.2 KV Cache Sharing Across Rounds + Independent Sliding Window

    A naive loop needs to store a separate KV cache for each round, so memory grows by a multiple of the number of rounds, which is directly unacceptable in long-context scenarios.

    The improved approach shares the same KV cache across rounds: the second round reuses the sparse KV selected in the first round, while keeping only the KV newly generated by the second round within the sliding window range, used to supplement local details. This way, the extra memory cost of adding one round is equivalent to only one sliding window, which is nearly negligible at million-level context lengths.

    3.3 Sparse Attention Index Reuse

    If the indexer were rerun each round to select the tokens participating in attention, the indexing overhead would also stack with the number of rounds. Having the second round directly reuse the index produced by the first round adds almost no extra overhead, while the effect is roughly on par with recomputing each round. The underlying logic is that the first round has already completed a global coarse screening, and the goal of the second round is to do finer weighting within the same candidate set, with no need to relocate.

    4. Validation Method and Boundaries of the Conclusion

    A reasonable validation approach is to scale up step by step: convert 1B, 4B, 30B, and up to 750B parameter base models, and observe whether the gains reproduce stably with scale. The most persuasive comparison is this: the loop version and the baseline use exactly the same architecture and parameter count, with overall training compute increased by only about ten percent, yet the loop version still shows a clear improvement in overall performance—indicating that the gain comes from structure rather than extra compute.

    A further pattern is that the longer the reasoning chain, the greater the benefit from looping, with the most significant improvements concentrated in tasks requiring multi-step reasoning such as math reasoning, long-context understanding, and code generation; on single-step, short-output tasks, the difference is limited.

    Engineering deployment still requires weighing three points. First, looping linearly amplifies the inference latency per token, which must be evaluated in combination with batching and memory budget. Second, the conversion depends on a well-trained base model, and the quality of the base model sets the ceiling. Third, gating, cache sharing, and index reuse should be treated as a set of companion designs; introducing any one alone is unlikely to yield the full benefit. For teams that want to improve complex reasoning ability without expanding parameters, loop depth is a general path worth including in technical selection evaluation.