GLM-5.4: How Z.ai's First Loop Transformer Pushes Coding Beyond Code

On November 23, 2026, Z.ai shipped GLM-5.4, the first model in the GLM flagship line built on a Loop Transformer architecture. The company reports that the model reaches intelligence levels comparable to 2T to 3T parameter models despite running on a roughly 750B parameter base, and it frames the release as the start of something broader than software generation: Generalized Coding, where code becomes the foundation for solving tasks ranging from video production to mechanical design.
The interesting part of this launch is not the headline claim. It is the engineering behind it. Loop architectures have been studied since at least the 2018 Universal Transformer paper, but they have consistently underperformed dense models when trained from scratch under the same pre-training compute budget. GLM-5.4 is the first time this idea has been carried to flagship scale in the GLM family, and the specific problems Z.ai had to solve to make it work at 750B parameters explain a lot about where LLM architecture is heading.
Why Depth, Not Just Parameters
Z.ai carried forward a distinction from its GLM-5.3 technical blog: memory-intensive tasks benefit from more parameters, while reasoning-intensive tasks benefit from more effective compute. Large-scale software engineering, cybersecurity, 3D modeling, and physical control are all ultra-long-chain reasoning tasks. The model must follow multi-step causal chains while maintaining global logical consistency across the whole solution. Stacking more parameters and memorizing more data does not solve that.
A standard Transformer couples depth and parameter count tightly. If you want 56 layers of computation, you store and train 56 distinct layers, each visited exactly once per forward pass. A Loop Transformer breaks that coupling. A group of weight-shared layers runs for multiple iterations, with each pass refining the hidden state left behind by the previous one. Compute scales with the loop count; the parameter count does not.
This is a form of depth-wise weight tying. With L distinct blocks executed for T passes, the model performs L times T block applications while storing only L blocks. The idea has a long lineage: Universal Transformers combined recurrence over depth with adaptive halting in 2018, ALBERT explored cross-layer parameter sharing, and a series of 2025 and 2026 papers on recurrent depth and looped language models showed gains at smaller scales. Some of that work found that a k-layer model looped L times can approach the reasoning performance of a kL-layer non-looped model, and that deeper compositions learned during limited training depth can be reached by scaling inference-time recurrence.
The catch has always been training. Under equal pre-training compute, multiplying parameter count by N has historically beaten looping N times, and looped models trained from scratch lagged their unshared counterparts. Z.ai's answer was not to pre-train a looped model from scratch but to adapt an already pre-trained base model into a Loop Transformer through continued training. That conversion raises the intelligence ceiling with a relatively small compute overhead, sidestepping the from-scratch disadvantage entirely.
GLM-5.4 loops 28 layers of the GLM-5 base model for two iterations, roughly doubling effective depth while leaving that block's parameter count unchanged.

