Summary (Overview)

  • LoopRes is a novel approach that enables pretrained LLMs to be finetuned into looped Transformers, achieving significant and consistent performance gains through loop residuals—a mechanism that lets each looped layer attend directly to outputs of earlier loops.
  • The method introduces two key innovations: loop-aware keys (trainable per-block, per-loop vectors encoding structural identity) and a residual window (restricting attention to the latest WW loops), addressing three core challenges of naive Attention Residuals in looped settings: similar iterates, early convergence, and growing source sets.
  • Across 6 pretrained LLMs (Qwen3-1.7B/4B/8B/30B-A3B, Qwen3.5-2B, Llama-3.2-1B) and 9 math/code benchmarks, LoopRes delivers substantial improvements: at 2× compute on Qwen3-1.7B-Base, it improves average score by 29.1% over SFT, more than doubling the gain of the strongest baseline (BRT at 13.9%).
  • LoopRes demonstrates superior test-time scaling: its score rises with a steeper slope than SFT as compute grows, reaching a higher ceiling while requiring less compute on long outputs. Notably, LoopRes on the 4B backbone even surpasses SFT on the 8B backbone.
  • The method adds minimal training overhead (~4.8% step time increase) and is implemented with a fused Triton kernel for efficiency.

Introduction and Theoretical Foundation

Background and Motivation

Looped Transformers reuse a shared block of layers multiple times in a single forward pass, achieving deeper computation without adding parameters. This offers a promising lever for both stronger performance and test-time compute scaling. However, prior attempts have faced significant hurdles:

  • Training from scratch (e.g., Huginn, Ouro) yields modest or even negative gains at comparable cost, and is prohibitively expensive.
  • Finetuning existing models into loops is cheaper but has historically yielded only marginal gains over standard SFT, because existing designs compress the outputs of earlier loops into a narrow pathway, limiting what later loops can build on.

Theoretical Foundation: Attention Residuals (AttnRes)

The paper builds on Attention Residuals (AttnRes) (Kimi Team et al., 2026), which replaces the standard residual stream with a learned input. In its block form, each sub-layer takes as input a set of sources S\mathcal{S} (embedding, completed block outputs, partial sums) and weighs them via softmax attention:

x=∑s∈Sαsvs,αs=exp⁡(q⊤ks)∑s′∈Sexp⁡(q⊤ks′),(1)\boldsymbol{x} = \sum_{s \in \mathcal{S}} \alpha_s \boldsymbol{v}_s, \quad \alpha_s = \frac{\exp(\boldsymbol{q}^{\top} \boldsymbol{k}_s)}{\sum_{s' \in \mathcal{S}} \exp(\boldsymbol{q}^{\top} \boldsymbol{k}_{s'})},\tag{1}

where q\boldsymbol{q} is a learnable query (initialized to zero), vs\boldsymbol{v}_s is a source, and ks=RMSNorm(vs)\boldsymbol{k}_s = \mathrm{RMSNorm}(\boldsymbol{v}_s) is its content key (content-dependent).

Key Insight: Loops Break AttnRes Assumptions

The authors identify that AttnRes is designed for standard Transformers, where sources differ in content and are fixed in number. Loops break both assumptions—sources are iterates of the same layers (becoming similar in content) and grow in number with each loop. This causes three problems:

  1. Similar iterates: Outputs of the same block across loops become increasingly similar, making it hard for content keys to distinguish them.
  2. Early convergence: The query norm reaches most of its final value within the first third of finetuning, committing the model to an early connection pattern before it can learn to differentiate sources.
  3. Growing sources: Full attention windows allow shortcuts to early loops, skipping intermediate ones. The weight on the path through every loop falls from 33.7% (3 loops) to 0.05% (7 loops), meaning deeper loops add little effective depth.

Methodology

Looped Architecture

The paper adopts the Huginn architecture (Geiping et al., 2025): layers are split into three parts—prelude (runs once), core (runs LL times, each run a "loop" indexed by t∈{1,…,L}t \in \{1, \ldots, L\}), and coda (runs once). The model is finetuned with cross-entropy loss. LoopRes applies only to the core; prelude and coda keep standard residual streams.

