Mixture of Experts (MoE) LLM Architecture: Principles and Engineering Practices
This article explains how Mixture of Experts (MoE) architecture decouples model capacity from computation cost, and what it takes to run it in production. It covers fine-grained expert splitting, shared expert isolation, dynamic routing, load balancing, and capacity control, along with engineering guidance for training and inference. Readers will also find practical model-size selection advice, multimodal adaptation notes, and a minimal runnable router implementation.
1. Why Mixture of Experts?
The capability of dense models has long depended on linear growth in parameter count, and expanding parameters directly increases the compute required per token. Mixture of Experts (MoE) takes a different path: a large model is split into multiple smaller “expert” subnetworks, and a lightweight gating network selects only a subset of them during inference. As a result, the total parameter count can be very large while the actual activation per token stays within a small range.
A typical publicly reported configuration is roughly 671B total parameters with about 37B activated per token. This ratio decouples model capacity from compute cost: capacity determines “how much the model knows,” while activation volume determines “how fast it computes.” For enterprise scenarios that need to carry a large body of knowledge under limited compute, this decoupling has direct economic value.
MoE is not a new idea, but it only became practically usable in engineering terms in the last couple of years, for three main reasons: improved expert-parallel communication efficiency, maturing methods for routing stability, and the growth in the number of expert combinations enabled by fine-grained splitting.
2. Two Key Designs: Fine-Grained Splitting and Shared Expert Isolation
2.1 Fine-Grained Expert Splitting
In traditional MoE, there are few experts and each one is “wide.” Fine-grained splitting takes the opposite approach: each expert is made smaller, the number of experts is multiplied, and the number of experts selected per token is increased accordingly.
A schematic comparison of the structures (pseudocode, illustrating only the difference in splitting granularity):
# Coarse-grained: 2 wide experts, select 1class CoarseMoE(nn.Module):def __init__(self, hidden=4096):self.experts = nn.ModuleList([FFN(hidden) for _ in range(2)])self.top_k = 1# Fine-grained: 8 narrow experts, select 2class FineGrainedMoE(nn.Module):def __init__(self, hidden=4096):self.experts = nn.ModuleList([FFN(hidden // 2) for _ in range(8)])self.top_k = 2
The benefit of fine-grained splitting lies in the combination space: choosing 2 out of 8 already yields 28 paths, and splitting into 64 experts with 6 selected pushes the number of combinations into the hundreds of millions. The gating network can therefore route tokens with different semantics, different languages, and different reasoning depths more precisely, and individual experts find it easier to specialize. The cost is more frequent routing decisions and more fragmented communication, which places higher demands on parallelism strategies and operator fusion.
2.2 Shared Expert Isolation
If all experts are optional, “general knowledge” gets replicated across every expert, creating parameter redundancy. Shared expert isolation carves out a group of always-active shared experts dedicated to cross-domain general capability; the rest are routed experts responsible only for differentiated knowledge.
Formally, this can be written as:
y = Σ_{i∈Shared} FFN_i(x) + Σ_{j∈TopK(Router(x))} g_j · FFN_j(x)
where g_j is the gating weight. This structure separates “common” from “individual” at the parameter level, reducing duplicated storage and lowering the variance of routing signals, which makes training more stable.
3. Dynamic Routing and Load Balancing
Routing is where the architecture succeeds or fails. Three problems must be handled simultaneously in practice.
First, routing collapse. If the gate favors a few experts early on, the remaining experts receive no gradient and the model degenerates into a small model. Common mitigations include noise injection, routing temperature annealing, and normalizing selection counts.
Second, load imbalance. Under expert parallelism, the busiest expert determines overall latency. The industry commonly uses an auxiliary balancing loss to constrain the selection probability of each expert toward uniformity:
# Load balancing auxiliary loss (illustrative)def aux_loss(router_logits, top_k_idx, num_experts):probs = softmax(router_logits, dim=-1) # [tokens, experts]f_i = one_hot(top_k_idx, num_experts).float().mean(0) # actual assignment ratiop_i = probs.mean(0) # mean gating probabilityreturn num_experts * (f_i * p_i).sum()
Third, capacity and dropping. Each expert has a capacity limit, and tokens beyond it either take a residual direct connection or are dropped. A capacity factor that is too small costs accuracy, while one that is too large wastes memory and communication; tuning typically starts in the 1.0–1.25 range, combined with monitoring drop rate in training logs.
4. Engineering Essentials from Training to Inference
On the training side, expert parallelism (EP) must be combined with tensor parallelism and pipeline parallelism. A common practice is to place EP within the highest-bandwidth interconnect domain, since all-to-all communication volume grows linearly with token count and top_k. Gradient accumulation and communication overlap can significantly improve utilization.
On the inference side, the key tradeoff is memory versus throughput. All expert weights must either stay resident or be swappable in quickly, so quantization, expert offloading, and popularity-based tiered caching are common approaches. For serving, the recommendations are:
- Use continuous batching to improve GPU utilization and avoid MoE compute idling under small batches;
- Monitor the routing distribution online, since sudden shifts in expert popularity are often a signal of data drift or quantization error;
- Reserve KV cache budget for long-context scenarios, as MoE does not reduce the memory cost of the attention part.
A minimal runnable router implementation, useful for understanding the data flow:
import torch, torch.nn as nn, torch.nn.functional as Fclass Router(nn.Module):def __init__(self, hidden, num_experts, top_k=2):super().__init__()self.gate = nn.Linear(hidden, num_experts, bias=False)self.top_k = top_kdef forward(self, x):logits = self.gate(x)w, idx = torch.topk(F.softmax(logits, -1), self.top_k, dim=-1)w = w / w.sum(-1, keepdim=True) # weight normalization to stabilize output scalereturn w, idx
5. Parameter Scale and Multimodal Adaptation
The same architecture scales as needed: the 2B class suits on-device and high-frequency light tasks, the 16B class is relatively balanced between quality and cost, and the hundred-billion class targets complex reasoning. Notably, mid-sized models of this kind are also released as conversation-optimized open versions — for example, a 16B chat model was made public on February 27, 2025 — showing that MoE has moved down into a range deployable on a single machine.
The general approach to multimodal extension is to project the visual encoder output into soft tokens in the language space and feed them into the MoE backbone. The modality gap between vision and text naturally suits different experts, but the routing bias caused by the large disparity in image and text token counts needs attention.
6. Evolution and Selection Guidance
Based on public information, since the architecture was first open-sourced on January 11, 2024, it has gradually supported larger flagship models and evolved toward reasoning reinforcement, expert modes, and a multi-version matrix: an expert mode backed by a new-generation MoE foundation went live on April 8, 2026, incorporating reinforcement learning results on the reasoning side; a preview of a new-generation model series was released on April 24, 2026, with two branches — one aimed at the capability ceiling and one at cost efficiency. This path reflects an industry consensus: architectural innovation delivers the “capacity ceiling,” while inference optimization delivers “unit cost.”
Recommendations for adoption: scenarios with clear task boundaries, high concurrency, and cost sensitivity should evaluate mid-sized MoE first; for scenarios that are extremely latency-sensitive with very small batches, a small dense model may be more cost-effective. Regardless of the choice, establish a baseline evaluation set first, then compare three metrics — activated parameters, memory footprint, and P99 latency — rather than looking only at total parameter count. For cloud deployment, combining container platforms for elastic scaling, object storage for model weights, and monitoring and alerting to track routing distribution and drop rate turns MoE’s capacity advantage into stable business throughput.
