GLM-5.4 Explained: How Z.ai Turned a 750B Model Into a Loop Transformer
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."…
In a recent development, Z.ai has introduced GLM-5.4, a model built on the Loop Transformer architecture, which is touted as its "first flagship model." The model is not a brand new creation but rather an existing, trained base model that has been converted to utilize the looped architecture. Unlike Inkling 2 Mini, which has 26.4 billion total parameters, GLM-5.4 operates at a scale of 750 billion parameters.
GLM-5.4 operates by running 28 layers twice for every token, while other layers run only once. The architecture incorporates three key changes that allow it to work at this scale: per-token gates, a hybrid KV cache, and reused sparse attention indices. In comparison to a 30B test model with the same architecture, incorporating a loop added approximately 10% more training compute, but improved benchmark performance by 3.3 to 11.3 points.
The company claims that the intelligence level of GLM-5.4 is comparable to models with 2T-3T parameters.
A standard transformer processes tokens through each layer once, whereas a loop transformer applies specific groups of layers multiple times, reusing the same weights on each pass. Each iteration starts with the hidden states generated by the previous pass, allowing the model to refine its work. This approach enables the creation of deeper networks without requiring more parameters. Z.ai cites the 2018 Universal Transformer and subsequent work on recurrent depth as the inspiration behind this design.
The primary reason behind looping is to address memory-intensive tasks while preserving effective compute for reasoning-intensive tasks. Looping adds computational power rather than memory. The decision to convert an existing model rather than train a looped model from scratch is noteworthy. Z.ai asserts that looped models trained from scratch generally perform worse than unshared models when working within a fixed training budget.
Therefore, they opted to take the pre-trained GLM-5 model and modify it to incorporate looping, aiming to raise the intelligence ceiling with minimal additional compute overhead.
The architecture of GLM-5.4 is composed of 78 layers divided into four groups: Prelude (layers 1 to 26) run once to transform the input into the model's internal representation, Loop Pass 1 (layers 27 to 54) implements the looped layers for the first time, Loop Pass 2 (layers 27 to 54) repeats the same weights for a second pass, and Coda (layers 55 to 78) runs once to convert the final state into the next-token prediction. This configuration results in 106 layer passes per token, originating from 78 stored layers.
To address instability issues arising from looping, Z.ai introduces two key changes. First, they implement per-token gates to prevent activation norms from growing excessively with each pass. These gates help control the state's evolution and ensure stability. Second, they employ a hybrid KV cache that avoids duplicating the cache for every pass.
Instead, the second pass reuses the first pass's cache for long contexts, while also maintaining a smaller sliding window cache for recent tokens, reducing the overall memory requirements.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to