GLM-5 Architecture Explained: A Technical Breakdown of Open-Source Sparse LLMs

    This article breaks down the architecture of GLM-5, a large open-source sparse model with 744B total parameters and 40B activated per inference. It explains the compute economics behind Mixture of Experts, then examines three key design choices: combining Multi-head Latent Attention (MLA) with optimizer splitting, using multi-token prediction to increase training signal density, and pairing sparse attention with MLA for long-context workloads. It closes with practical guidance on memory budgeting, building evaluation sets, inference infrastructure, data staging, and fallback strategies for deploying models of this scale.

    1. Introduction: The Capability Boundary of Open-Source Models Is Being Redefined

    Over the past two years, the gap between open-source large models and leading closed-source models has narrowed from a generational difference to same-tier competition. According to public benchmark results, the new generation of open-source models has reached the 50-point range in composite capability indices for the first time, ranking first among open-source models. In blind evaluations on text and code arenas, they also rank first in the open-source category, performing at the same level as the top closed-source models overseas. For developers and enterprise users, this means that building controllable model capabilities is no longer a compromise. It is now a practical option that balances performance, cost, and data compliance.

    This article uses a typical technical document for an ultra-large-scale sparse model as a basis, abstracts its architectural design methodology, and breaks down parameter scale, attention mechanisms, training objectives, and sparsification strategies layer by layer. The goal is to help readers build a transferable framework for evaluation.

    2. Fundamentals: The Compute Economics of 744B Total Parameters and 40B Activated Parameters

    The first key to understanding this class of models is distinguishing between total parameters and activated parameters.

    • 744B total parameters: determine the upper limit of the model’s knowledge capacity, affecting memory usage and deployment requirements.
    • 40B activated per inference: determine the actual cost of a single forward pass, directly affecting throughput and latency.
    • 256 experts and 80 layers: determine routing granularity and the depth of feature abstraction.

    The core idea of Mixture of Experts (MoE) is to remove the constraint in dense models where every token must pass through all weights. Instead, a routing network selects a small number of experts to participate in computation for each token. The benefit is direct: model capacity can scale linearly with the number of experts, while the computation per token stays roughly constant. The cost is increased memory usage and engineering complexity—all expert weights must remain resident, and uneven routing loads can leave some devices idle.

    Compared with the previous generation, parameters have doubled from 355B to 744B, activated parameters have increased from 32B to 40B, and the pre-training corpus has grown from 23T tokens to 28.5T tokens (about 27T for pre-training and about 1.5T for mid-training). Two engineering signals are worth noting here:

    1. Activated parameters increased by only 8B while total parameters doubled, indicating that the team deliberately invested the growth budget in capacity rather than compute—a typical cost-reduction approach.
    2. Mid-training was allocated a separate 1.5T tokens, indicating that data mixture and capability enhancement are managed as two independent stages rather than blended in a single pass.

    3. Architectural Change 1: Co-Tuning MLA with Optimizer Splitting

    Multi-head Latent Attention (MLA) shares the same origin as several mainstream sparse attention approaches in the industry. The idea is to use low-rank compression to reduce the dimensionality of the key-value cache, significantly lowering memory usage and improving decoding speed in long-context scenarios. For applications that handle long documents, large codebases, and multi-turn tool calls, this can be more valuable than simply scaling up parameters.

    However, a typical conflict emerged in engineering practice: when MLA was combined with an optimizer that maintains weight orthogonality, the results fell short of the simpler grouped-query attention approach. The team’s solution was optimizer splitting—instead of applying orthogonalization to the entire projection matrix as a block, it is applied separately to each attention head.

    1. # Pseudocode: block orthogonalization vs. per-head split orthogonalization
    2. # Option A (original)
    3. W = orthogonalize(W_concat) # shape [d_model, n_heads * d_head]
    4. # Option B (after splitting)
    5. for h in range(n_heads):
    6. W_h = W_concat[:, h*d_head:(h+1)*d_head]
    7. W_h = orthogonalize(W_h) # constrain each head independently

    The takeaway is that structural innovation and optimizer behavior are not independent variables. Before deploying any new attention structure, optimizer interactions should be included in the validation matrix. Otherwise, it is easy to misjudge “optimizer incompatibility” as “structural ineffectiveness.”

    4. Architectural Change 2: Multi-Token Prediction Changes Training Signal Density

    Traditional autoregressive training provides only one supervisory signal per position. Under a multi-token prediction framework, the model predicts multiple future tokens at each position. The benefits are threefold:

    • Higher training signal density improves sample efficiency, extracting more gradient information from the same corpus.
    • It forces the model to learn longer-range dependencies, which is especially helpful for planning and code completion tasks.
    • During inference, it can be combined with speculative decoding to trade a small cost for higher throughput.

    A boundary to note: multi-token prediction is not a free lunch. Too large a prediction span can introduce noisy gradients. In practice, the span is usually kept small and enabled on demand during inference.

    5. Architectural Change 3: Sparse Attention and the Long-Context Cost Curve

    The goal of sparse attention (DSA) is to keep attention computation from growing quadratically with sequence length. Common approaches combine local windows, global anchors, and learnable sparse routing. It is complementary to MLA: MLA compresses cache dimensions, while sparse attention reduces the computation range. Together, they can bring the per-token cost of long-text scenarios into an acceptable range.

    Three points to watch during implementation: whether the sparse pattern is friendly to hardware memory access characteristics; whether the precision loss from sparsification is tolerated by downstream tasks; and whether a dense fallback path needs to be retained for different tasks.

    6. Practical Guidance: How to Evaluate and Deploy This Class of Models

    1. Budget memory first, then evaluate performance. Even after quantization, 744B weights still require multiple GPUs. Always stress-test with real business concurrency rather than relying only on benchmark scores.
    2. Build your own evaluation set. Public benchmarks are for horizontal positioning, but business metrics determine the final choice. Cover long context, code, and structured output scenarios.
    3. Pay attention to the inference stack. An elastic container platform for inference services, object storage for model weights, a message queue for peak shaving, and logging and monitoring services form an observability loop—a common foundation for stable deployment.
    4. Stage training data properly. Managing pre-training and mid-training data mixtures separately makes it easier to locate issues and enhance capabilities in a targeted way.
    5. Keep a fallback strategy. Both sparsification and quantization introduce uncertainty, so critical paths should include a degradation plan.

    7. Conclusion

    The significance of the new generation of open-source models is not just that their scores have caught up with the top closed-source models. More importantly, they have engineered a working combination of large capacity, low activation, long context, and sparsification. For developers, what really needs to be mastered is not the parameter table of a specific model, but the conversion logic between parameters and compute, the coupling between structure and optimizer, and the complete validation method from evaluation to deployment. Baidu AI Cloud provides full product support for general compute, storage, and observability capabilities in model training and inference, helping enterprises bring this type of architectural evaluation into production environments faster.