Three Fixes That Make Looping Survivable at 750B Scale
Naively looping a large pre-trained model breaks things in predictable ways. Z.ai made three architectural changes after extensive experimentation, each targeting a different failure mode of repeated execution.
Gated Progressive Updates
The first problem shows up the moment you convert middle layers of an existing model into a multi-pass loop. Directly overwriting hidden states across iterations causes activation norms to blow up, and downstream layers then receive representations outside the scale and distribution they were trained to expect.
GLM-5.4 adds independent per-token gates for each iteration, which proportionally write candidate updates back into the residual stream. After training, these gates develop a clear division of labor. The first pass builds global context and writes conservatively, keeping scales stable with small gate values. The second pass reuses that state to refine the output, opening the gates to write full updates.
The gates also adjust step size dynamically based on token difficulty. On harder tokens, the first pass writes more aggressively, so complex predictions benefit more from iterative refinement. This is a small mechanism with a large consequence: the model effectively learns how much extra computation each position deserves, encoded directly in the gating behavior.
Hybrid KV Cache
The second problem is memory. A naive implementation keeps a full KV cache for every loop iteration, multiplying memory usage with the loop count. For a flagship served at million-token context lengths, that would be unacceptable.
Instead, GLM-5.4 builds on cross-loop KV sharing and supplements it with a local sliding window for the new pass. The second loop reuses the sparse KV selected in the first pass while retaining its own newly generated KV within the sliding window. These two KV streams can overlap at the same positions, so the model can attend to both the first-pass context representations and the updated local representations from the second pass.
The result is that an extra loop costs one sliding window of KV cache rather than a full context cache. Z.ai states that this keeps GLM-5.4's deployment cost increase over GLM-5.3 well under control at 1M context lengths, which is the difference between an architecture that works in a lab and one that can be served to subscribers.
Sparse Attention Index Reuse
The base model uses sparse attention, and normally each attention computation would need its own index selection pass. GLM-5.4's second loop directly reuses the attention indices generated by the first loop's indexer, adding zero indexing overhead. Experiments showed this performs nearly identically to recomputing indices on every pass, which means the second pass gets sparse attention essentially for free.
Validating Scaling Correctness Before the Flagship
Looping is also a strict test of what Z.ai calls Scaling Correctness: any architectural change must still work as models get bigger, not just in small proof-of-concept runs. Before committing the flagship to the design, the team validated the Loop architecture progressively across 1B, 4B, 30B, and 750B base models.
The most informative evidence comes from a controlled iso-parameter comparison on a 30B model with the exact same architecture as the 750B base. With identical parameter counts and only about 10% more total training compute, the looped version showed clear gains. The results were evaluated after 200K long-context supervised fine-tuning, with thinking mode enabled:
| Benchmark | Baseline | + Loop | Gain | Output Length Change |
|---|---|---|---|---|
| AIME25 | 19.17 | 30.42 | +11.3 | -635 tokens (-2%) |
| GPQA-Diamond | 47.58 | 56.26 | +8.7 | -2,473 tokens (-11.7%) |
| AA-LCR | 40.33 | 47.67 | +7.3 | -539 tokens (-9.7%) |
| MMLU-Pro | 71.65 | 75.05 | +3.4 | -863 tokens (-14.9%) |
| IFBench | 50.20 | 53.47 | +3.3 | -763 tokens (-13.0%) |
Two findings stand out. First, longer reasoning chains benefit more: the largest gains appear in math, scientific reasoning, and long-context tasks, which are exactly the capabilities Generalized Coding depends on. Second, the looped model spends fewer tokens on thinking. Across most benchmarks, average output length drops by 10 to 14 percent, mostly from shorter chains of thought. In effect, part of the reasoning shifts from explicit output tokens into the implicit depth of the loop.
That second finding deserves emphasis because it reframes what test-time compute means. When a conventional model reasons longer, it does so by generating tokens that a human can read. A looped model can absorb some of that work into additional passes through shared layers, where the intermediate states never surface as text. The accuracy improves, but the auditability changes, and that is a trade-off the field is only beginning to discuss seriously.
Making a Multi-Pass Model Fast
Extra computation per token usually means slower inference, and a flagship that streams at a crawl is a product problem, not just a research curiosity. GLM-5.4 reaches up to 200 tokens per second during off-peak hours and maintains 70 to 80 tokens per second at peak load, according to Z.ai's reported serving speeds.
Achieving that with a multi-pass architecture required close co-design between the model and the inference infrastructure. The hybrid KV cache and sparse index reuse cut memory and retrieval costs at the architecture level. At the systems level, Z.ai fused core kernels to reduce intermediate memory reads and writes, eliminating the fragmented overhead that looping would otherwise amplify. Each pass through the same weights avoids re-fetching different layer weights, which changes the memory access pattern in the model's favor, but only if the kernel execution is tight enough to exploit it.
Generalized Coding: Code as a Universal Substrate
The product framing is as notable as the architecture. Since going all-in on coding in early 2025, Z.ai has progressively unlocked Agentic Engineering, Long-Horizon Tasks, and Cybersecurity. Generalized Coding is the next step, and it applies the same principle outside software development: the model writes code, and that code produces the artifact.
Driven by improvements in both coding and vision, GLM-5.4 generalizes well beyond traditional software development. The launch demonstrations show the pattern:
- Scaling Coding to Video. GLM-5.4 produced a self-narrated music video titled "Hello World." Every visual is drawn in real time with frontend code and zero image assets. The model planned the music by chapter and shot, called a third-party music generation model, and revised its prompts over several rounds.
- Scaling Coding to Engineering. The model built a 6-axis robotic arm through engineering-grade CAD modeling in FreeCAD, then used Blender to design the motion, create the visualization, and synthesize audio.
- Scaling Coding to Games. It created a complete game directly, covering character movement, physics, maps, combat systems, and art assets.
- Scaling Coding to 3D. It generated an interactive 3D macro bird-watching experience from scratch using pure mathematical geometry and custom GLSL shaders, with no external 3D models or texture files.

