Inside GLM-5.4: How Loop Transformers Unlock Generalized Coding
🚀 Key Takeaways
- Weight-Reusing Loop Architecture: GLM-5.4 executes existing transformer layers across multiple passes, deepening computational reasoning without inflating raw model size.
- Stabilized Two-Pass Optimization: Continuous pre-training paired with independent token gating and a hybrid cache preserves activation stability and accelerates runtime execution.
- Generalized Coding Paradigm: The model expands program synthesis beyond standard software development into multimodal domains such as CAD modeling, robotics, and procedural video generation.
- Targeted Ecosystem Deployment: The system is integrated directly into Z.ai subscriptions and developer CLI tools, with standalone API access and weight releases slated following safety hardening.
As frontier artificial intelligence encounters practical ceilings in brute-force parameter scaling, Z.ai has introduced GLM-5.4 to chart a fundamentally different path forward. Rather than expanding network dimensions into multi-trillion parameter territory, the model establishes the production debut of the Loop Transformer, an architectural design that re-routes token representations through core network layers multiple times to achieve profound computational depth.
This architectural shift underpins what Z.ai defines as Generalized Coding—an operating philosophy where code generation acts as an expressive medium to solve physical and visual challenges far outside traditional software repositories. By combining dynamic gating mechanisms with modular memory caches, GLM-5.4 demonstrates that iterative computational refinement can overcome conventional scaling bottlenecks while handling intricate engineering and creative workflows.
This architectural shift underpins what Z.ai defines as Generalized Coding—an operating philosophy where code generation acts as an expressive medium to solve physical and visual challenges far outside traditional software repositories. By combining dynamic gating mechanisms with modular memory caches, GLM-5.4 demonstrates that iterative computational refinement can overcome conventional scaling bottlenecks while handling intricate engineering and creative workflows.

1. Loop Transformer Architecture: Reusing Layers for Trillion-Scale Computational Depth
Understanding GLM-5.4's foundation begins with its structural departure from conventional forward-only model topologies, which directly underpins how GLM-5.4's Loop Transformer enables generalized coding through recursive algorithmic refinement.Rather than continuously widening the neural network footprint to handle intricate programming structures, the architecture achieves deep-tier computational reasoning through recurrent execution cycles.
Two-Pass Layer Iteration Over 28 Base Layers
GLM-5.4 operates at a 750-billion-parameter scale while avoiding the physical footprint expansions traditionally required for multi-trillion parameter networks.Under this design, the model executes 28 layers of the GLM-5 base model twice rather than running each layer once.
Z.ai stated the design loops existing layers in the GLM-5 base model for deeper reasoning.
The architecture reuses weights across passes to deepen computational reasoning instead of growing model parameters.
By cycling the internal token representations through the same 28 layers in two consecutive passes, the execution pipeline allows complex program representations and control flow dependencies to be processed across multiple stages of evaluation.
| Architectural Dimension | GLM-5.4 Specification |
|---|---|
| Base Architecture Lineage | Loop Transformer (concept traces back to the 2018 Universal Transformer) |
| Physical Parameter Foundation | 750-billion-parameter scale |
| Base Model Layer Count | 28 layers of the GLM-5 base model |
| Layer Execution Strategy | Executes 28 layers twice (two-pass weight reuse) |
| Parameter Expansion Mechanism | Reuses weights across passes instead of growing model parameters |
| Claimed Intelligence Tier | Comparable to models with 2 to 3 trillion parameters without increasing parameter count |
| Deployment Milestone | Z.ai's first flagship model built on the Loop Transformer architecture |
From 2018 Universal Transformers to 750B Scale
GLM-5.4 is Z.ai's first flagship model built on the Loop Transformer architecture.The underlying concept traces back to the 2018 Universal Transformer, adapting the principle of recurrence over depth to modern large-scale system designs.
Historically, standard transformer deployments stacked discrete layers sequentially to build abstraction, scaling compute strictly in step with parameter counts.
Z.ai claims the architecture delivers intelligence comparable to models with 2 to 3 trillion parameters without increasing parameter count.
By executing recurrent layer traversals over its 750-billion-parameter base, the system unlocks computational depth equivalent to systems several times its physical size.

