DEV Community

Cover image for Loop Transformers: Thinking Deeper Without Getting Bigger (GLM-5.4 & Inkling 2 Mini)
amananandrai
amananandrai

Posted on AI-assisted

Loop Transformers: Thinking Deeper Without Getting Bigger (GLM-5.4 & Inkling 2 Mini)

A loop transformer runs the same block of layers more than once for every token. That lets a model think deeper without storing more weights.

The idea is old, but November 2026 is when it went mainstream. Thinking Machines shipped Inkling 2 Mini on November 20, and Z.ai released GLM-5.4, its first flagship built on a Loop Transformer, on November 23.

In this post:

  1. How a normal transformer works
  2. The loop transformer architecture
  3. Normal vs loop, side by side
  4. Advantages and trade-offs
  5. How GLM-5.4 uses looping
  6. How Inkling 2 Mini uses looping

A note on naming: the GLM model that loops is GLM-5.4. Earlier GLM models, including the GLM-4 family, are standard transformers.


1. How a normal transformer works

A standard transformer is a stack of L distinct layers, each with its own weights. Each token's hidden state passes through every layer exactly once.

Each layer has two parts:

  • an attention sublayer that mixes information across tokens
  • a feed-forward (or Mixture-of-Experts) sublayer that transforms each token

Residual connections add each layer's output back onto a running hidden state.

This design ties three things together:

  • Depth (how many transformations a token gets) equals the number of layers.
  • Parameters grow with every layer you add.
  • Memory traffic grows too, because every layer's weights are read from memory for each generated token.

Want more reasoning depth? Add layers, and you get a bigger, more expensive model. A loop transformer breaks that link.

2. The loop transformer architecture

Standard vs loop transformer

A loop transformer reuses a shared block of layers across depth, so effective compute is no longer tied to parameter count. Most modern designs split the model into three parts, prelude → recur → coda:

  1. Prelude: a few unshared layers that run once. They turn token embeddings into the model's internal representation.
  2. Recurrent block: a group of layers that runs r times with the same weights, refining the hidden state on each pass.
  3. Coda: a few unshared layers that run once at the end and predict the next token.

Effective depth becomes:

ℓeff=ℓprelude+r⋅ℓrecur+ℓcoda \ell_{\text{eff}} = \ell_{\text{prelude}} + r \cdot \ell_{\text{recur}} + \ell_{\text{coda}}

So a model with 24 stored layers can behave like a 48-layer model if its middle 12 layers loop three times.

Making the loop stable

Simply repeating a block doesn't work well. A naive looped model underperforms a standard model of the same depth, because a block applied the same way every pass can't change its behavior from one pass to the next. Repeated non-linear passes can also make the residual state explode and cause loss spikes.

Gates keep the loop stable

Modern loop transformers add three fixes:

  • Input injection. Each pass sees the prelude's output again, so the model never drifts far from the input.
  • Gates. A learned, often per-token gate decides how much of each pass's output to blend into the running state. Gates start near closed, so looping is phased in during training.
  • Cache sharing. Later passes reuse attention key/value (KV) data from earlier passes, so looping doesn't multiply KV-cache memory.

A short history

  • Universal Transformer (2019): weight sharing plus Adaptive Computation Time for input-dependent halting.
  • ALBERT (2020): cross-layer parameter sharing. Deep Equilibrium Models: implicit depth.
  • Latent thoughts: later work showed looped models can reason beyond their apparent depth.
  • Recurrent-depth models: scale test-time compute by looping more at inference.
  • Ouro LoopLM (2025): a learned early exit, so easy inputs use fewer loops.
  • GLM-5.4 and Inkling 2 Mini (Nov 2026): the first big production releases.

3. Normal vs loop transformer at a glance

Aspect Standard transformer Loop transformer
Layer weights Unique per layer Middle block shared across passes
Passes per token Each layer once Recurrent block runs r times
Effective depth = number of layers Prelude + r × block + coda
Parameters for more depth Grow linearly Unchanged
Weight memory read per token Every layer, once Same block reused, so less traffic per unit of compute
Compute per token Fixed by size Higher (block repeats)
Vary depth at inference No Yes, in variable-loop models
Knowledge capacity Scales with parameters Also scales with parameters; looping adds no facts
Training stability Well understood Needs gates and input injection

4. Advantages of loop transformers

The main win is more reasoning per byte of weights.

  1. Parameter efficiency. Depth comes from reuse, not new weights. The Hyperloop Transformer paper reports beating standard transformers of the same depth with about 50% fewer parameters.
  2. Better multi-step reasoning. Gains are largest on math and science, smallest on knowledge recall.
  3. Thinking more, writing less. Extra passes are "latent" reasoning, so the model needs fewer chain-of-thought tokens.
  4. Lower memory bandwidth. Token generation is usually limited by how fast weights stream from memory. Reusing one block means fewer distinct weights to read, which suits laptops and bandwidth-limited chips like NVIDIA's DGX Spark.
  5. Adjustable compute. Variable-loop models can run more passes on hard inputs, and some keep improving past the loop count they were trained with.
  6. Smaller checkpoints. Inkling 2 Mini is about 20GB.

