GLM-5.4 converts a pre-trained GLM-5 base into a Loop Transformer: 28 middle layers re-execute for 2 weight-shared iterations, buying 2T–3T-class reasoning at a fixed parameter count. Three fixes — gated residual writes, hybrid KV sharing, sparse-index reuse — make the extra loop nearly free at 750B/1M context.
Z.ai separates two capability axes: memory-intensive tasks reward more parameters, while reasoning-intensive tasks reward more effective compute. The target workloads — large-scale software engineering, cybersecurity, 3D modeling, physical control — are ultra-long-chain reasoning: they demand following multi-step causal chains while preserving global logical consistency. Stacking parameters and memorizing more data does not close this gap, because the bottleneck is sequential compute depth, not stored knowledge. The naive remedy (train a 2T–3T dense/MoE model) is prohibitively expensive to train and serve.
Add depth without adding parameters by looping a weight-tied block. Formally, let the shared loop block be a function $f_\theta$ applied to the residual-stream hidden state $h$. A standard stack applies $f$ once; the Loop Transformer applies the same $f_\theta$ for $T$ iterations, refining $h$ in place:
$$h^{(t)} = h^{(t-1)} + g^{(t)} \odot f_\theta\!\left(h^{(t-1)}\right), \quad t = 1 \dots T$$
with $T=2$ and $g^{(t)}$ a learned per-token gate for iteration $t$. The decisive engineering choice is not to train looped-from-scratch (which underperforms an unshared model at equal pre-training compute) but to adapt an already pre-trained base into looped form via continued training, lifting the intelligence ceiling for ~10% extra compute.
The 核心技术壁垒 (single hardest-to-replicate insight): making the loop free to serve. A naive loop multiplies both KV-cache memory and sparse-attention indexing by $T$. GLM-5.4 collapses that overhead — the second loop reuses the first loop's sparse KV selection plus one sliding window of fresh KV, and reuses the first loop's attention indices verbatim — so an added loop costs one sliding window, not a full context cache. This co-design is what lets looping survive at 750B parameters and 1M context, where the baseline cost would otherwise roughly double.
No published architecture figure is embeddable; the mechanism is redrawn below.
Loop placement in the stack — the base model keeps its early and late layers single-pass; only a 28-layer middle block is wrapped in a 2-iteration loop:
Per-iteration gated residual write — each iteration's candidate update is scaled by an independent per-token gate before it rejoins the residual stream, keeping activation norms in-distribution for downstream layers:
The learned gate behavior is the subtle part: iteration 1 writes conservatively (small gate) to stabilize scale while assembling global context; iteration 2 opens the gates for a full refinement write; and on harder tokens iteration 1 writes more aggressively, so difficult predictions extract more from the second pass.
Hybrid KV cache — the second loop attends to two overlapping KV streams: the sparse KV selected in pass 1 (shared, global) plus its own sliding-window KV (local, fresh):
无形式化作者证明 — 仅实证. The blog states no convergence theorem, variance bound, or formal proposition; all support is empirical (iso-parameter ablation + deployment numbers). The six verification checks are therefore applied to the mechanism claims and the equation's physical meaning rather than to a theorem.
Notation
| Symbol | Meaning |
|---|---|
| $f_\theta$ | the weight-tied loop block (28 layers, shared across iterations) |
| $h^{(t)}$ | residual-stream hidden state after loop iteration $t$ |
| $g^{(t)}$ | per-token, per-iteration gate controlling write magnitude |
| $T$ | number of loop iterations ($T=2$ for GLM-5.4) |
| $\odot$ | element-wise (per-token) scaling |
方程物理意义. $h^{(t)} = h^{(t-1)} + g^{(t)} \odot f_\theta(h^{(t-1)})$ is a gated residual recurrence: re-applying one parameter set deepens the effective computation graph without new weights, and the gate makes each write a controllable step so re-entry does not push activations out of the distribution the downstream single-pass layers expect.
Six checks
A desirable missing guarantee: a bound relating loop count $T$ to effective-depth gain, or a stability condition on $g^{(t)}$ that provably keeps $\lVert h^{(t)} \rVert$ bounded.
No result figures were extractable; the load-bearing numbers are tabulated from the post.
Iso-parameter controlled ablation (the central evidence). The comparison fixes parameter count and architecture, varying only looped vs. unshared, at the 30B scale that mirrors the 750B base:
| Factor | Setting |
|---|---|
| Base scale | 30B (same architecture family as 750B base) |
| Parameter count | identical across arms |
| Extra training compute | ~10% |
| Eval protocol | after 200K long-context SFT, thinking mode on |
| Outcome | looped arm shows clear gains, largest in math / scientific reasoning / long-context |
This design is what makes the claim credible: holding parameters constant isolates effective compute as the manipulated variable, so the gain cannot be attributed to more memory capacity.
Efficiency table.
| Metric | Value | Note |
|---|---|---|
| Avg. output length | −10% to −14% | GPQA-Diamond, MMLU-Pro, etc.; mostly shorter CoT |
| Throughput (off-peak) | up to 200 tok/s | model ↔ infra co-design |
| Throughput (peak) | 70–80 tok/s | under load |
| Added serving cost vs GLM-5.3 | "well under control" at 1M ctx | from hybrid KV + index reuse |
Scaling-validity ladder. The loop was validated progressively at 1B → 4B → 30B → 750B before the flagship, establishing that the architecture holds across two orders of magnitude of scale rather than at a single lucky operating point.
| # | Step | Supports |
|---|---|---|
| 1 | Target tasks are ultra-long-chain reasoning, bottlenecked by sequential compute depth, not stored knowledge. | motivates depth over width |
| 2 | More effective compute = more depth; weight-tying adds depth at zero parameter cost. | justifies the loop |
| 3 | Looped-from-scratch underperforms unshared at equal pre-train compute ⇒ instead adapt a pre-trained base via continued training. | justifies the continued-training recipe |
| 4 | Re-entering a middle block ungated blows up activation norms ⇒ add per-token per-iteration gates for proportional writes. | justifies gated progressive updates |
| 5 | Naive loop multiplies KV and indexing by $T$ ⇒ share loop-1 sparse KV + add one sliding window, and reuse loop-1 indices. | justifies hybrid KV + index reuse |
| 6 | Iso-parameter 30B ablation shows accuracy gains + 10–14% shorter outputs for ~10% extra compute. | validates the whole construction empirically |
| 7 | Memory/index savings + fused kernels keep 750B/1M-context serving at 70–200 tok/s. | shows the design is deployable, not just accurate |
[实现未公开] — GLM-5.4 is a product blog; no code, config, or file-level artifacts are released. Open weights are "planned after safety hardening" and the API is "coming soon," so there is nothing to cite at file:line granularity yet.
核心技术壁垒 (dedicated). The hardest piece to reproduce is not the loop itself — Universal Transformer (2018) and recent recurrent-depth work already established weight-shared depth — but making an extra loop serving-free at 750B and 1M context. That requires the full stack to compose: (a) sparse attention in the base model, (b) cross-loop sparse-KV sharing so the second pass does not re-cache context, (c) verbatim reuse of the first loop's attention indices so indexing cost is zero, and (d) fused kernels that remove the fragmented intermediate reads/writes a loop would otherwise amplify. Any team can tie weights; few can make the second pass cost one sliding window instead of a second full forward.
关键实现细节 (easy-to-miss tricks).