2. Inference and Training Engineering: Gating Mechanisms, Hybrid KV Caching, and Kernels
The practical viability of GLM-5.4's Loop Transformer for generalized coding relies directly on training stability and runtime memory engineering.Executing iterative layer passes introduces significant computational overhead and activation risks that conventional architectures do not face.
To resolve these engineering bottlenecks without degrading performance, Z.ai introduced specialized training adaptation protocols, token-level gating, hybrid caching, and kernel-level optimizations.
Token-Specific Gating and Continued Training Adaptation
Under identical compute budgets, training looped transformer architectures completely from scratch consistently trails standard autoregressive models.To circumvent this limitation, Z.ai adapted an already trained base model via continued training rather than initiating training from scratch.
In controlled tests conducted on a 30B parameter model, this looping adaptation required approximately 10% more training compute compared to standard baselines.
A central challenge in recurrent layer execution is the risk of activation instability across repeated passes.
GLM-5.4 addresses this using a token-specific independent gating mechanism that regulates how much candidate updates modify the network's internal state.
Z.ai noted that the gating mechanism applies conservative updates on the first pass to establish context and opens further on the second pass for refinement.
This per-token calibration ensures that stable contextual representations are formed before the model applies targeted structural edits to its internal state.
Hybrid KV Caching, Sparse Attention Reuse, and Kernel Fusion
Iterating through transformer blocks multiple times threatens inference speed due to quadratic attention costs and escalating memory bandwidth demands.To maintain low latency, the architecture deploys a hybrid KV cache that allows the second pass to reuse sparse KV entries selected during the first pass.
Rather than expanding the full context cache during subsequent passes, new entries generated in the second pass are stored in a dedicated local sliding window.
Furthermore, the second pass reuses sparse attention indices directly from the first pass to avoid recalculating context positions.
At the hardware execution layer, fused core kernels reduce intermediate memory read and write overhead during layer iterations.
These optimizations prevent memory bus saturation and preserve production-grade serving speeds.
In production environments, inference throughput reaches between 70 to 80 tokens per second at peak load and up to 200 tokens per second during off-peak periods.
In addition to sustained throughput, controlled tests revealed that average output length decreased by 10% to 14% on benchmarks such as GPQA-Diamond and MMLU-Pro, reflecting more concise and concentrated reasoning paths.
| Engineering Component | Technical Implementation | Measured Metric / Operational Impact |
|---|---|---|
| Model Adaptation Strategy | Continued training of an already trained base model instead of training from scratch | Required approximately 10% more training compute on a 30B parameter model |
| Token-Specific Gating Mechanism | Independent per-token gating applying conservative updates on pass one and expanded updates on pass two | Regulates candidate state modifications to prevent internal activation instability |
| Hybrid KV Cache Architecture | Sparse KV entry reuse coupled with a dedicated local sliding window for second-pass entries | Eliminates full context cache expansion during multi-pass execution |
| Attention Index Reuse | Direct reuse of first-pass sparse attention indices in the second pass | Avoids recalculating context positions across loop iterations |
| Kernel Execution | Fused core kernels deployed across layer iteration boundaries | Reduces intermediate memory read and write overhead during layer passes |
| Serving Throughput | Optimized hardware execution pipeline | 70 to 80 tokens per second (peak load); up to 200 tokens per second (off-peak) |
| Output Efficiency | Loop-refined contextual representations | Average output length decreased by 10% to 14% on GPQA-Diamond and MMLU-Pro |