The trade-offs

  • More compute per token. Looping saves parameters, not FLOPs.
  • No extra knowledge. Facts scale with total parameters. Looping didn't improve Inkling's knowledge scores.
  • Harder training. Z.ai says looped models trained from scratch still lag unshared models at the same pre-training budget.
  • Less visible reasoning. If more thinking happens inside the loop, the written chain of thought may not show everything the model did.

5. How GLM-5.4 uses looping

GLM-5.4 loops 28 middle layers of its roughly 750B-parameter GLM-5 base twice per token. Z.ai claims intelligence comparable to 2T–3T parameter models, but hasn't published flagship benchmark scores to back that up yet.

Inside GLM-5.4

Part Layers Runs
Prelude (+ features from a 24-layer vision encoder) 1–26 Once
Loop 27–54 (28 layers) Twice, shared weights
Coda 55–78 Once

That's 78 stored layers doing 106 layer passes per token.

Key design choices

  • Converted, not trained from scratch. Z.ai took the already-trained GLM-5 base and turned it into a loop transformer through continued training.
  • Per-token gates. Each pass blends in as x1 = x0 + b1 * (h1 - x0), then x2 = x1 + b2 * (h2 - x1). Pass 1 tends to use small gates to build context; pass 2 opens them.
  • Cross-loop KV sharing. For long context, pass 2 reuses the sparse KV entries picked in pass 1 and doesn't rerun the indexer. It keeps only its own 128-token sliding-window cache, so the extra loop costs a small window of memory, not a second full cache.

Z.ai's controlled 30B experiment

GLM 30B results

Z.ai trained a 30B model with the same architecture, looped and unlooped, with equal parameters. Looping cost about 10% more training compute. Output length also dropped on every benchmark, by up to 14.9% on MMLU-Pro.

Caveats: Z.ai admits the model can fall into overly long "marathon thinking," weights aren't released yet, and all figures are vendor-reported.

6. How Inkling 2 Mini uses looping

Inkling 2 Mini, Thinking Machines' smallest model, runs its middle 12 layers three times per token, turning 24 stored layers into 48 layer passes.

Inside Inkling 2 Mini

It's an open-weights (Apache 2.0) Mixture-of-Experts model: 26.4B total, 3.4B active, and 5.4B weight activations per token once looping is counted. It fits on a 32GB Mac.

Why loop the middle? Looping the middle 12 layers beat looping the last 12 on 27 of 28 evaluations. Middle layers carry more abstract reasoning; outer layers translate between embeddings and internal representations.

Key design choices

  • Attention residuals. Each layer learns its own mix of earlier block outputs instead of summing everything into one running total.
  • Fresh start plus a message. Every pass starts from the prelude's output. Passes 2 and 3 also get a "message" from the previous pass.
  • A gate that opens slowly. The gate starts fully closed, so each loop first behaves like a non-looped model, then opens during training.
  • Cheap at inference. A non-looped model needed 7.5% less training compute but 140% more inference compute to match the looped model's loss on 512k-token agentic traces.

Training. Expert layers were trained in NVFP4 from pretraining through RL, so the model ships at its training precision. Training started with 384 experts. Two-thirds were pruned partway through training, then about 1T tokens of distillation healed the model, followed by SFT and 2.2T tokens of RL. Reported scores include 79.2% on SWE-bench Verified and 20.1 on the Artificial Analysis Intelligence Index.

What looping did to reasoning. Thinking Machines also released a variable-loop research model trained with 1–5 passes:

  • No-CoT time horizon rose from 16 s at 1 pass to 37 s at 3.
  • On a serial-reasoning task, accuracy kept climbing out to 10 passes, twice what it was trained with.
  • Mean reasoning tokens on GPQA Diamond fell from 3,703 at 1 pass to 1,661 at 5, with fewer "wait" and "actually" backtracks.

The shipping Inkling 2 Mini uses a fixed three loops. You can already run it locally:

Takeaways

Looping trades parameters for passes: same weights, more thinking. Both models loop their middle layers, wrap the loop in learned gates, and see their biggest gains on reasoning, not knowledge.

GLM-5.4 Inkling 2 Mini
Size ~750B 26.4B (3.4B active)
Loop 28 layers × 2 12 layers × 3
Stored → passes 78 → 106 24 → 48
How it got looped Continued training of GLM-5 Built in during training
Weights Not yet released Open, Apache 2.0

Things to watch: independent GLM-5.4 benchmarks once the weights ship, adaptive loop counts in production models, and how safety teams monitor reasoning that moves out of the written chain of thought into hidden depth.


Sources

Top comments (0)