Mixture of experts
More parameters, same compute per token
Chapter 14 of 21 · IV. Scaling the network · about 40 minutes. Builds on: 7. The transformer block, 9. The full model and its training loop.
Conditional computation
Section titled “Conditional computation”In a dense model every token passes through every weight. A mixture of experts (MoE) replaces the MLP in each block with many smaller MLPs, the experts, plus a small router that picks a few experts per token. The idea predates transformers : the parameter count (capacity to store knowledge) grows with the number of experts, while the compute per token grows only with the number selected.
The computation
Section titled “The computation”For token vector , the router computes a score for each of experts, keeps the top , and combines the chosen experts’ outputs with normalized weights:
is and gives one score per expert; holds the indices of the highest scores; the weights are a softmax over the chosen scores, or renormalized sigmoids.
Each expert is a gated MLP (Chapter 7). The router is tiny . Only the selected experts run, so FLOPs per token are those of experts, not . Try the toy router and the parameter calculator:
Total parameters determine memory (every expert must be resident somewhere); active parameters determine compute and, roughly, per-token latency. gpt-oss-120b has 116.8B total and 5.1B active ; DeepSeek-V3 has 671B total and 37B active ; Mixtral 8x7B has about 46.7B total and 12.9B active . The calculator reproduces these from the architecture alone.
The load-balancing problem
Section titled “The load-balancing problem”Left to itself, a router collapses: a few experts get most tokens, they train faster and get chosen more, while the rest wither. Worse, in distributed training an overloaded expert’s GPU becomes a straggler. Standard remedies:
Auxiliary loss
Section titled “Auxiliary loss”Switch Transformers add a penalty that is smallest when tokens are spread evenly. With experts, let be the fraction of tokens sent to expert and the average router probability assigned to :
This is minimized when both and are uniform (each ). Switch also uses for simplicity, and an expert capacity = (tokens per batch / ) × capacity factor: tokens beyond an expert’s capacity are dropped from that layer and pass through only the residual connection.
Fine-grained and shared experts
Section titled “Fine-grained and shared experts”DeepSeekMoE argues for splitting experts into many smaller ones (so each token can combine a more specific mix) and for designating a few shared experts that every token always uses, to hold common knowledge so the routed experts can specialize. DeepSeek-V3 uses 256 routed experts of intermediate width 2,048 plus 1 shared expert, 8 routed experts per token, and ordinary dense MLPs in the first 3 layers . For comparison Mixtral has 8 large experts per layer with top-2, and gpt-oss-120b has 128 experts with top-4.
Auxiliary-loss-free balancing
Section titled “Auxiliary-loss-free balancing”An auxiliary loss pulls on the main objective and can hurt quality. DeepSeek-V3 follows : keep a bias for each expert. Add it to the router affinity only when choosing which experts to use (the gating weights still use the original affinity), and after each step lower by a small for overloaded experts and raise it for underloaded ones. DeepSeek-V3 uses sigmoid affinities normalized among the selected experts, a tiny sequence-level balance loss as a safety net, and limits each token to experts on at most 4 nodes to bound communication; it drops no tokens during training or inference .
Systems consequences
Section titled “Systems consequences”- Expert parallelism: experts are spread across GPUs. Each layer needs an all-to-all exchange: send each token to the GPUs holding its experts, compute, send results back. Network bandwidth becomes a first-order design constraint (hence node-limited routing).
- Memory vs compute: an MoE model is cheap per token yet needs enough memory for all experts, so it favors serving at large batch sizes where each expert sees many tokens.
- Open frontier models are overwhelmingly MoE: for example Kimi K2 and Qwen3’s large models alongside the models above. Read each report for exact configurations.
Check yourself
Section titled “Check yourself”A layer has 64 experts and top-2 routing. What fraction of the expert parameters is active per token?
% (plus any shared expert and the attention and router, which are always active).
Why is the balance loss N·Σ fᵢPᵢ and not just Σ fᵢ²?
is a count (not differentiable); is a smooth probability. Their product gives a gradient through while supplies information about actual load. The factor makes the minimum value 1 independent of .
Why add the bias b_i only for selection and not to the gate value?
The bias is a load-balancing control signal; including it in the weights would change the model’s output to satisfy balance, distorting the quality objective.
Papers
Section titled “Papers”- The sparsely-gated MoE layer.
- Switch Transformers: simple routing and the balancing loss (sections 2.1–2.2).
- Mixtral.
- Fine-grained and shared experts.
- Auxiliary-loss-free balancing.
- A complete large-scale MoE recipe.
- An attack specific to MoE serving.