The router is the brain of MoE
The router is a tiny network — usually a single linear layer mapping the token's hidden state to a logits vector over experts — but it is responsible for the entire routing decision. The router is learned alongside the rest of the model. If the router is bad, the experts get useless training signal and everything falls apart.
How top-K works
For each token, the router emits N scores (one per expert). Top-K selection keeps the K highest scores; the rest are zeroed out. The kept scores are passed through softmax (or sigmoid for some 2025+ designs) to become routing weights. Each selected expert's output is multiplied by its weight, and the K weighted outputs are summed.
Common K values in practice
- Top-1: Switch Transformer's original choice. Cheapest but most prone to expert collapse. Llama 4 Scout uses top-1.
- Top-2: Mixtral's choice. Two experts hedge against routing mistakes; modest extra compute. Was the dominant choice in 2023–2024.
- Top-6 to Top-8: DeepSeek's fine-grained-expert designs. Many small experts, more routes selected per token, more nuanced specialization.
Shared experts
DeepSeek-V2/V3 and Gemma 4 MoE include 1–2 shared experts that always activate for every token, regardless of router decisions. They provide a stable always-on baseline so the routed experts don't have to relearn common patterns. This is a small architectural addition with big training-stability benefits.
Sigmoid vs softmax routing
Most early MoE used softmax over expert logits. DeepSeek-V3 introduced sigmoid routing with auxiliary-loss-free balancing — each expert score is independent (no zero-sum competition), and load balancing is achieved by adding learned bias terms to the logits instead of an explicit auxiliary loss. This allowed DeepSeek-V3 to drop the auxiliary loss entirely and still avoid expert collapse.