What unites these demos is that the model never emits a video file, a mesh, or a texture. It emits code, and the code is precise enough to act as the rendering and engineering pipeline. That is why reasoning depth matters so much here: coordinating physics, geometry, and rendering across thousands of generated lines is an ultra-long-chain task in exactly the sense the architecture targets.
The Marathon Thinking Problem
Z.ai is candid that the model has limitations, and the most notable one is behavioral. GLM-5.4 tends to get caught in overly long "marathon thinking" loops. The prolonged reflection and self-correction consistently improves accuracy beyond what the parameter count alone would predict, but it raises latency, and a simple question can pay the same time tax as a hard one.
This connects directly to a known issue in recurrent-depth research sometimes called overthinking: excessive recurrence can degrade predictions, and the right amount of computation depends on the input. Z.ai lists adaptive compute as an open problem, specifically the goal of letting harder tokens dynamically receive more iterations while easier tokens finish early. Fixed two-pass looping is a first step, not the destination.
Availability and the Road Ahead
At launch, GLM-5.4 was available to all GLM Coding Plan users, in ZCode, and in Z.ai Chat, with 50% more weekly quota than GLM-5.3 when the model is explicitly selected. The API was listed as coming soon following a safety evaluation, and Z.ai plans to open-source the model weights after completing necessary safety hardening. That staged pattern echoes the GLM-5.3 launch, where subscribers got access days before pricing, documentation, and weights caught up, so teams building against stable endpoints should treat the current state as a subscription-first preview rather than general availability.
Several research questions remain open. Beyond adaptive compute, Z.ai is watching how the returns of looping behave as both loop count and model size keep growing. The company's stated position is that it is not choosing between scaling depth and scaling model size; it is pursuing both. GLM-5.4 validates computational depth, and Z.ai says its next, significantly larger model will carry forward everything learned here.
Conclusion
GLM-5.4 matters less as a benchmark event and more as a proof of architecture. It shows that weight-shared depth, an idea that has underperformed when trained from scratch, can be grafted onto a large pre-trained model and made to pay off, provided the conversion is engineered carefully. Gated progressive updates keep the residual stream stable across passes, a hybrid KV cache keeps the memory bill close to a single-pass model, and index reuse keeps the second pass nearly free of retrieval overhead. The 30B iso-parameter ablations suggest the gains concentrate exactly where long-chain reasoning lives, and they arrive with shorter explicit chains of thought rather than longer ones.
The deeper story is the decoupling of parameters from compute. If loop depth continues to scale alongside model size, the trade space for building capable models changes: reasoning can be bought with computation rather than storage, and part of a model's thinking can happen in latent space rather than in the token stream. GLM-5.4 is the first flagship-scale data point for that bet, and the marathon thinking problem and the open questions around adaptive depth are honest signals that the bet is still being worked out.