Ultra-Large-Scale MoE Model Architecture: Design, Challenges, and Engineering Practice
This article reviews two common Mixture of Experts (MoE) designs for large language models: the shared-plus-routed expert layout and the pure MoE approach. It covers Top-2 gating, expert load balancing, cross-node communication costs, and cloud-native deployment practices on Baidu AI Cloud.
1. Introduction: Model Evolution and the Rise of MoE
Natural language processing has advanced quickly. The parameter counts of large language models have grown from tens of billions to hundreds of billions, and in some cases to trillions. In traditional dense models, computational cost grows linearly, or even exponentially, as the parameter count increases. This leads to high inference latency and high compute costs. To go beyond the parameter limits of dense models under constrained compute, the Mixture of Experts (MoE) architecture emerged.
The core idea of MoE is to split a large neural network into multiple sparsely activated sub-networks, called “experts.” In each forward pass, only some of these experts take part in the computation. This lets a model keep a very large total parameter count while keeping the compute per inference within a manageable range. This article analyzes two representative MoE designs widely used in the industry, and discusses the engineering challenges and optimization practices involved in deploying them.
2. Core Architecture: Shared Experts and Dynamic Routing
MoE implementations use many routing and expert-combination strategies. One widely validated design with strong results is the hybrid of shared experts and routed experts.
2.1 The “8+1” Architecture: Decoupling General Knowledge from Specialized Capability
Take the “8+1” structure as an example. This architecture contains 8 routed experts and 1 shared expert. Its key innovation is an explicit decoupling of knowledge representation:
- Shared expert: This expert is always active during inference and does not take part in dynamic routing. Its main role is to capture and process general, foundational language knowledge. Because every token passes through the shared expert, this part of the network receives extensive training, which helps keep the output features stable and generalizable.
- Routed experts: The 8 routed experts handle specific domains or more specialized patterns. Based on the context features of the current token, the dynamic routing strategy assigns the most relevant routed experts to compute it.
The main advantage of this design is high stability. Because of the shared expert, the general feature representations in the lower layers do not fluctuate sharply due to routing sparsity. The design also helps mitigate expert load imbalance and knowledge forgetting, two common problems in pure routing architectures.
2.2 Dynamic Routing and Top-K Gating
For routed expert selection, the industry commonly uses Top-K gating, such as Top-2. When an input feature enters the routing layer, the gating network computes a matching score between the token and each routed expert, then activates the 2 experts with the highest scores.
The following simplified Top-2 gating example shows the core routing logic:
import torchimport torch.nn as nnimport torch.nn.functional as Fclass Top2Gating(nn.Module):def __init__(self, input_dim, num_experts):super().__init__()self.gate = nn.Linear(input_dim, num_experts)self.num_experts = num_expertsdef forward(self, x):# Compute routing logitslogits = self.gate(x)# Select the 2 experts with the highest scorestop2_scores, top2_indices = torch.topk(logits, k=2, dim=-1)# Normalize the weightstop2_scores = F.softmax(top2_scores, dim=-1)return top2_scores, top2_indices
Through this sparse activation, even when total parameters reach the hundreds-of-billions scale, the activated parameters per token stay in the tens of billions. This greatly improves inference efficiency.
3. The Pure MoE Approach: Full-Size Coverage and Engineering Fit
Besides architectures with shared experts, another mainstream approach is pure MoE. This route has no always-on shared expert. It relies entirely on dynamic routing to pick the best experts from a large pool.
3.1 Unified Training Framework and Full-Size Model Family
A key engineering feature of the pure MoE route is “full-size coverage.” Leading solutions typically use one training framework to produce multiple model versions, ranging from tens of billions of parameters to several hundred billion, and close to the hundreds-of-billions scale. This unified approach offers real value to developers and enterprises:
- Smooth scaling: Teams can first validate application logic and tune prompts on a smaller version, then move to a larger version for final quality alignment.
- Lower trial-and-error cost: Teams do not need to maintain multiple incompatible codebases for models of different sizes, which substantially reduces technical debt.
3.2 Flexible Deployment on Heterogeneous Hardware
Compute resources vary widely across enterprises. Full-size coverage lets developers choose a model version based on available hardware, such as per-GPU memory and the number of cluster nodes. For example, in resource-constrained edge settings or small and mid-sized business scenarios, a version with 800B total parameters but only 28B activated parameters can be deployed. This balances compute cost against model capability.
4. Key Engineering Challenges and Optimizations in MoE Deployment
Despite its clear advantages, MoE still faces many engineering challenges in distributed training and inference deployment.
4.1 Expert Load Balancing
Under pure routing, a “winner-takes-all” pattern can easily emerge. A few experts are activated frequently while others sit idle, which wastes memory and creates compute bottlenecks. To address this, engineering practice typically adds an auxiliary load-balancing loss to the training objective.
By monitoring how often each expert is selected and penalizing overly popular experts in the loss, the gating network is pushed to distribute tokens more evenly. Combined with a degree of random perturbation, this helps ensure all experts receive sufficient gradient updates over the training cycle.
4.2 Reducing Cross-Node Communication Overhead
When the number of experts is large, a single compute node, such as one 8-GPU server, cannot hold all of them. Tensor parallelism or expert parallelism across nodes then becomes necessary. This introduces dense All-to-All communication. If communication time dominates the inference cycle, the compute savings from sparsity disappear.
Common optimizations include overlapping communication with computation, NCCL-based topology-aware routing, and padding or batching tokens to improve bandwidth utilization for each communication call.
5. Best Practices for Deploying MoE in Cloud-Native Environments
When very large MoE models move into production, the underlying cloud-native infrastructure matters a great deal. General-purpose cloud services such as Baidu AI Cloud can lower the operational barrier for MoE architectures.
- Elastic container scheduling: Experts in an MoE model are distributed across multiple nodes, which places high demands on cluster resource scheduling. Using the Baidu AI Cloud container platform, teams can schedule GPU nodes with affinity rules that match the expert parallelism topology. They can also scale up or down quickly to handle traffic peaks and troughs.
- High-performance storage and loading: MoE weight files at the hundreds-of-billions scale can reach several terabytes. Combining object storage with a high-performance file system enables fast distribution and mounting of model weights, which shortens cold-start time for inference clusters.
- End-to-end monitoring and log analysis: The complexity of MoE architectures calls for more granular observability. By integrating logging and monitoring alerting systems, operators can observe the load level, memory usage, and network communication latency of each expert node in real time. When a single point becomes congested, they can locate and isolate the faulty node quickly.
Whether the design is the stable “shared plus routed” architecture or the extremely sparse full-size pure MoE approach, the core goal is the same: balance compute and intelligence through careful engineering. Choosing an architecture requires weighing business needs, available compute, and what the cloud-native infrastructure can support. Only then can large models be deployed efficiently.
