跳到正文
DEV Community· jamilxt·· 50 分鐘前AI 評分67

GLM-5.4 解讀:Z.ai 如何將 750B 規模模型改造成 Loop Transformer

GLM-5.4 Explained: How Z.ai Turned a 750B Model Into a Loop Transformer

AI 導讀

Z.ai 發佈 GLM-5.4,稱它是基於 Loop Transformer 的旗艦模型,並以已訓練的 GLM-5 底模經持續訓練改造而成。模型採 Z.ai 所稱的 750B 規模,78 層中的 28 層會為每個 token 運行兩次;架構以逐 token 閘穩定狀態、混合 KV cache 減少額外快取需求,並在第二輪重用稀疏注意力索引。

正文

Looped transformers had a busy week. Thinking Machines shipped Inkling 2 Mini, a small open-weights model that runs its middle layers three times per token. Now Z.ai has published GLM-5.4, which it calls its "first flagship model built on the Loop Transformer architecture."

The difference is scale. Inkling 2 Mini has 26.4B total parameters. GLM-5.4 is built at what Z.ai calls "the 750B scale." And Z.ai did not train it as a looped model from scratch. It took an existing, already trained base model and converted it.

I have not used GLM-5.4. This breakdown comes from the Z.ai launch post and its architecture diagram. Every number below is reported by Z.ai and has not been independently checked.

The short version

  • GLM-5.4 runs 28 layers twice for every token. The other layers run once.
  • It was made by continued training of the GLM-5 base model, not by pre-training a looped model from zero.
  • Three changes make it work at this size: per-token gates, a hybrid KV cache, and reused sparse attention indices.
  • On a 30B test model with the same architecture, looping added about 10% more training compute and improved every benchmark shown, by 3.3 to 11.3 points.
  • Z.ai claims intelligence "comparable to 2T-3T parameter models," but the post does not include flagship benchmark scores to back that up.
  • Weights are not out yet. Z.ai says it plans to release them "after completing necessary safety hardening."

What a loop transformer does

A standard transformer is a fixed stack of layers. Each token goes through every layer once.

A loop transformer picks a group of layers and runs them more than once. The same weights are reused on each pass. Each pass starts from the hidden states the previous pass produced, so the model gets to refine its work. You get a deeper network without storing more parameters.

Z.ai is open about the history. The post credits the 2018 Universal Transformer and later work on recurrent depth. Its reason for looping is the same one other labs give. In its words, "memory-intensive tasks benefit from more parameters, while reasoning-intensive tasks benefit from more effective compute." Looping adds compute, not memory.

The key decision: convert instead of training from scratch

This is the most interesting part of the post.

Z.ai says looped models trained from scratch "still lag behind unshared models under the same pre-training compute budget." In other words, if you have a fixed training budget, a normal model trained from scratch still tends to win.

So Z.ai skipped that race. It took the GLM-5 base model, which was already fully trained, and turned part of it into a loop through continued training. The goal, in the post's words, is to "raise the intelligence ceiling with a relatively small compute overhead."

For anyone following this field, that is a practical result. It suggests that looping does not have to be a choice made before pre-training starts. It could be applied to a model that already exists.

How the model is wired

The architecture diagram in the post shows 78 layers in four groups:

  • Prelude (layers 1 to 26): runs once. Turns the input into the model's internal representation. The input includes text embeddings plus projected features from a 24-layer vision encoder.
  • Loop pass 1 (layers 27 to 54): the 28 looped layers, first run.
  • Loop pass 2 (layers 27 to 54 again): same weights, second run.
  • Coda (layers 55 to 78): runs once. Turns the final state into the next-token prediction.

That makes 106 layer passes per token from 78 stored layers.

This is close to how Inkling 2 Mini is built: a prelude, a looped middle, and a final block. Both labs loop the middle of the network, not the start or the end.

Change 1: gates that stop the numbers from blowing up

When you loop layers that were trained to run only once, a problem shows up. If each pass simply overwrites the hidden state, the size of the values (the "activation norms") grows with each pass. The layers after the loop then get inputs at a scale they never saw in training.

GLM-5.4 fixes this with a gate after each pass. The diagram shows the formula:

x1 = x0 + b1 * (h1 - x0)
x2 = x1 + b2 * (h2 - x1)

Here x0 is the state before the loop, h1 is what pass 1 produced, and b1 is a gate value the model computes for each token. If the gate is small, the pass only nudges the state. If it is close to 1, the pass replaces it.

Z.ai reports that after training, the gates split the work in a clear way:

  • Pass 1 writes carefully. It builds global context with small gate values, which keeps the numbers stable.
  • Pass 2 writes fully. It opens the gates and refines the output.
  • Hard tokens get more. On harder tokens, the first pass writes more aggressively, so those tokens get more benefit from the second pass.

This rhymes with the research. The 2024 ICLR paper "Looped Transformers are Better at Learning Learning Algorithms" found that looped models became unstable unless they were given extra structure (in that paper, feeding the original input back in on every pass). Inkling 2 Mini uses a learned gate that starts closed. Stability is the problem every looped design has to solve, and gates are a common answer.

