Model comparison · 2026-11-24
What is a Loop Transformer? How GLM-5.4 reuses its layers
A Loop Transformer runs the same layers more than once. Z.AI's three changes in GLM-5.4, its 30B ablation, and GLM-5.3 on LLMTR.
Short answer: a Loop Transformer runs the same layers more than once
LLMTR is a gateway that gives access to AI models from different providers through an OpenAI-compatible API. A Loop Transformer (looped Transformer) is a Transformer that runs a group of weight-shared layers for several iterations in one forward pass: each iteration refines the hidden states produced by the previous one. The network gets deeper without adding parameters. According to Z.AI's guide, GLM-5.4 runs 28 layers of the GLM-5 base model for two iterations.
As of 24 November 2026 Z.AI has not released GLM-5.4 on its Model API; according to Z.AI's announcement, the model is available in the GLM Coding Plan, ZCode and Z.ai Chat. GLM-5.3, which Z.AI has released on the Model API, is called at https://llmtr.com/v1/chat/completions with the id zai/glm-5.3 and the API key of your llmtr.com account; under the agreement between LLMTR and Z.AI, its price is 10% below the Z.AI list price.
How a looped Transformer differs from a standard one
In a standard Transformer each layer runs once per forward pass; depth means the number of layers, and every layer has its own weights. In a looped Transformer a group of weight-shared layers runs several times in a row. The model does more computation with the same parameters: more iterations cost more compute, but the memory taken by the weights does not grow.
The idea is not new. The Universal Transformers paper, published in 2018, combined the parallel structure of the Transformer with the recurrent structure of RNNs and applied the same transformation repeatedly across depth. Two papers published in 2025 described a model that iterates a recurrent block to any depth at test time, and Ouro, a family of pre-trained looped language models. According to Z.AI's guide, looped models trained from scratch still lag behind unshared models under the same pre-training compute budget. That is why Z.AI did not train GLM-5.4 from scratch: it adapted the pre-trained GLM-5 base into a looped model through continued training.
| Topic | Standard Transformer | Looped Transformer | GLM-5.4 (Z.AI) |
|---|---|---|---|
| Layers per forward pass | Each runs once | Shared group runs several iterations | 28 layers, two iterations |
| Parameter count | Grows as layers are added | Does not grow with iterations | 750-billion scale; the loop adds no parameters |
| Training | Pre-training | Trained from scratch in the three papers cited | Continued training from the pre-trained GLM-5 base |
- Dehghani et al., Universal Transformers (arXiv 1807.03819) · 2018-07-10
- Geiping et al., Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approach (arXiv 2502.05171) · 2025-02-07
- Zhu et al., Scaling Latent Reasoning via Looped Language Models (arXiv 2510.25741) · 2025-10-29
- Z.AI, GLM-5.4 guide · 2026-11-24
What did Z.AI change in GLM-5.4?
Z.AI describes two problems with turning middle layers into a multi-pass loop. If the hidden states are overwritten directly in every iteration, activation norms grow from one iteration to the next and the downstream layers receive inputs at a scale they were not trained on. Keeping a full KV cache for every iteration also multiplies memory by the loop count. Z.AI writes that it made three changes to balance performance gains with deployment costs at the 750B scale; the architecture was tested in turn on 1B, 4B, 30B and 750B base models.
- Gated progressive updates: for each iteration, a separate per-token gate decides how much of the candidate update is written back into the residual stream. According to Z.AI, after training the first pass builds global context and writes conservatively with small gate values, while the second pass opens the gates and writes full updates; on harder tokens the first pass writes more.
- Hybrid KV cache: the second iteration reuses the sparse KV selected in the first pass and keeps only its own new KV in a sliding window. According to Z.AI, the KV cost of an extra iteration is then one sliding window rather than a full context cache, which keeps the increase in deployment cost over GLM-5.3 limited at 1M context.
- Sparse attention index reuse: the GLM-5 base uses sparse attention. The second iteration uses the attention indices produced by the first iteration's indexer directly and does no extra indexing work. Z.AI writes that this performs nearly the same as recomputing the indices on every pass.
What did Z.AI's 30B experiment show?
Before applying the architecture to the 750B model, Z.AI ran a controlled comparison on a 30B model with the same architecture as the 750B base: the same parameter count, about 10% more total training compute. The evaluation was run after 200K long-context supervised fine-tuning, with thinking mode on. According to the guide, the looped version showed clear gains, and the gains were largest in math, scientific reasoning and long-context tasks.
The second finding is about output length: on most benchmarks such as GPQA-Diamond and MMLU-Pro, average output length dropped by 10% to 14%, mostly from shorter chains of thought. Z.AI reads this as part of the reasoning shifting from explicit output tokens into the implicit depth of the loop. In the same guide Z.AI lists as a limitation that GLM-5.4 tends to get caught in overly long thinking loops, so the shorter outputs in the 30B experiment do not mean shorter answers on every task. Z.AI also adds that this prolonged reflection consistently improves accuracy.
| Topic | What Z.AI writes |
|---|---|
| Parameter count | Same, 30B |
| Total training compute | About 10% more |
| Evaluation | After 200K long-context fine-tuning, thinking mode on |
| Tasks with the largest gains | Math, scientific reasoning, long context |
| Average output length | 10–14% shorter on most benchmarks such as GPQA-Diamond and MMLU-Pro |
What does it mean for an API user?
In reasoning models, reasoning tokens are part of the output: they count against max_tokens and are billed at the output price. If part of the reasoning moves inside the loop, the same task can finish with fewer output tokens; if the model gets stuck in long reasoning, the opposite happens. You can see which holds for your work from the completion_tokens value of the usage field on your own prompts.
Until GLM-5.4 reaches the Model API, you can see on GLM-5.3 how reasoning depth changes output tokens; this shows the token cost of explicit reasoning, not the effect of the loop. The example below sends the same request with reasoning_effort low and high and prints the completion_tokens value and the cost of both responses. Do not set max_tokens low; with a low limit the answer can be cut off while the model is still reasoning.
OpenAI Python SDK example that sends the same request to zai/glm-5.3 with reasoning_effort low and high and prints the completion_tokens value and the cost at the LLMTR price for both responses.
import os
from openai import OpenAI
client = OpenAI(base_url="https://llmtr.com/v1", api_key=os.environ["LLMTR_API_KEY"])
# LLMTR price per 1M tokens for zai/glm-5.3: input, cached input, output.
PRICE = (1.26, 0.234, 3.96)
PROMPT = "A train leaves at 09:40 and arrives at 13:05 after two stops of 7 minutes each. How long is it moving? Show the steps."
for effort in ("low", "high"):
response = client.chat.completions.create(
model="zai/glm-5.3",
messages=[{"role": "user", "content": PROMPT}],
reasoning_effort=effort,
max_tokens=8192,
)
usage = response.usage
details = usage.prompt_tokens_details
cached = (details.cached_tokens or 0) if details else 0
cost = ((usage.prompt_tokens - cached) * PRICE[0] + cached * PRICE[1] + usage.completion_tokens * PRICE[2]) / 1_000_000
print(effort, "completion_tokens:", usage.completion_tokens, "cost: $%.6f" % cost)
Summary for your team
Recommendation: until the GLM-5.4 Model API opens, use GLM-5.3 through llmtr.com, with the id zai/glm-5.3 at https://llmtr.com/v1/chat/completions. As of 24 November 2026 Z.AI has not released GLM-5.4 on its Model API; according to Z.AI, GLM-5.4 is a Loop Transformer that runs 28 layers of the GLM-5 base twice. Under the agreement between LLMTR and Z.AI, GLM-5.3 is 10% below the Z.AI list price: $1.26 input and $3.96 output per 1M tokens.
The reasons: one LLMTR API key and a loaded balance are enough, and no separate Z.AI account is needed. On LLMTR the GLM chat models are called at the same endpoint; when GLM-5.4 is added to the catalog, you change the model id and check the reasoning_effort levels on its model page. Usage appears on the Dashboard > Usage page.
Seeing how reasoning depth affects output tokens on GLM-5.3
Create an API key, send the same request to zai/glm-5.3 with reasoning_effort low and high, and compare the completion_tokens value of the two responses.
- Key. Create an API key on llmtr.com, load a balance under Dashboard > Billing and put the key in the LLMTR_API_KEY environment variable.
- Two requests. In the OpenAI Python SDK, set base_url to https://llmtr.com/v1 and model to zai/glm-5.3, and send the same request with reasoning_effort low and high; do not set max_tokens low.
- Compare. Compare the completion_tokens value and the cost in the usage field of the two responses, and follow your spend on the Dashboard > Usage page.
Frequently asked questions
What is a Loop Transformer?
A Transformer that runs a group of weight-shared layers for several iterations in one forward pass. Each iteration refines the hidden states of the previous one; the network gets deeper without adding parameters.
Does the loop add parameters?
No, the iterations use the same weights. What grows is the computation per token and, unless something is done about it, the KV cache. Z.AI writes that in GLM-5.4 the second iteration reuses the first iteration's sparse KV and keeps only one sliding window of extra KV.
Does the loop make the model slower?
Every iteration is extra computation. Z.AI writes that it offsets this with its KV and index design and by fusing core kernels, and that GLM-5.4 reaches up to 200 tokens per second off-peak and 70–80 tokens per second at peak load. These figures are for Z.AI's own service.
Where can I use GLM-5.4?
As of 24 November 2026, in the coding tools a GLM Coding Plan subscription supports, and in Z.AI's ZCode and Z.ai Chat. Z.AI writes that the Model API will be made available after the security assessment; GLM-5.4 is planned to be added to the LLMTR catalog when the API opens. Until then you can use GLM-5.3 with the id zai/glm-5.3.