LoopRes Formulation

For a sub-layer in block ii of loop tt, the source set is:

Si(t)={p,b1(1),…,bB(t−1)⏟previous loops,b1(t),…,bi−1(t),ui(t)⏟loop t},(2)\mathcal{S}_i^{(t)} = \{\boldsymbol{p}, \underbrace{\boldsymbol{b}_1^{(1)}, \ldots, \boldsymbol{b}_B^{(t-1)}}_{\text{previous loops}}, \underbrace{\boldsymbol{b}_1^{(t)}, \ldots, \boldsymbol{b}_{i-1}^{(t)}, \boldsymbol{u}_i^{(t)}}_{\text{loop } t}\},\tag{2}

Loop-aware keys: Each source gets a trainable loop-aware key ksloop\boldsymbol{k}_s^{\mathrm{loop}} (per block, per loop, initialized from N(0,I)\mathcal{N}(\mathbf{0}, \boldsymbol{I})) alongside its content key. The attention weights become:

αs=exp⁡(qloop⊤ksloop+q⊤ks)∑s′∈Sexp⁡(qloop⊤ks′loop+q⊤ks′),(3)\alpha_s = \frac{\exp(\boldsymbol{q}^{\mathrm{loop}\top} \boldsymbol{k}_s^{\mathrm{loop}} + \boldsymbol{q}^{\top} \boldsymbol{k}_s)}{\sum_{s' \in \mathcal{S}} \exp(\boldsymbol{q}^{\mathrm{loop}\top} \boldsymbol{k}_{s'}^{\mathrm{loop}} + \boldsymbol{q}^{\top} \boldsymbol{k}_{s'})},\tag{3}

Both queries (qloop\boldsymbol{q}^{\mathrm{loop}} and q\boldsymbol{q}) are initialized to zero, starting from uniform weights.

Residual window: Restricts sources to the latest WW loops (default W=1W=1), bounding each input to (W+1)B+1(W+1)B + 1 sources. This prevents shortcuts to distant loops, forces incremental building, and keeps overhead constant as loops deepen.

Efficiency: A fused Triton kernel (following FlashAttention design) loads each source once from HBM and writes only the result back, significantly reducing IO cost and peak memory.

Experimental Setup

  • Backbones: Qwen3-{1.7B, 4B, 8B, 30B-A3B}-Base, Qwen3.5-2B-Base, Llama-3.2-1B.
  • Baselines: SFT plus 8 looped baselines (Ouro, TaH2-fixed, CloseLoop, InfiLoop, BRT, Huginn, Hyperloop, WMRE), all reimplemented on the same backbone with identical data and hyperparameters.
  • Compute budgets: 2× and 4× compute (corresponding to L=2,4L=2,4 for all-layer baselines; L=3,7L=3,7 for half-layer ones). LoopRes uses W=1W=1 at both budgets.
  • Training: 12,000 steps, learning rate 3×10−53 \times 10^{-5}, on math and code questions from AM-Qwen3-Distilled and UltraData-SFT-2605.
  • Evaluation: 7 benchmarks for backbones < 4B (MATH500, Olympiad-Bench, AMC23, AIME25, AIME26, HumanEval+, MBPP+); 5 harder benchmarks for 4B+ (AIME25, AIME26, OlympiadBench, IMO-AnswerBench, LiveCodeBench v6). Pass@1 averaged over ~1,000 samples per benchmark.

Empirical Validation / Results

Main Results (Qwen3-1.7B-Base)

Table 1 shows LoopRes achieves the best score on every benchmark at both compute budgets:

Methodavg. (2×)Δ vs SFTavg. (4×)Δ vs SFT
SFT43.2-43.2-
Huginn49.0+13.5%51.8+19.8%
BRT (best baseline)49.2+13.9%47.9+10.7%
LoopRes55.8+29.1%57.8+33.7%

Key observations:

  • LoopRes more than doubles the gain of the strongest baseline at 2× compute.
  • Relative gains are largest on hardest benchmarks (e.g., AIME25: 27.9 vs. SFT's 14.6 at 2×).
  • The gap widens as loops deepen (4× compute), showing LoopRes converts extra loops into further gains.

Scalability

  • Deeper loops (Figure 6): Score improves with loop depth, saturating beyond L=5L=5; best trade-off at L=3L=3.
  • Larger backbones (Table 3): On Qwen3-4B-Base, LoopRes improves average from 36.6 to 45.8 (+9.2 points); on 8B from 42.9 to 51.5 (+8.6); on 30B-A3B from 55.1 to 60.6 (+5.5). LoopRes on 4B surpasses SFT on 8B.
  • Other families (Table 4): Llama-3.2-1B improves from 14.3 to 19.6 (+5.4); Qwen3.5-2B-Base from 52.1 to 64.1 (+12.0).

Ablation Study (Table 5)

Variantavg. (2×)avg. (4×)
LoopRes55.857.8
Huginn + AttnRes (naive)53.955.0
W = 255.257.5
Loop-aware key only54.957.5
Content key only54.955.8

Both components are necessary; the loop-aware key becomes increasingly important as loops deepen.

Training Overhead (Table 2)

  • Step time: +4.8% vs. plain residual (1976.6 ms vs. 1886.3 ms).
  • Peak memory: +0.7% (8.62 vs. 8.56 GiB).
  • Without fused kernel: +54.9% time and +47.5% memory—highlighting the importance of the Triton fusion.

Analysis Findings

  • Iterative structure learned: Each block mainly updates its own previous output; the second block relies on the first block of the current loop.
  • Dominant loop-aware keys: Account for most of source selection (via Shapley values).
  • Adaptive content keys: Simple tokens ("But", "Wait") favor shallower outputs; difficult tokens (digits, math symbols) favor deeper ones—content keys allocate computation per token.
  • vs. AttnRes: LoopRes clearly separates adjacent loops, focuses on recent loops, and its content keys vary far more with the token (less fixed preference, more adaptive).

Theoretical and Practical Implications

Theoretical Implications

  • Loops as a scaling axis: LoopRes establishes loop depth as a legitimate test-time scaling axis, complementing token-level scaling (thinking budgets). The steeper scaling slope suggests looped computation is fundamentally more efficient than simply generating more tokens.
  • Structural vs. content information: The analysis reveals that distinguishing structural identity (loop/block coordinates) is more important than content similarity in looped networks—a finding that could inform other recurrent/iterative architectures.
  • Fixed vs. learned connections: The structured patterns learned suggest a simpler, fixed connection scheme might capture most of the benefit, opening questions about minimal viable designs.

Practical Implications

  • Cost-effective capability boost: LoopRes achieves SFT-on-8B-level performance using a 4B backbone, effectively "bridging the gap to larger models" at lower cost.
  • Efficiency on long outputs: LoopRes reaches the same score as SFT at lower compute, directly benefiting inference and post-training rollout budgets (critical for RL).
  • Minimal overhead: The +4.8% training time and +0.7% memory overhead make it practical for real-world finetuning pipelines.
  • Broad applicability: Works across model families (Qwen, Llama), sizes (1B–30B), and architectures (dense and MoE), suggesting it is a general technique.

Conclusion

Main Takeaways

LoopRes is a simple, effective, and scalable method for unlocking the power of loops in pretrained LLMs. By adding loop-aware keys (trainable structural identity) and a residual window (restricting to recent loops), it overcomes the fundamental limitations of naive Attention Residuals in looped settings. The result is significant and consistent gains across all tested backbones and benchmarks, with superior test-time scaling and minimal overhead.

Limitations

  • Evaluated only on math and code benchmarks; broader tasks (instruction following, open-ended generation) remain unvalidated.
  • Supervised finetuning only; interaction with reinforcement learning not yet explored.

Future Work

  1. Combine with RL: Lower compute cost on long outputs could reduce rollout budgets.
  2. Adaptive loop depth: Let the model decide how many loops each token/sequence needs.
  3. Larger scale: Scaling curves have not saturated on larger backbones.
  4. Simpler fixed schemes: The structured patterns suggest a fixed connection scheme might capture most benefits without learned attention weights, reducing overhead further.

Related papers