Unlocking the Power of Loops in Pretrained LLMs with Loop Residuals
Xuanlei Zhao, Hailun Xu, Kai Wang, Yang Luo, Yingxuan Ren, Zirui Zhu, Yuxuan Lou, Kun Xu, Yan Wang, Kanchan Sarkar, Yang You
cs.CL, cs.LG
2026-11-24
LoopRes adds loop-aware keys and a W=1 residual window. Qwen3-1.7B at 2× compute averages 55.8 vs SFT 43.2 (+29.1%), more than double the best prior loop gain.
A looped Transformer runs one shared block of layers several times in a single forward pass. Depth follows the loop count, and the parameter count stays put. Pretraining that structure from scratch is expensive, and at matched cost the gains are often small or negative. Finetuning a pretrained checkpoint into a loop is much cheaper. Against supervised finetuning with no loop (SFT), published loop designs still move the score only a little.
The bottleneck is the pathway between loops. Layer-wise repeats and full-stack repeats both crush earlier outputs into a few states before the next loop starts. Attention Residuals (AttnRes) take a different read: each sub-layer mixes earlier outputs with a softmax, and the key is the RMSNorm of the source, so the weights depend on the token. AttnRes was built for ordinary Transformers, where sources differ in content and their count is fixed. Loops break both. Outputs of the same layer are iterates, so they look more alike as depth grows, and every new loop adds more sources.
On Qwen3-1.7B at 2× compute, Huginn plus AttnRes shows the failure. Cosine similarity inside a block, across loops, is much higher than across blocks, and at seven loops many iterates get nearly the same score. The output query norm is already near its final value in the first third of finetuning, so the wiring locks in early. Multiply the attention weights back to the first loop, and the share of paths that touch every loop falls from 33.7% at 3 loops to 0.05% at 7. Extra loops add almost no effective depth.
The skeleton is Huginn. Layers split into a prelude, a core, and a coda. The prelude runs once on the token embeddings, the coda runs once on the last loop and predicts the next token, and the core repeats L times. LoopRes loops about the middle half of the layers, so L=3 is about 2× compute and L=7 is about 4×. Baselines that loop every layer use L=2 and L=4 for those same budgets. The core is grouped into blocks, and the attention residual is applied only there.
Each sub-layer builds its input as a weighted sum of sources. Queries start at zero, so the weights begin uniform. The content key is the source after RMSNorm, a scale by root-mean-square with no mean subtraction. LoopRes adds a loop-aware key: one trainable vector per block per loop, drawn from a standard normal. The score is a structural dot product plus a content dot product, then a softmax. That structural key names the loop index and the block index, and gradients update it directly.
A residual window of W=1 keeps the latest previous loop plus the current one. A layer cannot jump to a much earlier loop, the source count stays capped so the softmax does not dilute the current loop, and the overhead does not grow with L. The sum is fused into a Triton kernel that reads each source from device memory once.
Training is SFT on math and code from AM-Qwen3-Distilled and UltraData-SFT-2605. Qwen3-1.7B-Base trains on replies rewritten by Qwen3-8B: 572K conversations and 3.1B tokens. Larger backbones train on the original replies from Qwen3-235B-A22B. Every run is 12,000 steps at learning rate 3×10^-5.
The 1.7B eval has seven tasks: AIME25, AIME26, AMC23, OlympiadBench, MATH500, HumanEval+, and MBPP+. Decoding uses temperature 0.6, top-p 0.95, top-k 20, and at most 32K tokens. pass@1 is the fraction correct, averaged over about 1,000 samples per task. All eight loop baselines were reimplemented on the same backbone, data, and hyperparameters. The 2× and 4× labels are compute per token against SFT. SFT itself is the 1× model.
| Method | Compute | Average | vs SFT | Val loss |
| SFT | 1× | 43.2 | - | 0.312 |
| BRT | 2× | 49.2 | +13.9% | 0.302 |
| Huginn | 2× | 49.0 | +13.5% | 0.303 |
| LoopRes | 2× | 55.8 | +29.1% | 0.292 |
| Huginn | 4× | 51.8 | +19.8% | 0.299 |
| LoopRes | 4× | 57.8 | +33.7% | 0.291 |
At 2×, LoopRes is first on every task. AIME25 moves from 14.6 to 27.9, AIME26 from 11.7 to 19.4, HumanEval+ from 57.3 to 71.8, and MBPP+ from 56.2 to 68.9. At 4× the average reaches 57.8, though OlympiadBench falls from 53.8 to 52.9. Huginn, the strongest baseline once the loop deepens, reaches 51.8 and still trails LoopRes. Ouro sits below SFT at both budgets, at 42.9 and 42.3. The 29.1% gain over SFT is more than twice BRT's 13.9%.
From 4B up, the paper switches to five harder tasks: AIME25, AIME26, OlympiadBench, IMO-AnswerBench, and LiveCodeBench v6. Those averages are not comparable to the seven-task numbers. At 2×, Qwen3-4B goes from 36.6 to 45.8, Qwen3-8B from 42.9 to 51.5, and the mixture-of-experts Qwen3-30B-A3B from 55.1 to 60.6. LoopRes on the 4B model scores 45.8, above SFT on the 8B model at 42.9. On the original seven tasks, Llama-3.2-1B goes from 14.3 to 19.6 and Qwen3.5-2B-Base from 52.1 to 64.1. All six backbones and all three families move up. The absolute gap shrinks to 5.5 points on the 30B MoE.
With the thinking budget swept from 1K to 30K tokens, LoopRes from 1.7B to 8B climbs faster than SFT as decode FLOPs grow, and it hits a given score with less compute on long outputs. Loop counts from L=2 to L=11 flatten after L=5. The best score-versus-compute point is L=3. There is no table of scores at each budget.
On the same seven-task average, Huginn with unmodified AttnRes scores 53.9 and 55.0 at 2× and 4×, 1.9 and 2.8 behind LoopRes. W=2 drops the 2× score from 55.8 to 55.2, and larger windows are worse at both budgets. Either key alone lands below the pair, and removing the structural key hurts more as the loop deepens.
Against a plain residual that loops the same layers, a 16K sequence costs 1976.6 ms per step versus 1886.3 ms (+4.8%), and peak activation memory goes from 8.56 GiB to 8.62 GiB (+0.7%). Without the fused kernel, step time rises 54.9% and memory 47.5%.
The structural key carries most source selection, about 90% on the input side at three loops. The content key spends a smaller share by token: function words such as But and Wait prefer shallower outputs, while digits and math symbols prefer deeper ones.
Same math and code data, same 12,000 steps. Looping goes from often losing to SFT to winning all seven tasks, and a deeper loop still adds points on the average. A 4B model at about 2× compute beats an 8B SFT run on the five hard tasks. If a larger pretraining run is off the table, loop depth is a compute axis you can attach to a checkpoint you already have.
On long outputs, LoopRes matches SFT at lower decode cost. Against a plain looped residual, training step time rises 4.8%.
The recipe is two small changes. The gain comes from making each loop continue the previous one. The pretraining objective is untouched.
The benchmarks are math and code only. General instruction following and open-ended generation are untested, so contest problems inflate the average. Training is SFT only. The paper says the interaction with reinforcement learning is still open.
The 1.7B run learns from Qwen3-8B rewrites. Larger backbones learn from raw Qwen3-235B-A22B replies. Teacher strength is not held fixed, so the cross-size curve is not a scaling law. LoopRes at 4B beating SFT at 8B uses the same sampler, and there is no run that hands those extra FLOPs to the 8B SFT model directly.
The 30B result is the MoE 30B-A3B, with far fewer active parameters than a dense model of that size. The 2× and 4× labels assume the prelude and coda are about half the layers. A different split would misalign LoopRes with the full-stack baselines.
Plain AttnRes already scores 53.9, and LoopRes scores 55.8. Part of "more than double the best loop gain" is that several loop designs barely beat SFT. The paper suggests a fixed wiring might capture most of the learned pattern. That control is missing.