How to Loop Your Transformer: Loop Scaling, Specialization, and Parallel Inference
AuthorsChanakya Ekbote, Artidoro Pagnoni, Devendra Singh Sachan, Shruti Bhosale, Mike Lewis, Maryam Fazel-Zarandi, Shashank Rajput, Sujan Kumar Gonugondla
AffiliationsFAIR at Meta · MIT
The paper explores how to make transformers deeper through weight reuse while balancing model quality, training cost, and inference speed.
Key results
Largest dense decoder-only Transformer tested.
Largest training-token budget reported.
Largest loop factor tested.
Upper end of the reported overhead for loop-specific specialization in the 300M comparison.
Two-loop models at this training budget were compared with vanilla models trained at TPP 160 for FLOP efficiency.
What the paper found
Meta’s study asks when repeating shared Transformer weights is useful, testing dense decoder-only models from 70M to 1B parameters, trained on up to 155B tokens and with up to 32 loops. On DCLM and other language-modeling benchmarks, full-stack looping gives the strongest quality when parameter count is the constraint, while looping only a middle block can make better use of limited training FLOPs. More loops do not guarantee better results: gains can plateau, reverse, or become unstable. To reduce the limits of exact weight sharing, the researchers add loop-specific low-rank adapters; these help more as loop count rises, with overhead reaching 4.3% in the reported 300M comparison. For faster autoregressive inference, Parallel Loop Transformers shift loop-to-loop information across adjacent tokens so loop stages can run concurrently. The key repair is to preserve the current-token embedding, separately apply RMSNorm to it and the shifted hidden state, then combine them with a gate. This modified design retains strong quality: at 1B, its two-loop version closely tracks the sequential control, and two-loop models trained at TPP 80 can reach a given DCLM quality with fewer FLOPs than vanilla models trained at TPP 160. The paper also reports ChatGPT and Claude assistance with writing and coding, not the core research.
Original abstract
Looping in transformer models reuses weights by repeatedly applying the same transformer, or parts of it, making the model deeper without increasing its parameter count. Whether looping is useful depends on which constraint dominates: model size, training compute, or autoregressive inference efficiency. We study these trade-offs jointly in dense decoder-only transformers trained from scratch, varying which parts of the model are looped, how many loops are applied, and how information is passed between loops. Our experiments span models with up to 1B parameters, trained on up to 155B tokens with up to $1.07\times10^{21}$ FLOPs and 32 loops. We find that looping the full transformer generally gives the strongest quality at a fixed parameter budget, whereas looping a middle block of layers gives a better return when training FLOPs are constrained. Adding loops is not uniformly beneficial: gains eventually saturate, reverse, or become unstable. This motivates asking whether forcing every loop to use the same weights limits the benefit of deeper looping. We address this by adding small loop-specific low-rank adapters that improve quality, with larger gains as more loops are added. Looped transformers also suffer a decoding slowdown proportional to the number of loops. Parallel Loop Transformers address this by passing hidden states between loops across adjacent token positions, allowing loop stages to run concurrently. However, in our experiments the original formulation does not consistently retain the quality gains of ordinary looping. We find that preserving the current-token embedding and separately normalizing it and the previous-token hidden state before combining them recovers strong performance across model scales and training budgets. Together, these results show that effective looping requires matching the design to the resource constraint and inference setting.
Read the original paperMore in Transformers
Browse all 51 papers →Hierarchical Residuals: A Minimalist Decoupling of Residual Width from Compute Width
Ziteng Wang, Jianqiao Lu, Xinyu Ma, Jintao Zhang, Jun Zhu, Yiyuan Ma, Jianfei Chen
HiRes gives Transformers a wider memory path between blocks without making each layer more computationally expensive.
StateLoop: Persistent State for Looped Transformers
Feichen Song, Boyi Zeng, He Li, Shixiang Song, Yiqin Hao, Zitong Wang, Yizhou Yang, Yifan Liu, Ziwei He, Zhouhan Lin
StateLoop gives repeatedly applied Transformers a persistent memory to carry useful information across computation loops.
A Conditional No-Hair Theorem for Transformers: How Language Models Forget Their Prompt
Shuyang Xiang
The paper finds that a transformer’s direct memory of its prompt fades as it generates text, while the text itself can carry that memory forward.