MoE Architecture and the Efficiency Revolution in Open-Source LLMs

    An increasing number of open-source large language models now adopt Mixture-of-Experts (MoE) architectures. This article uses one such model—744B total parameters with roughly 40B activated per token—to explain how sparse scaling makes model expansion affordable on the compute side while pushing memory and memory bandwidth to the foreground. It clarifies the difference between total parameters, activated parameters, and sparsity; breaks down the three main sources of coding-capability gains (data quality, multi-stage training, and reinforcement learning); offers a practical framework for reading internal and public benchmarks; outlines a four-dimension evaluation system for enterprise model selection; and closes with a concrete checklist for optimizing inference services, including quantization, expert parallelism, batching, and KV Cache management.

    1. From Parameters to Activated Parameters: How Sparse Architecture Makes Expansion Cheap

    A recently released open-source large model built on a sparse Mixture-of-Experts (MoE) architecture has drawn considerable attention. Its total parameter count reaches 744B, while the number of parameters activated per token is about 40B. For comparison, the previous generation in the same family had 355B total parameters and 32B activated parameters. In other words, the total parameter count roughly doubled, yet the activated parameter count grew by only about a quarter.

    To make sense of these numbers, it helps to distinguish three notions of “parameter count”:

    Concept Definition Impact on cost
    Total parameter count All learnable parameters in the model, including attention layers and all experts Determines weight storage, memory footprint, and training compute
    Activated parameter count Parameters actually involved in computation for a single token (attention layers + selected experts) Determines the floating-point operations (FLOPs) per token
    Sparsity Ratio of activated parameters to total parameters The higher it is, the more knowledge capacity per unit of computation
    Dimension Previous-gen MoE model New open-source MoE model Change
    Total parameter count 355B 744B ~2.1x
    Activated parameters per token 32B 40B 1.25x
    Activated-to-total ratio ~9.0% ~5.4% Decrease

    In dense models, every token passes through all parameters, so as model capacity grows, compute cost grows almost in lockstep. MoE models instead split the feed-forward layers into multiple parallel “experts,” and a lightweight gating network (the Router) selects the Top-K experts to handle each token.

    1. # Illustrative code: routing and forward pass of a MoE layer (demonstrates the compute path only, not a specific implementation)
    2. import torch
    3. import torch.nn as nn
    4. class TopkMoELayer(nn.Module):
    5. def __init__(self, hidden_size, num_experts, top_k=8):
    6. super().__init__()
    7. self.router = nn.Linear(hidden_size, num_experts, bias=False)
    8. self.experts = nn.ModuleList([
    9. nn.Sequential(
    10. nn.Linear(hidden_size, 4 * hidden_size),
    11. nn.SiLU(),
    12. nn.Linear(4 * hidden_size, hidden_size),
    13. )
    14. for _ in range(num_experts)
    15. ])
    16. self.top_k = top_k
    17. def forward(self, x):
    18. # x: [batch_size, seq_len, hidden_size]
    19. logits = self.router(x) # gating scores
    20. topk_logits, topk_idx = logits.topk(self.top_k, dim=-1)
    21. weights = topk_logits.softmax(dim=-1) # normalized gating weights
    22. out = torch.zeros_like(x)
    23. # Each token passes through only the Top-K experts: compute ∝ number of selected experts
    24. for slot in range(self.top_k):
    25. for expert_id, expert in enumerate(self.experts):
    26. mask = topk_idx[..., slot] == expert_id
    27. if not mask.any():
    28. continue
    29. out[mask] += weights[..., slot][mask].unsqueeze(-1) * expert(x[mask])
    30. # During training, an auxiliary load-balancing loss is also needed to prevent routing collapse to a few experts
    31. return out

    Looking at per-token compute, both generations use the same typical configuration—attention layers plus 8-of-N activation—so the ratio is very close:

    • Previous generation: 32B / 8 = 4B per expert, and 8 × 4B = 32B, matching the officially reported activated parameter count;
    • New generation: 8 × 4.75B = 38B, plus roughly 2B for the attention layers, totaling about 40B.

    Put differently, most of the 389B additional parameters in the new model exist as “sleeping experts.” They do not take part in normal inference computation; they contribute knowledge capacity only. This is the core logic of sparse expansion: knowledge capacity grows with total parameter count, while per-token compute stays essentially flat. The earlier note that “the activated ratio drops from about 9% to about 5.4%” is only a rough estimate—weight storage precision and the actual share of shared experts and attention layers all affect this figure.

    It is worth stressing that this “cheapness” applies only to compute and does not mean inference cost stays unchanged:

    1. Memory is a hard constraint: during inference, all expert weights must stay resident in memory, and memory demand grows roughly linearly with total parameter count. Under an idealized load-balancing assumption, inference needs at least 744B × 1 Byte = 744 GB (at 8-bit quantization), which a single accelerator cannot hold;
    2. Memory bandwidth becomes the bottleneck: autoregressive decoding generates tokens one at a time, activating only a small subset of experts on each forward pass. With a small batch size per request, compute is often underutilized, and much of the time is spent moving weights;
    3. Throughput amplifies memory demand: raising batch size amortizes memory-movement overhead, but KV Cache in turn grows significantly in memory footprint with concurrency and context length.

    The real total cost therefore has to be weighed across “throughput, concurrency, context length, and quantization scheme.” These models are better suited to shared, batch-oriented inference services than to low-latency single requests.

    2. Three Sources of Capability Gains: Parameter Scaling Is Only One

    The figures disclosed officially are representative: at the same parameter count and the same inference cost, coding ability improved by about 50% over the previous generation (measured on the internal coding benchmark Z.ai Code Bench).

    Notably, the official account attributes this gain to improvements in the training methodology rather than to changes in model size. Drawing on widely shared industry practice, the leap in coding ability typically comes from the combination of three sources:

    1. Data quality: from “a byproduct of web text” to “built around real engineering”
    Code data is no longer limited to raw files from public code-hosting platforms. High-quality data is often processed as follows:

    • Deduplication and contamination filtering: reduces the inflated scores caused by overlap between training and evaluation sets;
    • Executability checks: automatically completing or rewriting incomplete, non-runnable snippets, keeping only samples that compile and pass tests;
    • Reasoning-trace distillation: using a stronger model to generate a complete “approach + code” solution, improving the model’s long-chain reasoning;
    • Preference data construction: building ranking data across multiple candidate answers, training the model to tell “runs correctly” apart from “written well.”

    2. Training pipeline: division of labor across stages
    The mainstream training paradigm generally has three stages:

    • Pre-training: injects broad knowledge of code, math, natural language, and more, laying the groundwork for token-level generation;
    • Supervised fine-tuning (SFT): uses large-scale “instruction-response” samples to teach the model to output in the right format, call tools, and explain its reasoning;
    • Reinforcement learning (RL): continuously optimizes the policy based on verifiable reward signals.

    3. Reinforcement learning: why coding is a “natural testbed”
    Coding shares a key trait with math and logical reasoning: answers are verifiable. Whether test cases pass, what the unit-test results are, and whether a terminal command succeeds can all be judged automatically by a program, with no manual labeling needed. Such objective signals can be turned directly into rewards, letting the model repeatedly try and fail on massive numbers of tasks and gradually learn to break down problems, test hypotheses, and revise its approach based on feedback from failures.

    Long-horizon tasks, long reasoning chains, and “engineering” ability

    The difficulty of coding tasks lies not in “writing a single function” but in “completing a context-aware engineering collaboration”: reading multi-file dependencies, following project conventions, running tests, locating the cause of a failure, and iterating on a fix. Much of the new model’s improvement shows up as stronger long-horizon capability:

    • Long-context understanding: keeping key constraints in view over larger contexts, such as interface definitions and coding conventions;
    • Tool calling: accurately interpreting terminal output and error messages, and deciding the next step accordingly;
    • Error recovery: when compilation fails or tests do not pass, locating the root cause rather than retrying blindly.

    These are also the core focus of terminal-task and agent-task evaluations. Corresponding to them, the maturity of supporting tooling matters just as much, including code-context retrieval, the reliability of applying diff/patches, and sandboxed execution environments. Gains in model capability must evolve in step with the engineering pipeline before they translate into real productivity.

    3. Reading Benchmark Scores Rationally: From “Usable” to “Reliable”

    To judge whether a new model is worth investing in, the key is to read the information behind the evaluation setup.

    1. Internal benchmarks: directionally trustworthy, absolute values need caution
    The strength of internal benchmarks is that they stay close to real business scenarios and iterate quickly. But the test sets are usually built in-house, which carries a risk of selection bias. In addition, mixing test samples into training data (i.e., “data contamination”) can inflate scores. Internal benchmarks are therefore better for judging “whether there is an improvement over the previous generation” than for direct head-to-head comparison with other models.

    2. Public benchmarks: broader coverage, but watch the details
    Public evaluations such as terminal-task and agent-task benchmarks typically require a model to complete multi-step operations in a real or simulated environment, reflecting “task completion rate” rather than pure text quality. When reading these scores, keep in mind:

    • Evaluation version differences: difficulty and scoring can differ across versions, so cross-version comparisons call for extra care;
    • Evaluation configuration: prompt templates, tool sets, maximum number of steps, and whether retries are allowed can all significantly affect results;
    • pass@k vs. single-attempt success rate: the former measures the ability to succeed at least once across multiple attempts, while the latter reflects reliability of a single delivery; the two carry different meaning for production.

    3. The horizontal gap: the “converging trend” between open and closed source
    A common pattern in publicly available industry evaluations is that, over the past year or two, the gap between top open-source models and top closed-source models has narrowed noticeably. One notable phenomenon: some open-source models now approach or even exceed certain flagship closed-source models on particular benchmarks, and the largest gaps tend to concentrate in “high-difficulty agent tasks” that demand extremely long reasoning chains and very complex tool orchestration.

    4. From “writes well” to “affordable to use”
    Over the past year, comparisons between open- and closed-source models have often been summed up as “can write but not well” versus “writes well but expensive.” As open-source models keep advancing in coding and reasoning, the focus of competition is shifting toward: at equal capability, what are the per-token cost, the feasibility of private deployment, and data controllability? For enterprise selection, these are more worth attention than a single benchmark point.

    4. Enterprise Selection: From “Chasing Scores” to “Engineering a Closed Loop”

    For development teams, model selection is never just about “picking the highest score”—it is about choosing a sustainable engineering path. It helps to build an evaluation system around four dimensions.

    1. Build your own evaluation set: close to the business, free of contamination

    • Anonymize and extract tasks from real tickets and defect records to construct “problem-expected result” pairs;
    • Keep the evaluation set isolated from training data and prompts, and rotate the questions periodically;
    • Cover a range of task types: code generation, defect fixing, test writing, refactoring, and documentation generation.

    2. Score across multiple dimensions: not just “does it pass”

    Dimension Focus Suggested metrics
    Correctness Whether output runs and passes tests Test pass rate, compilation success rate
    Engineering standards Naming, comments, exception handling, dependency management Number of static-analysis issues, code-review pass rate
    Long-horizon capability Multi-file changes, tool calling, error recovery Task completion rate, average interaction steps
    Cost Input/output token consumption, inference latency Cost per task, P95 latency
    Security and compliance Sensitive-data leakage, license risk Number of scan alerts, manual review ratio

    3. Deployment model: match to the scenario

    • Private deployment: suits teams with sensitive code assets that need offline or intranet environments. Assess how weight size affects memory, bandwidth, and operations;
    • Cloud inference service: suits teams seeking elasticity and fast iteration. Pay attention to context length, concurrency, and availability;
    • Hybrid mode: sensitive tasks go through private deployment, general tasks go through the cloud, with a unified gateway handling routing and fallback.

    4. Continuous evaluation: turn evaluation into a pipeline

    Wire evaluation scripts into continuous integration so that batches run automatically after each model version update, establishing a “baseline–new version–canary–full rollout” release cadence. This avoids the capability drift that comes from “select once, use for a long time.”

    5. Putting It Into Practice: An Inference Performance Optimization Checklist

    For teams choosing private or self-hosted inference, here are directions worth pursuing:

    1. Quantization: use low-bit weight quantization (e.g., 8-bit or lower) to substantially cut memory footprint while keeping precision loss under control;
    2. Expert parallelism and scheduling: distribute experts across multiple cards and pair this with dynamic routing to reduce cross-card communication overhead;
    3. Batching and KV Cache management: raise throughput with continuous batching and reduce fragmentation with paged KV Cache management;
    4. Context compression: summarize long conversations and long codebases, or apply retrieval augmentation, to cut down ineffective tokens;
    5. Monitoring and alerting: build dashboards and alert thresholds for metrics such as memory utilization, request latency, and routing distribution.

    6. Conclusion: Capability Boundaries Are Being Redefined

    From 355B/32B to 744B/40B, the shift in parameter scale reflects the maturation of the MoE “sparse expansion” idea; and the marked improvement in coding ability under the same compute budget shows that the value of training methodology, data quality, and the design of reinforcement-learning signals is being re-recognized.

    For developers, this sends a clear signal: growth in model capability no longer depends solely on “piling on parameters,” but on the systems engineering of “data–training–inference.” For enterprises, rather than chasing a single leaderboard, it is better to build an evaluation and deployment system tailored to your own business.

    On cloud platforms such as Baidu AI Cloud, general capabilities—containerized inference services, object storage and logging services, and monitoring and alerting—can help teams more smoothly carry out model deployment, performance observation, and cost governance. Tools change; the methodology stays the same: get evaluation solid first, then get engineering solid, and capability can truly turn into productivity.