中
◀ Back to feed
Z.ai Blog

GLM-5.4: Toward Generalized Coding with Our First Loop Transformer

Published 2026-11-23 Collected 2026-11-23 20:00 AI news #ai
Full text

2026-11-23 · Research

Over the past three months, we have aggressively scaled both loop depth and model size in parallel. The first surprise came from the Loop Transformer architecture itself. By executing a shared block of layers across multiple iterations, the model can reason more deeply without adding parameters, effectively matching the performance of much larger models.

  • GLM-5.4 is our first flagship model built on the Loop Transformer architecture, reaching intelligence levels comparable to 2T-3T parameter models.
  • GLM-5.4 marks the start of Generalized Coding, where code becomes the foundation for solving a much wider range of tasks and unlocking new capabilities.

The model still has some limitations. Most notably, it tends to get caught in overly long "marathon thinking" loops, though this prolonged reflection and self-correction does consistently improve accuracy beyond its parameter count.

The Loop Architecture

As we noted in our 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. Stacking parameters and memorizing data cannot solve this.

From Pre-Trained Base to Loop Transformer

In a standard Transformer, each layer runs once per forward pass. In a Loop Transformer, a group of weight-shared layers runs for multiple iterations, refining the hidden states from the previous pass. This gives us a deeper network without increasing the parameter count.

The idea is not new. The 2018 Universal Transformer proposed weight-shared depth, and recent work on recurrent depth and looped language models has shown gains at small scales. However, while weight sharing improves parameter efficiency, looped models trained from scratch still lag behind unshared models under the same pre-training compute budget. Instead of pre-training from scratch, we adapted an already pre-trained base model into a Loop Transformer through continued training. This lets us raise the intelligence ceiling with a relatively small compute overhead.

Architectural Modifications at 750B Scale

GLM-5.4 loops 28 layers of the GLM-5 base model for two iterations. To balance performance gains with deployment costs at the 750B scale, we made three changes after extensive experimentation:

Gated Progressive Updates

When converting middle layers of an existing model into a multi-pass loop, directly overwriting hidden states causes activation norms to blow up across iterations. Downstream layers then receive representations outside their expected scale and distribution.

GLM-5.4 adds independent per-token gates for each iteration to 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 with small gate values to keep scales stable. The second pass reuses this 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.

Hybrid KV Cache (Global Sharing + Independent Sliding Window)

A naive implementation keeps a full KV cache for every loop iteration, multiplying memory usage with the loop count. Instead, we build on cross-loop KV sharing by supplementing 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, allowing the model to attend to both the first-pass context representations and the updated local representations from the second pass.

As a result, an extra loop only costs one sliding window of KV cache rather than a full context cache. At 1M context lengths, this keeps GLM-5.4’s deployment cost increase over GLM-5.3 well under control.

Sparse Attention Index Reuse

GLM-5.4’s base model uses sparse attention. The second loop directly reuses the attention indices generated by the first loop's indexer, adding zero indexing overhead. Our experiments show this performs nearly identically to recomputing indices on every pass.

Scaling Correctness & Controlled Iso-Parameter Ablations

Looping is also a strict test of Scaling Correctness: any architectural change must still work at scale. Before committing our flagship model to it, we validated the Loop architecture progressively across 1B, 4B, 30B, and 750B base models.

On a 30B model with the exact same architecture as our 750B base, we ran a controlled iso-parameter comparison. With identical parameter counts and only ~10% more total training compute, the looped version showed clear gains:

(Evaluated on the 30B model after 200K long-context SFT, with thinking mode enabled.)

(Note: the comparison chart is an image in the original post.)

Two findings stand out:

  • Longer reasoning chains benefit more. The largest gains show up in math, scientific reasoning, and long-context tasks, which are core to Generalized Coding.
  • Fewer tokens spent on thinking. Across most benchmarks like GPQA-Diamond and MMLU-Pro, average output length drops by 10–14%, mostly from shorter chains of thought. In effect, part of the reasoning shifts from explicit output tokens into the implicit depth of the loop.

Inference Efficiency

GLM-5.4 reaches up to 200 tokens/s during off-peak hours and maintains 70–80 tokens/s at peak load. Achieving this throughput with a multi-pass Loop architecture required close co-design between the model and our inference infrastructure. Alongside the memory and retrieval savings from our KV cache and sparse index designs, we fused core kernels at the systems level to cut down intermediate memory reads and writes, eliminating the fragmented overhead amplified by looping.

Generalized Coding

Coding has become the foundation for extending model capabilities. Since going all-in on coding in early 2025, we have unlocked Agentic Engineering, Long-Horizon Tasks, and Cybersecurity. Now we are pushing toward Generalized Coding. It has a higher ceiling and broader impact, and GLM-5.4 is just the starting point.

Driven by improvements in both coding and vision, GLM-5.4 generalizes well beyond traditional software development. It can write code to generate and edit videos, build complete games, and handle 3D modeling and mechanical design:

  • Scaling Coding to Video: Producing "Hello World," GLM-5.4’s self-narrated music video.

  • Scaling Coding to Engineering: Building a 6-axis robotic arm through engineering-grade CAD modeling in FreeCAD.

  • Scaling Coding to Games: Creating a complete game directly, covering character movement, physics, maps, combat systems, and art assets.

  • Scaling Coding to 3D: Generating an interactive 3D macro bird-watching experience from scratch using pure mathematical geometry and custom GLSL shaders.

  • GLM Coding Plan: https://z.ai/subscribe

  • ZCode: https://zcode.z.ai/en

  • Z.ai Chat: https://chat.z.ai

  • API (Coming Soon): https://z.ai/model-api

  • Open Weights: We plan to open-source the model weights responsibly after completing necessary safety hardening.

