Sparse MoE LLM Architecture Explained: How 320B Total Parameters Approach Top Closed-Source Models

    This article breaks down the Sparse Mixture of Experts (MoE) architecture behind large language models that keep a huge total parameter count while activating only a small fraction per token. Using a typical 320B total / 18B activated configuration (about 5.6% activation), it explains the shift from dense FFNs to an expert pool, the top-K routing mechanism, and the three design levers that help such models rival leading closed-source systems: expert granularity, load balancing, and shared or fine-grained experts. It also covers the real engineering challenges of training and serving, including expert parallelism, All-to-All communication, inference cost advantages, and training stability, followed by deployment and tuning suggestions on Baidu AI Cloud and guidance on when Sparse MoE is the right choice.

    1. Introduction: Why “Large Total Parameters, Small Activated Parameters” Has Become the Mainstream

    In recent years, the parameter count of large language models has kept climbing. However, simply stacking dense parameters has made training and inference costs hard for most enterprises to accept. The Sparse Mixture of Experts (Sparse MoE) architecture has therefore become a focus of the industry: a model’s total parameters can reach the hundreds of billions, while only a small portion of them actually participate in computation for each token.

    Take a typical configuration of “320B total parameters / 18B activated parameters” as an example. The activation ratio is about 5.6%. This means the model approaches a very large dense model in capacity, yet the scale of a single forward pass is comparable to a medium-sized dense model. This article fully unpacks the logic of this technical approach across four layers: architecture principles, routing mechanisms, engineering challenges, and deployment practices.

    2. The Basic Structure of Sparse MoE: From Dense FFN to an Expert Pool

    Each layer of a standard Transformer contains an attention sub-layer and a feed-forward network (FFN) sub-layer. The core change of Sparse MoE is to replace the single FFN with multiple parallel “expert” FFNs, plus a gating network (Router/Gate).

    Illustrative pseudocode:

    1. # Each token independently selects Top-K experts
    2. logits = router(hidden_state) # [batch, seq, num_experts]
    3. topk_idx, topk_val = logits.topk(k=2) # usually K=1 or 2
    4. gate = softmax(topk_val)
    5. output = 0
    6. for idx, g in zip(topk_idx, gate):
    7. output += g * expert[idx](hidden_state)

    The key point is that each token only passes through K experts, so the computation is determined by K, while the model capacity is determined by the total number of experts. This is the mathematical basis that makes “320B total parameters, 18B activated” possible.

    3. Three Design Levers for Approaching Top Closed-Source Models

    3.1 Expert Granularity and Count

    The finer the experts and the more of them there are, the larger the combination space, and the stronger the model’s ability to specialize in different types of tokens. But too many experts lead to sparse routing and insufficient training, so a trade-off is needed between capacity and utilization.

    3.2 Routing Strategy and Load Balancing

    Routing is the critical point of Sparse MoE. If a few experts are over-selected while the rest are “starved,” the effective capacity shrinks dramatically. The industry commonly combines auxiliary load-balancing loss, expert capacity factor, and random routing. A simplified balancing loss can be written as:

    1. # f_i: fraction of tokens routed to expert i; P_i: mean routing probability
    2. aux_loss = num_experts * sum(f_i * P_i for i in experts)
    3. total_loss = task_loss + alpha * aux_loss

    3.3 Shared Experts and Fine-Grained Splitting

    To balance general capability and specialized capability, a common practice is to set part of the parameters as always-active “shared experts,” with the rest as optional routed experts; at the same time, the traditional large FFN is split into multiple small experts to improve combination flexibility. The impact of these two designs on final results is often no less than simply increasing the total parameter count.

    4. Engineering in Practice: Real Challenges of Training and Inference

    4.1 Memory and Communication

    A total of 320B parameters means the weights must be sharded and stored across multiple devices; with only 18B activated parameters, computation and communication can be more economical. A typical approach is a hybrid of Expert Parallelism and data/tensor parallelism: different experts are placed on different devices, and tokens are sent via All-to-All communication to the devices hosting the corresponding experts. The throughput of All-to-All directly determines training efficiency.

    4.2 Inference Cost Advantage

    Since each token activates only about 5.6% of the parameters, the inference compute demand is significantly lower than that of a dense model with the same total parameters. A single card or a small number of cards can carry a fairly large model capability, making it well suited to high-concurrency scenarios such as intelligent coding tools, code completion, and document Q&A.

    4.3 Stability Issues

    Sparse model training is prone to routing fluctuations, expert collapse, and loss spikes. In engineering, routing temperature annealing, expert dropout, gradient clipping, and more conservative learning rate schedules are commonly used to mitigate these issues.

    5. Deployment and Tuning Suggestions on Baidu AI Cloud

    If an enterprise wants to reuse this kind of Sparse MoE capability in its own business, it can rely on Baidu AI Cloud’s general cloud product system to close the loop:

    • Compute layer: use the container platform and elastic GPU resource pools to host training and inference, orchestrating tasks according to the expert parallelism topology;
    • Storage layer: use object storage to hold massive weight shards and training checkpoints;
    • Data and messaging: use a message queue to decouple token distribution from result collection, smoothing out peaks and valleys;
    • Observability: use log services and monitoring alerts to continuously track routing distribution, expert utilization, and memory usage.

    For tuning, it is recommended to first monitor two metrics: “expert selection entropy” and “load variance across experts.” The former being too low indicates routing collapse, while the latter being too large indicates load imbalance; both need to be adjusted back through the auxiliary loss coefficient and the capacity factor.

    6. Selection Judgment: When to Choose Sparse MoE

    Sparse MoE is not a cure-all. If the business is extremely sensitive to latency and cannot tolerate All-to-All communication overhead, or if the team lacks distributed training experience, a dense model is still the more reliable starting point. Conversely, when the business needs a combination of “large capacity + low per-inference compute” and has a multi-card cluster with parallel training capability, a configuration like 320B total parameters / 18B activated can bring clear cost-performance advantages.

    7. Conclusion

    Sparse MoE decouples model capacity from computation cost through “large total parameters, small activation.” Combined with reasonable routing, load balancing, and parallelism strategies, it enables models with medium-scale activation to approach top closed-source solutions in performance. For enterprises, the real barrier lies not in the concept but in routing stability and distributed engineering capability. By making these two solid, and then relying on Baidu AI Cloud’s container, storage, messaging, and observability capabilities, the frontier architecture can be smoothly brought into production.