3. Generalized Coding Frontiers: Visual Synthesis, CAD Modeling, and Algorithmic Shaders
GLM-5.4's architectural loop foundation underpins what Z.ai defines as Generalized Coding, establishing a direct connection between iterative algorithmic execution and domains outside standard programmatic scripts.Rather than restricting automated code generation to traditional software engineering tasks, Generalized Coding utilizes programmatic reasoning and multimodal synthesis to resolve complex visual, spatial, and mechanical design problems.
By integrating vision capabilities into the model, GLM-5.4 processes and produces visual coding structures directly aligned with physical and graphical environments.
Multimodal Expansion: FreeCAD Robotics, Shaders, and Video Generation
Z.ai stated that GLM-5.4 pushes beyond traditional coding to video, games, 3D shaders, and CAD modeling.To validate this expanded scope, the model incorporates dedicated vision capabilities that allow it to execute visual coding workflows across dynamic media and spatial engineering tasks.
Multiple concrete demonstrations highlight how programmatic synthesis replaces manual asset production and procedural scripting across diverse media:
| Demonstration Domain | Implementation Scope and Technical Output |
|---|---|
| Video Synthesis | Production of a complete, self-narrated music video titled Hello World, combining visual and audio scripting. |
| Mechanical CAD Modeling | Programmatic engineering of a 6-axis robotic arm modeled directly through the FreeCAD design tool. |
| Procedural Graphics | Generation of an interactive 3D birdwatching scene constructed using mathematical geometry and custom graphics shaders. |
| Interactive Game Creation | End-to-end full game generation covering character movement, physics, maps, combat systems, and art assets. |
Managing Marathon Thinking Loops and Autonomous Self-Correction
The application of Generalized Coding across intricate mathematical and mechanical domains exposes specific computational trade-offs during execution.Under complex reasoning demands, GLM-5.4 tends to get trapped in overly extended "marathon thinking" loops.
These extended loops introduce an explicit runtime penalty, lengthening inference cycles while the model navigates dense problem constraints.
However, Z.ai noted that although marathon loops add runtime, the accompanying self-correction improves accuracy.
Through these extended cycles, the model autonomously evaluates its intermediate programmatic structures, identifies logical or geometric flaws, and rectifies errors prior to finalizing the output, ensuring functional fidelity in demanding tasks such as CAD modeling, shader compilation, and game engine mechanics.

4. Tool Integration and Ecosystem Access: Claude Code, ZCode, and Staged Release Status
To operationalize the architectural advantages of GLM-5.4's Loop Transformer for generalized coding, deployment channels and developer interfaces have been configured to support multi-step reasoning and massive context scaling directly in daily programming workflows.The staged rollout brings these algorithmic capabilities into interactive development environments, editor extensions, and command-line agent frameworks while managing computational allocations and access boundaries.
Deployment Across ZCode v4.0.0 and Claude Code 1M Context
GLM-5.4 is accessible to subscribers of Z.ai's GLM Coding Plan, inside Z.ai Chat, and within the ZCode tool.Zixuan Li announced on X: "GLM-5.4 is now available to all GLM Coding Plan users."
To encourage adoption and prolonged exploratory coding sessions, users with weekly quotas receive 50% more quota on GLM-5.4 compared to GLM-5.3.
Tool support for the Loop Transformer model has progressed concurrently.
ZCode synced version 4.0.0 to GitHub at 06:04 UTC on November 23, 2026, anchoring client-side integration to the updated architecture.
Tooling integration establishes specific model routing strings depending on the target host.
In other integrated tools, the model identifier is glm-5.4.
In Claude Code, the model is selected via the identifier glm-5.4[1m], where the suffix selects a 1 million token context window, accommodating entire multi-repository architectures and large trace histories.
| Deployment Channel / Tool | Model Identifier | Configuration and Quota Details |
|---|---|---|
| Z.ai Chat & GLM Coding Plan | glm-5.4 | 50% more weekly quota compared to GLM-5.3 allocations. |
| ZCode | glm-5.4 | Version 4.0.0 synced to GitHub at 06:04 UTC on November 23, 2026. |
| Claude Code | glm-5.4[1m] | Specifies a 1 million token context window via the [1m] suffix. |
Ecosystem Safeguards: Safety Evaluations and Deferred Model Weights
Despite active integration across interactive web surfaces and IDE tools, full programmatic access remains constrained by phased platform safeguards.API access is pending the completion of safety evaluations.
Regarding availability timelines, Z.ai stated: "API access will open after safety evaluation. Model weights will be released responsibly."

References
Generative AI may have assisted with research or drafting for this article. Topic selection, fact-checking, final wording, and publication remain the responsibility of DragonStone74. AI use disclosure