GLM-5.4 is our first step with looped architectures, and several questions remain open. We are exploring how to achieve adaptive compute so harder tokens dynamically get more iterations, and how the returns of looping behave as both loop count and model size keep growing.

We are not choosing between scaling depth and scaling model size; we are pursuing both. GLM-5.4 validates computational depth, and our next, significantly larger model will carry forward everything we learned here. It will be ready soon.

Source
Title
GLM-5.4: Toward Generalized Coding with Our First Loop Transformer
Author
—
Site
Z.ai Blog
Published
2026-11-23
Collected
2026-11-23 20:00 · 2026-11-23-20-ai.json
Link
https://z.ai/blog/glm-5.4
Open original ↗

Reposted. Will be removed on request. All rights belong to the original author.

More from this batch

20:00batch · 2026-11-2312 items
>

Perplexity and Intelligence

OpenAI 首次公开各代模型在内部代码留出集上的对数困惑度:GPT-3.5 约 0.99、GPT-4 约 0.91,现在已低于 0.8;文中说升级到约 0.76 的模型后,它开始在数学开放问题上出成果,并外推最早 2027 年可能出现预训练算法进步的“雪崩”。他提议各实验室以困…

OpenAI
>

CrowdStrike bets on network security with $43.9 billion Zscaler deal

每股 Zscaler 换 1.135 股 CrowdStrike,相当于 260.41 美元、溢价 34%;交易完成后 CrowdStrike 股东持有约 84%,预计在 CrowdStrike 2028 财年下半年完成。报道把背景归到 AI 让攻击者更快找到并利用漏洞、企业更想…

CNBC
>

Building the digital front door

官方博客说由 Greenoaks 和 Lightspeed 领投,此前所有领投方都在加码;公司称成立两年半多 ARR 超过 4 亿美元,按“结果”收费(解决一个问题、发放一笔贷款等)而不是按 token。客户名单里有 BNY、JPMorganChase、Wells Fargo、H…

Sierra
>

蚂蚁集团领投中国具身智能公司 Simplexity Robotics 1 亿美元 Pre-A,估值 16 亿美元(11 月 22 日)

Bloomberg 报道,阿里、腾讯等跟投。说明国内大厂继续押注人形机器人和“物理 AI”赛道。

Bloomberg
>

美国州长协会提议分工监管 AI:联邦审查前沿模型,州政府负责消费者保护(11 月 22 日)

两党州长组成的全国州长协会(NGA)呼吁华盛顿为最强大的 AI 系统制定规则,同时不要剥夺各州保护消费者的权力。这是联邦与州“谁来管 AI”之争的新提案。

Bloomberg
>

《纽约时报》:中国军民研究担心美国 AI 会把核决策时间压缩到 90 秒(11 月 23 日)

报道梳理中国研究文献中的一种担忧:美国用 AI 加快探测与决策后,可能削弱中国的核威慑。是 AI 与核安全议题的重要背景读物。

New York Times
>

《华盛顿邮报》:黄仁勋与特朗普关系密切,曾亲自游说争取对华 AI 芯片销售(11 月 23 日)

报道称黄仁勋曾把中国称为每年 500 亿美元的市场,并多次打电话游说。与此同时《纽约时报》报道财长 Bessent 表示,黄仁勋能否回归应取决于对英伟达对华芯片销售的调查结果。英伟达风波仍在发酵。

Washington Post
>

Bloomberg:美国新芯片出口规则冲击东南亚数据中心热潮(11 月 22 日)

报道称新规让东南亚一些数据中心项目面临烂尾风险,新云厂商被迫替换中国客户。对在东南亚找算力的中国团队影响直接。

Bloomberg
>

Director of National Intelligence Jay Clayton warns Americans of 'bumps in the road' after tech outages

过去一周美国出现 FAA 全国停飞、Outlook 多日故障和摩根大通银行故障。Jay Clayton 在 CNN 说要为系统升级和网络安全投资做准备;官方称 FAA 停飞源于路由器升级、并非网络攻击。微软总裁 Brad Smith 说 AI 让找漏洞更容易,未来几个月还会有故障…

CNBC
>

路透:Anthropic IPO 流程很不寻常,限制承销团队人数、用可追踪访问记录的文件平台(11 月 22 日)

报道称因担心泄密,Anthropic 把部分投行团队限制在 4 人,并要求半年内不得为竞争对手提供咨询,一些银行家不满。

Reuters
>

伦敦国防仿真软件公司 Agon 融资 7000 万美元,估值 4.5 亿美元(11 月 23 日)

Northzone 领投;这家公司今年早些时候刚带着 3000 万美元走出隐身。国防 AI 仿真继续吸金。

Bloomberg
>

黎曼猜想 Lean 证明遭质疑:Nielsen 论文指出关键几何谓词被定义成“恒为真”,社区仍在核对依赖链(11 月 20–22 日)

Jenny Lorraine Nielsen 在 PhilArchive 发布未经同行评审的论文,承认证明项能通过 Mathlib 的 RiemannHypothesis 类型检查,但称路径上用的假设包由空洞定义构成,例如 anyGeometry := fun _ _ _ => …

PhilArchive / DEV