Change 2: the KV cache does not double

This is the change that matters most for running the model.

During generation, a transformer keeps a KV cache: the stored keys and values for every earlier token. For long contexts, this cache is a big share of memory. A naive looped model would keep a full cache for every pass. Two passes would mean two full caches.

GLM-5.4 avoids that with a hybrid design:

  • Pass 2 reuses pass 1's cache for the long context (the "sparse KV selected in the first pass").
  • Pass 2 also keeps its own small cache for recent tokens only, using a sliding window. The diagram labels this window as 128 tokens.
  • The model can attend to both at once.

The result, according to Z.ai, is that "an extra loop only costs one sliding window of KV cache rather than a full context cache." Z.ai says this keeps the deployment cost increase over GLM-5.3 "well under control" at 1M-token context lengths. The post does not give a number for that increase.

Change 3: attention indices are computed once

GLM-5.4 uses sparse attention. Instead of looking at every earlier token, it picks the most relevant ones. A component called an indexer makes that choice.

In the second pass, GLM-5.4 does not run the indexer again. It reuses the choices from the first pass. Z.ai says this adds "zero indexing overhead" and "performs nearly identically to recomputing indices on every pass."

The ablation numbers

Before using looping in the flagship model, Z.ai tested it on base models of 1B, 4B, 30B and 750B parameters.

The clearest evidence is a controlled test on the 30B model, which has the same architecture as the 750B base. Both versions had the same parameter count. The looped version used about 10% more total training compute. Scores were measured after long-context fine-tuning, with thinking mode on:

  • AIME25: 19.17 to 30.42 (+11.3)
  • GPQA-Diamond: 47.58 to 56.26 (+8.7)
  • AA-LCR: 40.33 to 47.67 (+7.3)
  • MMLU-Pro: 71.65 to 75.05 (+3.4)
  • IFBench: 50.20 to 53.47 (+3.3)

Two patterns stand out.

The gains are biggest on long reasoning. Math (AIME25), science (GPQA-Diamond) and long-context reasoning (AA-LCR) improved most. Knowledge-heavy MMLU-Pro and instruction following (IFBench) improved least. Inkling 2 Mini's launch post reported a similar split: looping helped reasoning, not memorized knowledge.

The model writes less while thinking. Average output length dropped on every benchmark in the table. Z.ai's text says most benchmarks dropped by 10 to 14%. The table shows a wider range: GPQA-Diamond fell 11.7% (2,473 tokens), MMLU-Pro 14.9% and IFBench 13.0%, but AIME25 only 2%. Z.ai's reading is that "part of the reasoning shifts from explicit output tokens into the implicit depth of the loop." Inkling's team reported the same effect.

That last point has a safety side. Reasoning that moves inside the loop is reasoning nobody can read in the chain of thought. Thinking Machines studied that question in detail for Inkling. The GLM-5.4 post does not discuss it.

What the post does not show yet

The engineering details are clear. The headline claims are thinner.

  • No flagship benchmarks. The "comparable to 2T-3T parameter models" claim has no scores attached in the post. The only numbers are from the 30B test model.
  • Speed numbers are vendor-reported. Z.ai says GLM-5.4 reaches "up to 200 tokens/s" off-peak and 70 to 80 tokens/s at peak load. There is no detail on hardware, context length or batch size.
  • A known weakness. Z.ai says the model "tends to get caught in overly long 'marathon thinking' loops." It adds that this extra reflection improves accuracy. For anyone paying per token or waiting on a response, long thinking still costs time and money.
  • Not yet open. The API is listed as "coming soon," and weights will follow safety work. Today you can try it through the GLM Coding Plan, ZCode and Z.ai Chat.

"Generalized Coding"

The second half of the post is product positioning. Z.ai calls it "Generalized Coding": using code as the base for tasks beyond software. Its demos include a music video, a 6-axis robotic arm modeled in FreeCAD, a complete game, and a 3D bird-watching scene written in GLSL shaders.

These are demos, not benchmarks. They show what the model can produce on a good run, not how often it succeeds. Treat them that way until independent tests appear.

Why this matters

In one week, two labs shipped looped models at very different sizes: about 26B for Inkling 2 Mini and the 750B scale for GLM-5.4. That is a signal that looping has moved from research papers into production.

GLM-5.4 adds two lessons of its own:

  1. You can convert an existing model. Continued training on a pre-trained base sidesteps the main weakness of looped models trained from scratch.
  2. The KV cache is the real cost, and it can be managed. Sharing the cache across passes and giving the second pass only a small local window keeps memory close to the non-looped model.

The open questions are the ones Z.ai lists itself. Can harder tokens get more loops automatically? And how do the gains change as loop count and model size keep growing? Z.ai says its next, "significantly larger" model is coming soon.

If looping moves reasoning out of the visible chain of thought and into the hidden layers, how much should we trust a model's written reasoning to tell us what it actually did?

來源:DEV Community · dev.to