Looped Transformers
Looped transformers are transformer architectures that run a layer or block of layers multiple times, sharing learned weights across passes. Each pass can refine the hidden state produced by the preceding pass. Reusing a block increases the number of layer applications while keeping the stored weights of that block fixed. In language models that support variable loops, the pass count is one way to allocate test-time compute before generating the next token.[1][2][3]
How the loop works
Each pass through a recurrent block applies the same weights to a new hidden state. Some architectures also feed the original input representation back into the block on each pass. In Huginn, a prelude prepares the input, a recurrent core combines the prelude's output with the current state at each step, and a coda processes the final state before the model predicts a token.[2]
Consider a stack with two prelude layers, four recurrent layers, and two coda layers. The stack stores eight distinct layers. Running the core three times gives 2 + (4 × 3) + 2 = 16 layer applications in a forward pass. The count measures depth of computation within the transformer blocks. Runtime and memory depend on additional factors.[2][3]
The loop operates on vectors inside the model. Chain-of-thought generation spends computation on additional tokens, which in turn become part of the context. A model can do both. Huginn experiments varied the number of recurrent passes while evaluating both direct answers and answers with chain-of-thought prompting.[2]
Where to loop and when to stop
Networks can repeat a middle block or loop the entire stack. Universal Transformers, first posted in 2018 and published at ICLR 2019, used a recurrent self-attentive transformation that updates all sequence positions in parallel within a step. Its authors tested dynamic halting that lets each position take a different number of steps.[1][3]
Some designs use the same loop count on every forward pass. Other checkpoints expose the count as an inference setting. A third option is to learn which tokens should proceed through more passes. In Mixture-of-Recursions, one routing design makes a decision at each step about which tokens continue. Another assigns each token a depth at the outset.[4][5]
| Example | Repeated computation | How the pass count is used |
|---|---|---|
| Huginn-0125 | Four-layer core between a two-layer prelude and a two-layer coda | Variable at test time. The prototype has 3.5 billion parameters and was trained on about 800 billion tokens.[2] |
| Ouro | Shared stack of transformer layers | Research family with 1.4-billion- and 2.6-billion-parameter models. The authors report 7.7 trillion training tokens and studied how to learn when to exit the loop.[6] |
| Inkling 2 Mini | Twelve middle layers out of 24 | Three passes through the middle layers per token. The six layers at either end run once.[5] |
| TML-d24-varloop-research | Research counterpart to Inkling 2 Mini | Users can choose the pass count. It saw one to five passes sampled during part of midtraining and three during post-training.[7] |
| GLM-5.4 | Two passes through a 28-layer block | Z.ai introduced looping during continued training of a pretrained GLM-5 base.[8] |
What additional depth can buy
Yang and colleagues tested looped transformers on in-context data-fitting tasks at ICLR 2024. Their looped models approached the standard transformer baselines with under a tenth of the parameters in their experiments. In the Huginn study, additional test-time passes raised scores on some reasoning tasks, with the best recurrence count varying by evaluation.[2][9]
David Louapre's November 2026 Hugging Face Space separates two effects using models with roughly 0.6 million to 2 million parameters. One task supplied directed edges in shuffled order and asked the model to find the terminal node from a given starting point. At six layer applications, both the shared-weight and separately parameterized designs could follow the full 48-hop chains tested. Across the looped series, the same 0.63 million parameters supported longer chains as the number of layer applications increased.[10]
In a separate memorization test, the training set contained one million associations with randomly assigned answers. The shallow and looped models each had 0.83 million parameters and recalled about 299,000 and 294,000 associations respectively. The 2-million-parameter model with distinct layers recalled about 662,000. Those figures describe the specific synthetic tasks and training runs.[10]
Extra passes can also reach a point of diminishing returns. Thinking Machines Lab reported that most results for its variable-loop model changed little beyond three passes. On its N-Hop Lookup task, where the model follows chains through supplied lookup tables without generating an intermediate explanation, results continued to improve through ten passes. In Louapre's variable-loop chain tests, reach leveled off after six or seven passes, then fell in one run when the model was pushed further.[5][10]
Adapting pretrained models
Looping can also be introduced after pretraining. Chen and colleagues kept released model weights frozen and used an inference wrapper to repeat a short run of middle layers. The wrapper scales each residual update so that successive passes can refine the original update. In one comparison using the same prompts, Qwen3-4B-Instruct scored 59.79% on five-shot MMLU-Pro with the wrapper, up from 57.14% without it. The paper reports that gains were concentrated on knowledge-heavy multiple-choice tasks.[13]
LoopRes, a separate method from Zhao and colleagues, fine-tunes a pretrained model with a looped core. Each layer in the core can use a weighted combination of intermediate states. Learned keys distinguish the same block's outputs across passes, and a fixed window limits how far back each layer can look. In the authors' Qwen3-1.7B-Base experiments, average performance across seven math and coding benchmarks rose from 43.2 to 55.8 at twice the per-token compute of their supervised fine-tuning baseline without loops.[14]
Compute and memory costs
Each extra pass adds arithmetic. In an ordinary same-token loop, successive passes depend on previous results, increasing the sequential work before the model can emit a token. Cache use depends on the design. Repeated layers can produce different key and value vectors at every pass because their inputs change. Keeping them all increases the KV cache even if the sequence length stays fixed. Huginn researchers tested sharing a fixed cache budget across passes. GLM-5.4 reuses sparse key-value entries from the first pass while storing a local window of new entries for the second pass.[2][3][8]
The Mixture-of-Loops Transformer paper explores how the information passed between loops affects decoding. Its MoLT-KV variant starts each pass from the token embedding and reads key and value memory from the previous loop only at earlier token positions. With that prefix memory already cached, a new token can be processed in one traversal of the shared stack. The paper also describes a U-shaped variant with a separate decoder that reads the memory produced by a looped encoder.[15]
Comparisons of training efficiency depend on which resources are matched. Ekbote and colleagues tested dense models trained from scratch in 2026. Repeating the full stack generally gave the strongest results at a fixed parameter count, while looping the middle layers gave a better return under constrained training FLOPs. Schwethelm and colleagues found that recurrent applications were worth less than unique layers in validation loss at matched training compute under their training recipe. The number of passes, validation loss, decoding latency, and cache memory describe different aspects of the trade-off.[3][11]
Continue reading
- TransformersA Transformer is a deep learning architecture, introduced by eight Google researchers in the 2017 paper "Attention Is All You Need", that uses attention as the sole mechanism for modeling relationships between…Mentioned 9 times above
- Test-time computeTest-time compute (also called inference-time compute scaling or test-time scaling) is the practice of allocating additional computation while a large language model answers a queryLinked in the introduction
- Latent reasoning via recurrent depth (Huginn)Latent reasoning via recurrent depth is an approach to scaling a language model's test-time computation. A looped transformer repeatedly applies a shared block of layers to each token's hidden state.Links back to this article
- Mixture-of-Loops TransformerMixture-of-Loops Transformer (MoLT) is a family of looped transformers that shares layer weights across repeated passes and uses attention keys and values to carry information between them.Links back to this article
- Inkling 2 MiniInkling 2 Mini is an open-weight multimodal model from Thinking Machines Lab, released on November 20, 2026. It accepts text and images, generates text, and is distributed under Apache 2.0.Mentioned twice above
- GLM-5.4GLM-5.4 is a reasoning and coding model from Z.ai, released to GLM Coding Plan users on November 23, 2026.Mentioned twice above
More to read
Topics:Large Language ModelsModel ArchitectureTransformer Models
References
- ^1 ^2Dehghani, M., Gouws, S., Vinyals, O., Uszkoreit, J., and Kaiser, L. Universal Transformers. Preprint posted July 10, 2018. ICLR, 2019.
- ^1 ^2 ^3 ^4 ^5 ^6 ^7Geiping, J., et al. Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approach. arXiv, February 2025. See sections 2, 5, and 6.
- ^1 ^2 ^3 ^4 ^5Ekbote, C., et al. How to Loop Your Transformer: Loop Scaling, Specialization, and Parallel Inference. arXiv, October 29, 2026. See section 3 and appendix B.
- ^Bae, S., et al. Mixture-of-Recursions: Learning Dynamic Recursive Depths for Adaptive Token-Level Computation. arXiv, July 2025. See section 2.2.
- ^1 ^2 ^3Thinking Machines Lab. Introducing Inkling 2 Mini. November 20, 2026.
- ^Zhu, R.-J., et al. Scaling Latent Reasoning via Looped Language Models. arXiv, October 2025. Revised October 2026.
- ^Thinking Machines Lab. TML-d24-varloop-research Model Card. November 20, 2026.
- ^1 ^2Z.ai. GLM-5.4: Toward Generalized Coding with Our First Loop Transformer. November 23, 2026.
- ^Yang, L., Lee, K., Nowak, R., and Papailiopoulos, D. Looped Transformers are Better at Learning Learning Algorithms. Preprint posted November 2023. ICLR, 2024.
- ^1 ^2 ^3Louapre, D. Looped transformers: thinking twice with the same weights. Hugging Face Spaces, November 25, 2026.
- ^Schwethelm, K., Rueckert, D., and Kaissis, G. How Much Is One Recurrence Worth? Iso-Depth Scaling Laws for Looped Language Models. arXiv, April 2026.
- ^Chanakya Ekbote et al. Original image source. CC BY 4.0. Figure reproduced from the source paper.
- ^Chen, L., Li, J., Liang, C., Lao, N., and Liu, Q. Training-Free Looped Transformers. arXiv preprint, May 2026. See sections 2 and 3 and Table 3.
- ^Zhao, X., et al. Unlocking the Power of Loops in Pretrained LLMs with Loop Residuals. arXiv preprint, November 2026. See section 2.4 and Table 1.
- ^Zhu, L., Wang, S., Wang, X., Bai, J., Wang, B., and Bai, X. Mixture-of-Loops Transformer. arXiv preprint, November 25, 2026.
Improve this article
Add missing citations, update stale details, or write a clearer explanation. Anyone can edit: changes go live when you publish, and every edit is checked by an editor.
3 revisions · v3 · 1,564 words · full history
Fact-checks are independent of edits: a reviewer re-verifies the article against its sources and stamps the date. How we verify
Research and drafting on this wiki are AI-assisted, under named human editorial standards. How AI is used here
Cite this page: AI Wiki. "Looped Transformers." aiwiki.ai, updated 29 Nov 2026. CC BY 4.0. https://aiwiki.ai/wiki/looped_transformers

