Guide · AI and GenAI
Looped Transformers in 2026: More Depth, Same Parameters
20 min readUpdated By Saket Bhatnagar
Researched and drafted with AI, reviewed and edited by Saket Bhatnagar.
In short
- Looped transformers run one shared block of layers several times for each token, a small piece of text. The model gets deeper without storing more parameters, the learned numbers held in GPU memory, the memory on the graphics chip that runs the model.
- Looping does not cut compute. Every loop still costs FLOPs, the additions and multiplications done per token, and by default every loop adds to the KV cache, the saved attention data for earlier tokens.
- A September 2026 paper tested looping in mixture-of-experts models, which send each token to a few small expert networks. With compute per token, parameters and KV cache matched, looping reached the same training loss, its error score, with 6.8% to 18.0% less training compute. That compares the best run at each training budget.
- As of 19 October 2026, looping is mostly research. At least two widely used open-source serving frameworks support one looped coding model, in releases of 16 and 18 October 2026. Both limit the cache that later loops keep.
- Beginners can stop after the section on why looping saves memory but not compute. Engineers get KV cache maths for 40 students, four ways to cap that cache and a pilot plan.
What goes wrong when you want a deeper model but cannot afford more memory?
You hit a memory wall. Every extra layer in a standard model adds parameters that must sit in GPU memory. Looped transformers are one research answer: reuse the same layers instead of adding new ones.
Picture a common setup. An ed-tech team runs a coding-tutor app where students paste broken Python code and get the bug explained in English or Marathi. The setup is made up, but the problem is real.
The team serves its own small model on one rented GPU at about Rs 220 an hour. It has Rs 30 lakh (3 million rupees) for training, so every experiment must count.
The current model has 24 layers. A deeper one might explain bugs better, but the GPU must also hold working memory for 40 students at once. The team wants to know whether looping buys depth without that memory.
Which words do you need before looped transformers make sense?
Four words carry this whole guide: layer, parameters, FLOPs and KV cache. Each one is a different budget, and looping moves only one of them.
Layer. A layer is one round of processing for every token. In a model that writes text, attention lets each token look back at earlier tokens. Then a feed-forward step, a small network applied to each token on its own, reshapes it.
Parameters. These are the numbers the model learns in training, also called weights. In a normal GPU setup, all of them sit in GPU memory while the model runs.
FLOPs. A FLOP, or floating-point operation, is one addition or multiplication on numbers with a fractional part, like 0.75. FLOPs per token is the work done for one token, which you pay for in GPU time and rupees.
KV cache. When a model writes text one token at a time, attention needs keys and values, two lists of numbers for every earlier token, in every layer. The KV cache saves them so they are not recomputed. It shares GPU memory with the parameters.
What are looped transformers?
Looped transformers run one shared block of layers several times in a row, instead of stacking many different layers. The block's parameters are stored once, but each token passes through them on every loop.
Think of exam answer sheets. A stacked model hires three checkers, and each reads every sheet once. A looped model pays one checker to read every sheet three times.
Each checker is a block of layers, the salary is parameter memory and the reading time is compute. The salary bill drops to a third, but the reading time stays the same.
Where the picture breaks: three human checkers would all look for the same mistakes. Stacked layers each learn a different job, while a shared block must serve every loop with one set of weights.
The team sketches a looped option: 8 unique layers, run 3 times. Each token still gets 24 layer runs, but only a third of the layer parameters are stored.
Many real designs keep a few ordinary layers outside the loop. Papers call the layers before the loop the prelude and the layers after it the coda.
The 2025 recurrent-depth model below has a 2-layer prelude and a 2-layer coda. The September 2026 paper loops only the middle half of its layers.
One token through a looped transformer
Drag to exploreOnly the shared block repeats. Its weights are stored once, but its compute is paid on every loop.
Diagram connections:
- Token from the student to Prelude layers
- Prelude layers to Shared block
- Shared block to Enough loops?
- Enough loops? to Shared block (No: loop again)
- Enough loops? to Coda layers (Yes)
- Coda layers to Next token
- Token from the student: One piece of the pasted code
- Prelude layers: Run once: turn the token into numbers
- Shared block: Same weights on every loop
- Enough loops?: Fixed count, or stop when guesses settle
- Coda layers: Run once: score every possible next token
- Next token: Added to the bug explanation
Why does looping save memory but not compute?
A shared block costs memory once but compute every time it runs. The Python below counts both for the team's two designs, using rough textbook sizes rather than a real model.
Pause and predict: the looped design stores a third of the layers. What happens to its compute and its KV cache?
HIDDEN = 1024 # toy: numbers per token
PARAMS_PER_LAYER = 12 * HIDDEN * HIDDEN # attention 4x, feed-forward 8x
FLOPS_PER_PARAM = 2 # one multiply, one add per weight
def design_cost(unique_layers, loops):
params = unique_layers * PARAMS_PER_LAYER
layer_runs = unique_layers * loops
flops = layer_runs * PARAMS_PER_LAYER * FLOPS_PER_PARAM
kv_slots = layer_runs # one key-value slot per layer run
return params, flops, kv_slots
for name, unique, loops in [("stacked", 24, 1), ("looped", 8, 3)]:
params, flops, kv = design_cost(unique, loops)
print(f"{name}: {params / 1e6:.0f}M params, "
f"{flops / 1e9:.2f} GFLOPs per token, {kv} KV slots per token")Run it with Python 3 and you should see two lines. The stacked line reads 302M params, 0.60 GFLOPs per token and 24 KV slots per token. The looped line reads 101M params, 0.60 GFLOPs and 24 KV slots.
What just happened? Both designs do the same 0.60 billion FLOPs per token and save the same 24 key-value slots. Only the parameters drop, from 302 million to 101 million.
The 12 x HIDDEN x HIDDEN size is the usual estimate for one layer whose feed-forward step is four times wider than HIDDEN. The 2 FLOPs per weight leave out attention's own work, which grows with text length.
Where did the idea of looping layers come from?
Looping layers is an old idea with new results. A 2018 paper already reused one shared layer over repeated steps instead of stacking different layers. It also let each token position stop once a learned halting score said it was done.
In February 2025, Geiping and colleagues trained a 3.5 billion parameter recurrent-depth model on 800 billion tokens. Recurrent depth means the depth comes from repeating a block, not from adding layers.
That model has only 8 real layers: 2 before the loop, a 4-layer core block and 2 after. With 32 loops, its effective depth is 2 + 4 x 32 + 2 = 132 layers.
In training, the loop count was drawn at random, with a target average of 32. At test time, its scores on several reasoning tests rose as it ran more loops, with gains flattening at higher counts. It wrote no extra tokens to get there.
What did the 2026 compute-matched paper find about looped transformers?
It found that looping still helped after the extra compute was taken away. The paper, arXiv 2609.01343, was first posted on 1 September 2026 and last revised on 11 September.
Earlier comparisons often matched only parameters, so the looped model quietly got more FLOPs. This paper matched FLOPs per token, parameters and KV cache, keeping each within about 4% of the baseline in its design table.
It uses a mixture-of-experts model, where a small router sends each token to a few of many small expert networks. The middle half of the layers runs twice.
To pay for the second visit, the authors made the layers narrower and added experts to win back parameters. Attention splits into parallel lookups called heads. Smaller heads, with each set of keys and values shared by more heads, kept the KV cache nearly flat.
The 12-layer example in the compute-matched paper
Drag to exploreThe middle six layers are visited twice, so 12 stored layers give 18 layer runs.
Diagram connections:
- Token to First quarter of layers
- First quarter of layers to Middle half, visit 1
- Middle half, visit 1 to Middle half, visit 2 (Reuse the same weights)
- Middle half, visit 2 to Last quarter of layers
- Last quarter of layers to Next-token scores
- Token: Enters the 12-layer stack
- First quarter of layers: The first three layers, run once
- Middle half, visit 1: The middle six layers, first pass
- Middle half, visit 2: Same layers and weights, second pass
- Last quarter of layers: The last three layers, run once
- Next-token scores: 18 layer runs from 12 stored layers
The authors tested four sizes, the largest with 54 billion parameters outside the word lookup table. Loss is the model's error score in training, and lower is better.
On the compute-optimal frontier, the best result each training budget can buy, the looped model reached the same loss with 6.8% to 18.0% fewer training FLOPs. Its biggest gains on later tests were on code, and they grew with longer inputs.
The authors offer a partial reason. On the second visit, less attention lands on the attention sink, often the first token, which soaks up attention whatever the text says. More lands on useful tokens.
How can earlier loops help a looped model decode better?
A 1 October 2026 paper, arXiv 2610.02185, turns the first loop's state into a weak guess and pushes the final guess away from it. It needs no extra training and no second model.
In plain terms, the final scores move further in the direction they changed since loop 1. If loop 1 and the final loop already agree on a word, little changes.
One variant applies this to the output scores and needs one extra output pass. The other applies it to the hidden numbers before the last layers and adds no output cost.
How the 2026 decoding method picks the next token
Drag to exploreBoth guesses come from the same model, so no second model or extra training is needed.
Diagram connections:
- Student's code question to First loop
- First loop to Later loops
- First loop to Weak guess (Early state)
- Later loops to Strong guess (Final state)
- Weak guess to Contrast step
- Strong guess to Contrast step
- Contrast step to Chosen next token
- Student's code question: Prompt enters the looped model
- First loop: Shared block, run once so far
- Later loops: Same block, run the remaining times
- Weak guess: Decoded from the first loop
- Strong guess: Decoded from the final loop
- Contrast step: Push final guess away from the weak one
- Chosen next token: Added to the bug explanation
On a 2.6 billion parameter looped model, pass@1 on a 2024 maths contest set rose from 61.88% to 73.33%. Pass@1 is the share of problems solved on one try, here averaged over 16 samples per problem.
On the 2025 recurrent-depth model, pass@1 on a Python coding test rose from 22.56% to 31.71% with the hidden-number variant.
The authors also ran the models with half their loops, which alone lost 0.17 to 1.29 points on a seven-test multiple-choice average. They report that the method closed that gap in all six settings they tested, matching or beating full depth without it.
That half-depth setup used 22.5% to 48.2% fewer forward FLOPs, the work of running the model, not training it. The paper counts that arithmetic rather than timing real runs.
Can looped transformers work with images too?
Yes, according to a vision-language paper, arXiv 2609.38426, posted on 29 September 2026 and revised on 13 October. Vision-language models read images and text together.
Its model has a language core of about 1 billion parameters, and in its default setting one forward pass, a single run through the model, makes 128 transformer-layer calls. The authors report it beats a range of similarly sized and larger non-looped models on image understanding and visual reasoning tests.
It does not win everywhere. In its main results table, six of 11 compared models beat it on chart reading. Seven beat it on a hallucination test, which checks for answers the image does not support. The authors also write that equal parameter storage is not the same as equal training FLOPs or wall-clock cost.
The tutor app may later read screenshots of error messages, so the team marks this paper as one to watch.
What are the trade-offs of looped transformers in production?
By default, looping shrinks only the weights. Compute, KV cache and latency, which is how long each answer takes, stay those of the full depth. The next section puts numbers on the cache.
| Cost | Standard stacked model | Looped model, same depth | What the team sees |
|---|---|---|---|
| Parameters stored | One set per layer | One set per shared block | 24 layers stored versus 8 |
| Compute per token | One run per layer | One run per layer, per loop | 24 layer runs either way |
| Weight memory | Grows with depth | Stays flat as loops grow | About a third for the layers |
| KV cache | Grows with layers | Grows with layer runs unless capped | No saving by default |
| Latency | Layers run one after another | Layer runs also go in order | Similar at equal depth, must be measured |
Compute: every loop is real arithmetic. Triple the loops and the block's GPU time roughly triples too.
Latency: a stacked model also runs its layers in order, so at equal depth the sequential work is similar. Adding loops for extra depth adds waiting, which is why stopping early matters.
The recurrent-depth paper lets a token stop looping once two loops in a row give nearly the same prediction. The compute-matched and decoding papers measure cost in FLOPs rather than timing a serving setup, so measure latency yourself.
How much KV cache does a looped transformer really need?
By default, as much as a stacked model of the same depth, because every loop runs attention and can save its own keys and values. For the team, that cache, not the weights, is the real squeeze.
The Python below sizes the cache for 40 students with 4,000 tokens each, using the toy model from earlier. Each key and each value is 1,024 numbers long, and a GiB is 1,073,741,824 bytes.
BYTES = 2 # each number stored in 16 bits
KV_NUMBERS = 2 * 1024 # one key and one value per layer run
USERS, TOKENS = 40, 4000 # 40 students, 4,000 tokens each
GIB = 1024 ** 3
def kv_gib(full_runs, window_runs=0, window=64):
per_run = KV_NUMBERS * BYTES
full = full_runs * per_run * TOKENS
recent = window_runs * per_run * min(window, TOKENS)
return USERS * (full + recent) / GIB
print(f"stacked, 24 layers: {kv_gib(24):.2f} GiB")
print(f"looped, every loop: {kv_gib(24):.2f} GiB")
print(f"looped, one loop kept: {kv_gib(8):.2f} GiB")
print(f"looped, loop 1 + window: {kv_gib(8, window_runs=16):.2f} GiB")
print(f"weights: {301_989_888 * BYTES / GIB:.2f} GiB stacked, "
f"{100_663_296 * BYTES / GIB:.2f} GiB looped")Run it and you should see 14.65 GiB for the stacked model and for the looped model that saves every loop. Keeping one loop's cache gives 4.88 GiB, and loop 1 plus 64-token windows gives 5.04 GiB.
The last line shows the weights: 0.56 GiB stacked against 0.19 GiB looped. Those sizes assume each number takes 16 bits, which is 2 bytes.
What just happened? In this toy, the cache for 40 students is about 26 times the stacked model's weights. Looping alone saves about 0.38 GiB of weights and nothing of the 14.65 GiB cache.
Capping the cache cuts it to about a third. Whether answers stay as good after that cut must be tested, model by model.
Real models often shrink every one of these numbers with grouped-query attention, where several query heads share one set of keys and values. The toy leaves that out to keep the arithmetic plain.
| Approach | How it works | Where it comes from | Toy cache for 40 students |
|---|---|---|---|
| Save every loop | Each loop stores its own keys and values | The simple default | 14.65 GiB |
| Fixed slots per token | Loop i writes slot i mod k, overwriting an older loop | 2025 recurrent-depth paper | 4.88 GiB with k = 1 |
| Smaller shared heads | Narrower keys and values, each set shared by more heads | September 2026 compute-matched paper | Not modelled here |
| First loop plus window | Loop 1 keeps a full cache, later loops keep only recent tokens | The looped coding model's design, read in serving source code | 5.04 GiB with a 64-token window |
In the slot scheme, i mod k is the remainder of i divided by k. With k = 4, the fifth loop overwrites the first loop's keys and values.
The recurrent-depth paper tried that budget of 4 slots per token on a multi-turn chat test. The authors report that this did not reduce performance.
The looped coding model's serving code shows a more detailed design. Later loops read loop 1's full cache, keep their own cache of recent tokens and blend the two with a learned gate.
That code defaults to 2 loops and a 64-token window when the model's settings give neither. We read this in the source of two frameworks' releases from 16 and 18 October 2026, not in their docs. We did not check the model's own release notes. As of 19 October 2026, treat it as behaviour that can change, and pin your version. One of the two frameworks also dropped another looped model after its 25 July 2026 release.
Should a small team train a looped model today?
Only as a measured pilot. The results come from research setups, and serving support covers one looped coding model in the open-source frameworks we checked. The team plans two weeks of tests before touching most of the Rs 30 lakh.
Match the budgets
Compare designs on FLOPs per token, parameters and KV cache, as the compute-matched paper did. Write down any budget that differs.
Train two small twins
Train the 24-layer model and the 8-layer block looped 3 times on the same data, capped at Rs 2 lakh.
Test on real tasks
Score both on 500 real student bug reports, not only public tests.
Measure serving
On the target GPU, record tokens per second and KV cache GiB with 40 students at once.
Check your serving stack
Confirm your server can run the loop and keep a correct cache for each loop, or budget time to build it.
The twins match depth and FLOPs but not parameters, 302 million against 101 million, so the team writes that down. With a third of the parameters, the looped twin may score lower. Based on the sums above, the team expects the looped twin to save weight memory but not time. It expects the cache to still set the student limit. The team approves a larger test only if quality holds.
How do you explain looped transformers in a system design interview?
Frame it as a budget trade: weight memory against compute and KV cache per token.
Define it in one line
A looped transformer runs one shared block several times, so depth grows while stored parameters stay fixed.
Separate the three budgets
Name parameters, FLOPs per token and KV cache. Looping cuts the first, but not the other two by default.
Cite a fair comparison
The September 2026 paper matched all three budgets and still reported training FLOP savings.
Handle the KV cache
Cap cache slots per token, use smaller shared attention heads, or keep loop 1's cache plus short windows for later loops.
Talk about latency
Layer runs go in order, so use early stopping or fewer loops for easy tokens.
State the risk
Serving support is thin, so pilot it behind a flag before real users see it.
Questions people ask
- Is a looped transformer the same as a recurrent neural network?
- Not quite. Both reuse the same weights again and again. A classic recurrent network loops across the tokens of a sentence, one after another. A looped transformer loops in depth instead, running the same layers again on the same tokens.
- Do looped transformers use less GPU memory?
- They use less memory for weights, because the shared block is stored once. Total memory may barely fall. A simple looped model saves keys and values on every loop, so the KV cache stays large unless it is capped. In our toy sizing for 40 students, the cache was about 26 times the weights.
- Are looped transformers faster than normal transformers?
- Not by default. At the same depth, a looped model does about the same sequential work as a stacked one. Speed comes from running fewer loops when you can. A 2026 decoding paper reports that, with its decoding method, half the loops matched full-depth accuracy on a multiple-choice average. Early stopping lets easy tokens finish sooner.
- How many times should the shared block loop?
- There is no single answer. The compute-matched paper runs its middle layers twice. The recurrent-depth paper trained with a random loop count averaging 32 and tested several counts. The serving code we read defaults to 2 loops. Choose your count by testing quality and latency on your own tasks.
- Can I serve a looped model with my current inference server?
- Check first. As of 19 October 2026, at least two widely used open-source serving frameworks support one looped coding model, with a special cache for later loops. The models from the three 2026 papers were not on their supported lists. Your server must run the block several times per token and keep a correct cache for each loop.
- What is the difference between parameters and compute?
- Parameters are what the model stores, and compute is the work it does for each token. Parameters decide how much GPU memory the weights need. Compute decides GPU time per token. A looped model stores a block once but runs it many times, so it has few parameters and normal compute.
- Should beginners learn about looped transformers now?
- Learn the idea, not every detail. The core lesson is that parameters, compute per token and KV cache can move separately. That helps you reason about any model design. The specific recipes in the 2026 papers are recent research and may change.
Sources and further reading
- Wang et al. (2026), scaling laws for compute-matched looped mixture-of-experts transformers, arXiv 2609.01343
- Liu et al. (2026), training-free contrastive decoding for looped transformers, arXiv 2610.02185
- Qian et al. (2026), looping in vision-language models, arXiv 2609.38426
- Geiping et al. (2025), Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approach, arXiv 2502.05171
- Dehghani et al. (2018), a transformer that reuses one shared layer over recurrent steps, arXiv 1807.03819