# Looped Transformers

> Source: https://aiwiki.ai/wiki/looped_transformers
> Updated: 2026-11-29
> Categories: Large Language Models, Model Architecture, Transformer Models
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) - attribute to "AI Wiki (aiwiki.ai)"
> Cite as: AI Wiki. "Looped Transformers." aiwiki.ai, 29 Nov 2026. https://aiwiki.ai/wiki/looped_transformers
> From AI Wiki (https://aiwiki.ai), the free encyclopedia of artificial intelligence. Reuse freely with attribution.

**Looped transformers** are [transformer](https://aiwiki.ai/wiki/transformers) 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](https://aiwiki.ai/wiki/test_time_compute) before generating the next token.[1][2][3]

## How the loop works

<figure>
<a href="/images/looped-transformers-a21db265d96e.png"><img src="/images/looped-transformers-a21db265d96e.png" alt="Diagrams compare loops within transformer blocks and repeated passes through layers or whole stacks." /></a>
<figcaption>Looped transformer designs can repeat a component within a block, a single block, or a stack of blocks. [12]</figcaption>
</figure>

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](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/recurrent_depth_reasoning) | 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](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/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](https://aiwiki.ai/wiki/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]

## References

1. Dehghani, M., Gouws, S., Vinyals, O., Uszkoreit, J., and Kaiser, L. [Universal Transformers](https://arxiv.org/abs/1807.03819). Preprint posted July 10, 2018. ICLR, 2019.
2. Geiping, J., et al. [Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approach](https://arxiv.org/abs/2502.05171). arXiv, February 2025. See sections 2, 5, and 6.
3. Ekbote, C., et al. [How to Loop Your Transformer: Loop Scaling, Specialization, and Parallel Inference](https://arxiv.org/abs/2610.40325). arXiv, October 29, 2026. See section 3 and appendix B.
4. Bae, S., et al. [Mixture-of-Recursions: Learning Dynamic Recursive Depths for Adaptive Token-Level Computation](https://arxiv.org/abs/2507.10524). arXiv, July 2025. See section 2.2.
5. Thinking Machines Lab. [Introducing Inkling 2 Mini](https://thinkingmachines.ai/news/inkling-2-mini/). November 20, 2026.
6. Zhu, R.-J., et al. [Scaling Latent Reasoning via Looped Language Models](https://arxiv.org/abs/2510.25741). arXiv, October 2025. Revised October 2026.
7. Thinking Machines Lab. [TML-d24-varloop-research Model Card](https://thinkingmachines.ai/model-card/tml-d24-varloop-research/). November 20, 2026.
8. Z.ai. [GLM-5.4: Toward Generalized Coding with Our First Loop Transformer](https://z.ai/blog/glm-5.4?lang=en). November 23, 2026.
9. Yang, L., Lee, K., Nowak, R., and Papailiopoulos, D. [Looped Transformers are Better at Learning Learning Algorithms](https://arxiv.org/abs/2311.12424). Preprint posted November 2023. ICLR, 2024.
10. Louapre, D. [Looped transformers: thinking twice with the same weights](https://huggingface.co/spaces/dlouapre/looped-transformers). Hugging Face Spaces, November 25, 2026.
11. Schwethelm, K., Rueckert, D., and Kaissis, G. [How Much Is One Recurrence Worth? Iso-Depth Scaling Laws for Looped Language Models](https://arxiv.org/abs/2604.21106). arXiv, April 2026.
12. Chanakya Ekbote et al. [Original image source](https://arxiv.org/html/2610.40325v1#S3.F2). [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Figure reproduced from the source paper.
13. Chen, L., Li, J., Liang, C., Lao, N., and Liu, Q. [Training-Free Looped Transformers](https://arxiv.org/html/2605.23872v1). arXiv preprint, May 2026. See sections 2 and 3 and Table 3.
14. Zhao, X., et al. [Unlocking the Power of Loops in Pretrained LLMs with Loop Residuals](https://arxiv.org/html/2611.31094v1). arXiv preprint, November 2026. See section 2.4 and Table 1.
15. Zhu, L., Wang, S., Wang, X., Bai, J., Wang, B., and Bai, X. [Mixture-of-Loops Transformer](https://arxiv.org/abs/2611.34923). arXiv preprint, November 25, 2026.

