Understanding the MoE Architecture: Why a 671B Model Only Activates 37B Parameters
This article explains why a Mixture of Experts (MoE) model with 671 billion total parameters activates only 37 billion per token. It breaks down where parameters sit in a dense Transformer, how MoE splits a large FFN into multiple routed experts, and how this decouples model capacity from per-token compute. It also covers the engineering trade-offs—memory, load balancing, training stability, and parallelism—and offers practical guidance for capacity planning and deployment.
1. Starting from Cost Intuition: Parameter Count Is Not Inference Cost
When a technical report states 671 billion parameters, most people immediately think of the compute bill. Yet the same report may list a training cost of only a few million high-end GPU hours—sometimes less than a dense model with a few billion parameters. This contrast is not marketing spin; it is a direct consequence of the architecture. In a sparse activation model, the total parameter count determines how much knowledge the model can hold, while the parameters that actually participate in computation for each token determine how much compute is spent. The two are deliberately separated, producing a model that is large in size but light per forward pass.
To understand this, it helps to see where a dense model’s parameters actually sit.
2. Parameter Distribution in Dense Models: The FFN Is the Heavyweight
A standard Transformer block has two main parts: self-attention and the feed-forward network (FFN). As a rough estimate for a dense model around seven billion parameters, a single attention layer holds about 150 million parameters, while the FFN holds about 700 million—over 80% of the layer’s parameters. The reason is straightforward: attention parameters are driven mainly by the squared hidden dimension, whereas the FFN is a two-layer “up-project, activate, down-project” structure whose intermediate dimension is typically several times the hidden dimension, making it inherently larger.
The rule for dense models is that every token passes fully through the entire FFN, meaning all parameters are used on every pass. As parameter count grows, per-token compute grows in lockstep. Capacity and computation are tightly bound to the same number.
3. The First Cut of MoE: Splitting One Large FFN into Many Small Ones
Mixture of Experts (MoE) targets exactly this heaviest structure. It replaces a single large FFN with N structurally identical, independently parameterized subnetworks called experts, and places a lightweight router in front of them. When a token arrives, the router scores it and selects the few highest-scoring experts to run, while the rest stay silent.
An early common configuration used 8 experts with 2 selected per token. More recent large-scale designs scale the expert count into the hundreds and additionally keep one shared expert that always participates in computation, carrying general capabilities so the routed experts can focus on differentiated knowledge. The forward logic can be sketched as:
# Pseudocode: expresses the structure of routing and sparse computation, not a specific implementationdef moe_forward(x, experts, router, top_k=2, shared_expert=None):weights = router(x) # [batch, num_experts]topk_w, topk_idx = topk_softmax(weights, top_k)out = 0for slot in range(top_k): # only top_k experts are actually executedidx = topk_idx[:, slot]out = out + topk_w[:, slot] * dispatch(experts[idx], x, idx)if shared_expert is not None: # the shared expert is always computedout = out + shared_expert(x)return out
The key is the dispatch step: only the selected experts’ weights need to be loaded and used in computation. The remaining parameters exist, but produce no floating-point operations.
4. The Core Point: Decoupling Capacity from Compute
This leads to the central conclusion of the architecture:
- Total parameters = capacity, which determines how much knowledge the model can hold and how high its ceiling is;
- Activated parameters = compute, which determines the real compute cost of processing each token.
In a dense model these two numbers are naturally equal. MoE separates them, producing combinations like “hundreds of billions of capacity, tens of billions activated.” In engineering terms, the model’s “intelligence budget” and its “inference bill” are no longer linearly bound. Scaling up can be done by adding experts, while per-token cost grows only slowly with top_k and expert size.
This also explains the economics on the training side: backpropagation likewise passes only through the activated experts, gradient updates are sparse, and the number of multiply-add operations per token is far lower than in a dense model of the same capacity.
5. The Costs and Engineering Constraints: Sparsity Is Not Free
The problems introduced by decoupling are equally clear and must be faced in practice:
- Memory and bandwidth pressure. The full parameter set must still reside in memory, so memory usage is calculated by total capacity. Inference is often limited by the bandwidth of moving expert weights into the compute units, not by raw compute.
- Load imbalance. The router may funnel many tokens to a few experts, overloading some devices while others idle. Common mitigations include an auxiliary balancing loss, random routing noise, and capacity limits, with overflow tokens handled by a bypass path.
- Training stability. Routing is a discrete decision, and drift in the logits scale can cause oscillation, so the update magnitude of the routing weights needs to be controlled.
- Parallelism complexity. Experts are usually partitioned across devices (expert parallelism) and combined with data parallelism and tensor parallelism. The communication pattern shifts from a regular all-reduce to an irregular All-to-All, placing higher demands on network topology and collective communication libraries.
6. Practical Guidance: How to Evaluate and Choose
- Capacity planning: first estimate compute by “activated parameters per token,” then estimate memory and procurement cost by “total parameters,” and budget along the two lines separately.
- Inference deployment: prioritize local placement of expert weights and high-speed interconnects, and during batching try to aggregate tokens for the same expert to improve weight reuse.
- Quality validation: at the same activation level, MoE usually outperforms a dense model of the same size, but the gains depend on data mixture and routing quality, so regression should be based on your own evaluation set.
- Cloud deployment: container platforms can orchestrate distributed inference, object storage can host weights, and monitoring, alerting, and logging services can track expert hit distribution and communication bottlenecks. General compute and containerization capabilities from cloud providers such as Baidu AI Cloud can serve as the foundation for hosting such sparse models.
7. Summary
The essence of “large but not heavy” is managing two originally overlapping metrics—model capacity and per-token compute—separately: parameters are stacked into the hundreds of billions to carry knowledge, while routing wakes only tens of billions at a time to do the computation. Understanding this decoupling as the main thread, together with the engineering constraints around memory, load balancing, and communication, lets you accurately judge the cost structure of sparse expert models instead of being led by the single number of parameter count.
