Why MoE Routes at the Token Level Instead of the Sentence Level
This article explains why Mixture-of-Experts (MoE) models route at the token level rather than assigning an entire sentence to one expert. It covers how routing granularity expands the model's hypothesis space, why sentence-level routing worsens expert collapse and load imbalance, and how token-level routing aligns naturally with tensor parallelism and All-to-All communication. It also outlines common pitfalls around expert collapse, numerical instability, and inference memory growth, plus a practical checklist for building MoE systems.
1. Where the Question Starts: Granularity Sets the Ceiling on MoE Capability
“Why not hand an entire sentence to a single expert instead of picking experts token by token?” This is the most common question people ask when they first encounter the Mixture-of-Experts (MoE) architecture. Intuitively, sentence-level routing requires only one decision, with lower communication and scheduling overhead, while token-level routing computes gating weights separately for every position and looks like pure efficiency waste.
Once you break the problem apart, however, routing granularity turns out not to be an efficiency issue but a question of how large the model’s hypothesis space is. The core benefit of MoE comes from conditional computation: different inputs activate different subsets of parameters, decoupling total parameter count from per-token compute. Routing granularity determines the resolution of that conditional computation.
2. Expressiveness: The Gap Is Measured in Combinations
Let the number of routed experts be $N$, the number of experts activated per token be $k$, and the sequence length be $L$.
- Sentence-level routing: the whole sequence shares one set of experts, giving a theoretical combination count of $\binom{N}{k}$ — a constant independent of $L$.
- Token-level routing: each position chooses independently, giving a theoretical combination count of $\binom{N}{k}^{L}$, which grows exponentially with sequence length.
Take a common industry configuration: 256 routed experts, 8 activated per token, sequence length 2048. $\binom{256}{8}$ is already on the order of $10^{13}$, and raising that to the 2048th power produces a number far larger than the total number of atoms in the observable universe (about $10^{80}$).
What this difference in magnitude actually means is that sentence-level routing forces the model to make a single decision about which semantic or syntactic pattern the whole sentence belongs to, while a sentence in language usually carries several properties at once — subject, predicate, modifiers, technical terms, code fragments, numeric entities — each of which needs a different subset of parameters. Token-level routing lets the model perform fine-grained functional division of labor inside the same sentence, something sentence-level schemes structurally cannot express.
It is worth stressing that a large combination count does not guarantee the model learns better; it only means the hypothesis space is no longer artificially compressed. The real gain comes from the gating network learning stable, generalizable division of labor within that huge space.
3. Load Balancing: Sentence-Level Routing Amplifies Expert Collapse
The most typical failure mode in MoE training is expert collapse: early in training the gating network notices that a few experts “look better,” so it keeps sending the vast majority of tokens to them, the remaining experts receive almost no gradient, and they permanently lose the ability to learn.
Sentence-level routing amplifies this problem to the extreme. Because decision frequency drops by a factor of $L$, the total update signal each expert receives drops accordingly, making the positive feedback loop harder to break; at the same time, popular experts receive entire sequences, so memory and compute peaks concentrate heavily, easily causing a single device to overflow while the rest sit idle.
Only when token-level routing is combined with the following common techniques can the load be flattened:
- Auxiliary load-balancing loss: penalize deviation of the routing distribution from an ideal uniform distribution, commonly via a term multiplying the share of the most-loaded expert by the average share;
- Capacity factor and overflow handling: set a capacity limit per expert, and route tokens beyond it through a residual direct connection or drop them, so a long tail does not drag down the whole batch;
- Randomness and noisy gating: inject noise into the gating logits early in training to encourage exploration;
- Shared experts as a fallback: keep a small number of always-active shared experts that carry general knowledge, letting routed experts focus on differentiated work.
4. Parallel Efficiency: Token-Level Routing Aligns Naturally with Tensor Parallelism
An often-overlooked reason is hardware friendliness. After token-level routing, different positions of the same sequence can be sent to different devices, and the All-to-All communication payload is a regular block of tokens that naturally matches how tensor parallelism is partitioned. Sentence-level routing means the entire sequence must reside on the same group of devices, and the longer the sequence, the worse the load skew and the larger the pipeline bubbles.
Illustrative forward logic (pseudocode):
# x: [batch, seq_len, hidden]flat = x.view(-1, hidden) # flatten into a token sequencelogits = gate(flat) # gating scores [num_tokens, num_experts]weights, idx = topk(softmax(logits), k=8) # pick k experts per tokenweights = weights / weights.sum(-1, keepdim=True) # normalize to keep scale stabley = dispatch_and_combine(flat, idx, weights, experts) # All-to-All dispatch then weighted combine
Here dispatch_and_combine is the core of the engineering implementation: it determines communication volume, peak memory, and fault-tolerance strategy, and it is the source of most performance problems.
5. Three Pitfalls You Have to Hit Early
Pitfall 1: Expert collapse. It shows up as extremely uneven expert utilization in training logs. The countermeasure is to introduce the load-balancing loss early and monitor each expert’s token share, rather than only watching total loss.
Pitfall 2: Gradient and numerical instability. Adding gating weights, expert outputs, and the residual together amplifies scale, which easily overflows under low-precision training. Common practice is to normalize the gating output, apply scaling to expert outputs, and keep high-precision accumulation on the residual path.
Pitfall 3: Inference memory growth. All expert parameters must be resident, but each token uses only a small fraction. Viable directions include tiered placement by popularity, putting cold experts in memory or object storage with asynchronous swap-in, and using message queues and logging services to observe swap-in hit rates, with monitoring and alerting to locate long-tail latency.
On low-precision training, the industry generally adopts a mixed-precision strategy: keep numerically sensitive parts (such as normalization, accumulation, and optimizer state) at higher precision, and use lower precision for compute-intensive parts like matrix multiplications to gain bandwidth and compute. This is general engineering practice; the actual benefit varies by implementation and hardware, so no fixed speedup factor should be assumed.
6. A Practical Checklist
- First validate that routing is balanced with a small-scale configuration, then scale up the number of experts;
- Start with a conservative capacity factor, observe the overflow rate, then adjust;
- Do not make the gating network too deep, or it becomes a training bottleneck;
- Build a dashboard with three core metrics: expert utilization, All-to-All time, and overflow rate;
- On the inference side, prioritize parameter residency and swap-in strategy over blindly adding experts.
7. Conclusion
Token-level routing is not an efficiency compromise but the optimal solution across expressiveness, load balancing, and parallel efficiency for the MoE architecture. Sentence-level routing looks simpler, yet it simultaneously compresses the hypothesis space, worsens expert collapse, and breaks load symmetry across devices. To build MoE capability in your own business, you can rely on a container platform for elastic scaling and use monitoring, alerting, and logging services to locate routing skew, keeping the engineering focus on gating stability and expert residency strategy rather than agonizing over routing granularity itself.
