MoE routing explained: top-k gates, load balancing losses and loss-free bias updates
Most of the largest open models released this year are mixtures of experts, and each has to solve the same problem: send every token to a few experts without overloading some and starving others. This article explains the routing maths, the auxiliary loss, and the bias trick DeepSeek and Baidu now use instead.
- Reading time
- 17 min
- Sections
- 9
- Code examples
- 2
- Tables
- 2
- Sources
- 7
- Published
- 24 Nov 2026
- What changed
- Baidu publishes ERNIE 5.5 Flash Base weights
- Why it matters
- If you train MoE models, load balancing is now mostly a control problem, not a loss-design problem.
- What to do
- Log expert load from day one
A mixture-of-experts (MoE) model replaces each feed-forward layer with many smaller feed-forward networks, the experts, and a small router that decides which few experts process each token. The appeal is simple: the model can hold a huge number of parameters but run only a small fraction of them per token. DeepSeek-V4-Pro, for example, reports 1.6 trillion total parameters and 49 billion activated per token, about 3%.
The hard part is the router. Left alone, routers tend to favour a handful of experts, which then become overloaded while others sit idle. That wastes hardware, slows training and can lock the model into using only part of its capacity. For years the standard fix was an extra loss term that penalised imbalance. The newest open models, including DeepSeek-V4 and Baidu's ERNIE 5.5 Flash Base, whose weights were updated on Hugging Face on 5 November, use a different idea: a small per-expert bias, adjusted after every training step, that steers tokens without adding any gradient.
What happened
Baidu publishes ERNIE 5.5 Flash Base weights (November 2026)
Baidu's ERNIE-5.5-Flash-Base repository on Hugging Face, last updated on 5 November 2026, describes a pretraining checkpoint with 280 billion total parameters (the Hugging Face metadata lists 286 billion) and 14 billion activated per token. Each MoE layer has 512 routed experts and 1 shared expert, and each token goes to the top 10 routed experts plus the shared one. The model card describes the routing as "Multi-Router Latent MoE", using several independently initialised sigmoid routers, and states that load balancing is "Auxiliary-loss-free". Our article on sizing giant open MoE models covers the model's size and hardware needs.
DeepSeek-V4 report spells out its routing recipe (April 2026)
The DeepSeek-V4 technical report, "Towards Highly Efficient Million-Token Context Intelligence" (arXiv 2606.19348, dated 26 April 2026 in its header), lists two models. V4-Pro has 1.6 trillion total and 49 billion activated parameters, with 384 routed experts per MoE layer. V4-Flash has 284 billion total and 13 billion activated, with 256 routed experts. Both have 1 shared expert and activate 6 routed experts per token. The report changes the router's scoring function from sigmoid to the square root of softplus, keeps an auxiliary-loss-free balancing strategy with a bias update speed of 0.001, adds a small sequence-wise balance loss with weight 0.0001, and routes the first three MoE layers by a fixed hash of the token ID. For more on the models themselves, see our DeepSeek V4 guide.
A theory for why the bias trick works (revised 26 April 2026)
X. Y. Han and Yuan Zhong's paper "A Theoretical Framework for Auxiliary-Loss-Free Load Balancing of Sparse Mixture-of-Experts in Large-Scale AI Models" (first posted 3 December 2025, version 3 on 26 April 2026) analyses the bias method as a primal-dual algorithm for an assignment problem. The authors report a rule that moves tokens from overloaded to underloaded experts, an approximate balancing guarantee, and a logarithmic expected regret bound in a stochastic setting, with experiments on 1 billion parameter DeepSeekMoE models.
How a router chooses experts
Take a token whose hidden vector is h. The router holds one learned vector eᵢ per expert. It computes an affinity score for each expert:
sᵢ = G(eᵢ · h)
where G is a squashing function. Older models used softmax across experts. DeepSeek's loss-free balancing paper used sigmoid, which scores each expert independently. DeepSeek-V4 uses √softplus. The router then keeps the top K scores and sends the token to those experts. The layer output is a weighted sum of the chosen experts' outputs, with weights gᵢ derived from the scores (often renormalised so the chosen weights sum to one):
y = h + Σ over chosen i of gᵢ · Expertᵢ(h)
Many recent models add one or more shared experts that every token uses, so common knowledge does not have to be copied into every routed expert. A model with 384 routed experts and K = 6 activates 6 / 384 ≈ 1.6% of its routed experts per token. ERNIE 5.5 Flash Base, with top-10 of 512, activates about 2%. You can watch tokens being routed in our mixture of experts simulation, and the basics are on our mixture of experts page.
An everyday analogy: a hospital triage nurse (the router) sends each patient to a few specialists. If everyone with a cough goes to the same doctor, that queue explodes while other doctors sit idle.
Why imbalance is a real problem
Imbalance hurts in two ways.
Hardware. In large training runs, experts live on different GPUs (expert parallelism). Each layer waits for the slowest GPU. If one expert receives three times its share of tokens, the whole layer runs at roughly a third of its possible speed.
Learning. Routing is self-reinforcing. An expert that gets more tokens gets more gradient updates, becomes better, and attracts even more tokens. In the extreme, called routing collapse, a few experts handle almost everything and the rest of the parameters are wasted.
A common way to measure balance is MaxVio, used in the loss-free balancing paper:
MaxVio = (max load − mean load) / mean load
where load is the number of tokens an expert receives in a batch. If 4,096 tokens each pick 6 of 64 experts, the mean load is 4,096 × 6 / 64 = 384 tokens. An expert receiving 768 tokens would give MaxVio = (768 − 384) / 384 = 1.0: the busiest expert has twice its fair share.
Capacity limits and dropped tokens
Early MoE systems handled imbalance with a hard cap. The Switch Transformer paper (Fedus, Zoph and Shazeer, JMLR 2022) defines:
expert capacity = (tokens per batch / number of experts) × capacity factor
With top-K routing, the average is K × T / N. For T = 4,096 tokens, N = 64 experts and K = 6, that is 384, and a capacity factor of 1.25 gives a cap of 480 tokens per expert. Tokens beyond the cap are dropped from that expert. In Switch Transformer, which uses top-1 routing, an overflowing token skips the expert computation and, in the paper's words, "is passed directly to the next layer through the residual connection."
Capacity makes memory and compute predictable, but dropped tokens get no expert processing in that layer, and a larger factor wastes memory on padding. Good balancing makes the cap rarely bind.
The auxiliary loss approach
Switch Transformer added a term to the training loss that is smallest when tokens are spread evenly:
L_balance = α · N · Σᵢ fᵢ · Pᵢ
Here fᵢ is the fraction of tokens in the batch dispatched to expert i, and Pᵢ is the average router probability assigned to expert i. fᵢ is a count, so it has no gradient. Pᵢ is differentiable, so the loss pushes probability away from experts that are already receiving many tokens. When both are uniform, every fᵢ = Pᵢ = 1/N, and N · Σ (1/N)(1/N) = 1, so the term's balanced value is α. The paper used α = 10⁻², chosen from a sweep between 10⁻¹ and 10⁻⁵.
A worked example
Take four experts. Suppose a batch sends 50%, 20%, 20% and 10% of tokens to them, so f = [0.5, 0.2, 0.2, 0.1], and the average router probabilities are P = [0.4, 0.25, 0.2, 0.15]. Then:
Σ fᵢPᵢ = 0.5 × 0.4 + 0.2 × 0.25 + 0.2 × 0.2 + 0.1 × 0.15 = 0.200 + 0.050 + 0.040 + 0.015 = 0.305
Multiplying by N = 4 gives 1.22, against 1.0 for perfect balance. With α = 0.01 the loss term is 0.0122. Its gradient is largest for expert 1, which has the biggest fᵢ, so the router learns to lower expert 1's probability.
The catch: interference gradients
The auxiliary loss works, but it is a compromise. Its gradient flows into the router alongside the language modelling gradient, and the two can disagree. A large α balances load well but hurts model quality. A small α protects quality but balances poorly. The loss-free balancing paper by Lean Wang, Huazuo Gao, Chenggang Zhao, Xu Sun and Damai Dai (August 2024) calls these "interference gradients" and argues they lower the performance ceiling of MoE training. Our loss functions page covers how combined losses trade off in general.
Loss-free balancing: a bias that only steers
The loss-free method gives each expert a bias bᵢ. The bias is added to the scores only when choosing the top K:
choose expert i if sᵢ + bᵢ is among the top K values of {sⱼ + bⱼ}
but the output weight still uses the original score sᵢ, not sᵢ + bᵢ. The paper is explicit that the bias is "not added to the g_{i,t} that weights the output of the selected experts." So the bias changes who gets the token, never how much that expert's output counts.
After each training step, every bias is nudged according to that expert's load:
bᵢ ← bᵢ + u · sign(c̄ − cᵢ)
where cᵢ is the number of tokens expert i received and c̄ is the average. An overloaded expert has cᵢ above the mean, so its bias falls and it wins fewer future top-K contests. An underloaded expert's bias rises. The biases are not learned by gradient descent, so they add no gradient to the model at all.
Think of a lift dispatcher who, rather than lecturing passengers (a loss), quietly makes the crowded lift look slightly less attractive on the display until queues even out.
The update rate matters
The paper tested three update rates. It reports u = 0.001 as the appropriate choice, with u = 0.0001 converging too slowly and u = 0.01 causing fluctuations later in training. DeepSeek-V4 uses a bias update speed of 0.001.
The paper's results, on validation perplexity and global MaxVio, compare loss-free balancing with an auxiliary loss using α = 0.001:
| Model | Method | Validation perplexity | MaxVio (global) |
|---|---|---|---|
| 1B, 100B tokens | Auxiliary loss | 9.56 | 0.72 |
| 1B, 100B tokens | Loss-free | 9.50 | 0.04 |
| 3B, 200B tokens | Auxiliary loss | 7.97 | 0.52 |
| 3B, 200B tokens | Loss-free | 7.92 | 0.04 |
Quality and balance improve together: the method removes the trade-off rather than tuning it. DeepSeek-V3, the 671 billion parameter model released in December 2024, was described in its report as pioneering this auxiliary-loss-free strategy at scale.
A simulation you can run
The script below routes 2,048 tokens per step to 6 of 64 experts with sigmoid scores. A fixed random preference makes some experts more attractive, standing in for a skewed router. It then applies the bias update with different rates.
import numpy as np
rng = np.random.default_rng(0)
E, K, T = 64, 6, 2048
pref = rng.normal(0, 0.5, E) # some experts favoured
def simulate(u, steps=2000):
b = np.zeros(E); maxvio = []
for _ in range(steps):
s = 1 / (1 + np.exp(-(rng.normal(0, 1, (T, E)) + pref)))
top = np.argpartition(-(s + b), K, axis=1)[:, :K] # bias only for selection
c = np.bincount(top.ravel(), minlength=E)
maxvio.append((c.max() - c.mean()) / c.mean())
b += u * np.sign(c.mean() - c) # loss-free update
return np.array(maxvio)
for u in [0.0, 0.0001, 0.001, 0.01]:
m = simulate(u)
print(u, round(m[0], 2), round(m[-200:].mean(), 3))
In our run, without any balancing (u = 0) MaxVio stayed around 2.3, meaning the busiest expert had about 3.3 times its fair share. With u = 0.001, MaxVio first fell below 0.2 after 114 steps and averaged 0.17 over the last 200 steps. With u = 0.0001 it took 1,050 steps to get there. With u = 0.01 it got there in 46 steps but then hovered higher, around 0.27, because each step overshoots. The remaining 0.17 is mostly sampling noise: with an average of 192 tokens per expert per step, random variation alone produces that spread. The pattern matches what the paper reports for slow, good and jittery update rates.
Continue learning
How this article connects
6 pages link to or from it. Drag to turn, click a dot to open it.
- Tensor parallelism
- The new LLM serving stack: cache-aware routing, continuous batching and
- Kimi K3.1 Pro and ERNIE 5.5 Flash Base: sizing giant open MoE models
- Training at scale: precision, parallelism, memory and scaling laws
- Ant's Ling-3.2-air and LingSante-3.1: open hybrid-linear MoE models for
- DeepSeek in late 2026: V4 Pro, V4.1 Flash, sparse attention kernels and
Why DeepSeek-V4 still keeps a small loss
Loss-free balancing evens out load across a whole batch. It does not guarantee balance within a single sequence. One long document about one topic might send most of its tokens to the same few experts, which can be a problem for inference, where one sequence's tokens may share the same hardware. DeepSeek-V4 therefore adds a sequence-wise balance loss with a tiny weight, 0.0001, as a safeguard against extreme imbalance within one sequence, while the bias does most of the work.
V4 also routes its first three MoE layers by a predefined hash of the token ID instead of a learned router. Hash routing cannot collapse but ignores content; using it only in the earliest layers, where representations are still close to the raw tokens, is a pragmatic compromise.
| Approach | How it balances | Adds gradient to model | Main weakness |
|---|---|---|---|
| Capacity factor | Drops tokens over a hard cap | No | Dropped tokens skip the expert; padding wastes memory |
| Auxiliary loss (Switch) | Penalises α · N · Σ fᵢPᵢ | Yes | Trade-off between balance and quality |
| Loss-free bias | Adjusts bᵢ by u · sign(c̄ − cᵢ) after each step | No | Balances batches, not individual sequences |
| Sequence-wise loss | Small loss per sequence | Yes, but tiny weight | Needs tuning; used as a safeguard |
| Hash routing | Fixed token-ID mapping | No | Ignores content |
What it means in practice
If you train MoE models, load balancing is now mostly a control problem, not a loss-design problem. Track per-expert token counts and MaxVio every step, treat the bias update rate as a key hyperparameter, and log the biases: one that keeps drifting in one direction signals a router that strongly prefers some experts.
If you serve MoE models, balance during training does not guarantee balance during inference: production traffic differs from training data, so experts spread across GPUs can still see hot spots. Expert parallelism also interacts with tensor parallelism and with how you batch requests, which our serving stack article discusses. The broader picture of scaling training is in our training at scale topic.
If you are choosing an open model, the activated parameter count, not the total, drives per-token compute, while the total drives memory. DeepSeek-V4-Flash activates 13 billion of 284 billion parameters, about 4.6%; ERNIE 5.5 Flash Base activates 14 billion of 280 billion, 5%. Both still need memory for every expert.
What to do now
- Log expert load from day one. Record tokens per expert per layer and compute MaxVio at every training step. It is cheap and catches collapse early.
- Prefer loss-free bias balancing for new runs. Start with an update rate of 0.001, the value the original paper recommends and DeepSeek-V4 uses, and check sensitivity on a small model.
- Apply the bias to selection only. Make sure your implementation uses sᵢ + bᵢ to pick experts but sᵢ alone for output weights. Mixing them up changes the model's function.
- Keep a small safeguard loss if sequences matter. If inference runs one long sequence per device, consider a sequence-wise balance loss with a very small weight, as DeepSeek-V4 does.
- Set capacity with headroom, then watch drops. Measure the fraction of dropped tokens. If it is more than negligible, raise the capacity factor or improve balancing rather than accepting silent quality loss.
- Compare scoring functions. The loss-free paper found sigmoid better than softmax in its tests, and V4 moved to √softplus. Test on your own data.
- Consider hash routing for the earliest layers. It removes collapse risk where routing matters least. Measure quality with and without it.
- Measure inference load separately. Replay real traffic through the model and record expert hot spots before deciding how to place experts across GPUs.
Risks and open questions
Batch balance is not sequence balance. The bias method balances totals across a batch. Individual sequences can still concentrate on a few experts, which is why DeepSeek-V4 keeps a small sequence-wise loss.
Theory covers simplified settings. Han and Zhong's guarantees are for a formal assignment model and specific step-size choices. Real training, with changing token representations and huge batches, is messier.
Balanced is not the same as specialised. Even load does not show whether each expert has learned something distinct; balance metrics measure traffic, not usefulness.
Reported results come from the developers. The perplexity and MaxVio numbers are the authors' own experiments at 1 and 3 billion parameters; production models report recipes, not full-scale ablations.
Watch next: whether multi-router designs such as ERNIE 5.5's become common, whether scoring functions beyond sigmoid, such as V4's √softplus, show consistent gains in independent tests, and how expert pruning and FP4 expert weights change the balance between memory, speed and routing quality.
Frequently asked questions
What does a router do in a mixture-of-experts model?
It is a small learned layer that scores every expert for each token and sends the token to the top K experts, often plus one or more shared experts. The chosen experts' outputs are combined with weights based on the scores. Only those experts run, so compute per token is a small fraction of the total parameters.
What is routing collapse?
It is the failure mode where the router sends most tokens to a few experts. Those experts get more updates, improve and attract even more tokens, while the rest go almost unused, so the model behaves like a much smaller one.
How does auxiliary-loss-free load balancing work?
Each expert gets a bias that is added to its score only when choosing the top K experts. After every step, the bias of each overloaded expert is lowered by a small fixed amount and each underloaded expert's bias is raised. Because the biases are not trained by gradient descent and do not change output weights, they balance load without interfering with learning.
What is the capacity factor?
It sets the maximum number of tokens an expert may process in a batch, as a multiple of the average. With 4,096 tokens, 64 experts and top-6 routing, the average is 384 tokens, and a capacity factor of 1.25 allows 480. Tokens beyond the cap skip that expert, so good balancing keeps drops rare.
Why do models like DeepSeek-V4 use shared experts?
A shared expert processes every token, so it can hold general knowledge that all tokens need. That frees the routed experts to specialise instead of each storing the same common patterns. DeepSeek-V4 and ERNIE 5.5 Flash Base both use one shared expert per MoE layer alongside their routed experts.
Summary
A mixture-of-experts layer only pays off if its router spreads tokens evenly. Routers naturally drift towards a few favourite experts, which wastes hardware and can collapse the model into using a fraction of its parameters. The Switch Transformer's auxiliary loss, α · N · Σ fᵢPᵢ, fixes this at the price of gradients that fight the language modelling objective, and capacity limits cap the damage by dropping overflow tokens. Loss-free balancing replaces the loss with a per-expert bias that only affects selection and is nudged by u · sign(c̄ − cᵢ) after each step. In its paper it improved both perplexity and MaxVio, and DeepSeek-V3, DeepSeek-V4 and ERNIE 5.5 Flash Base all describe using it, with V4 adding a tiny sequence-wise loss and hash routing in early layers. If you train or serve MoE models, log expert load, tune the bias update rate, and test balance on real traffic.
Sources
- Paper arXiv: Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity
- Paper arXiv: Auxiliary-Loss-Free Load Balancing Strategy for Mixture-of-Experts
- Paper arXiv: DeepSeek-V3 Technical Report
- Paper arXiv: DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence
- Paper arXiv: A Theoretical Framework for Auxiliary-Loss-Free Load Balancing of Sparse Mixture-of-Experts
- Code Hugging Face: baidu/ERNIE-5.5-Flash-Base model card
Cite this article
Kelahmet, Ö. C. (2026, November 24). MoE routing explained: top-k gates, load balancing losses and loss-free bias updates. Özer Cem KELAHMET. https://www.ozercemkelahmet.com/articles/moe-routing-load-balancing-bias
BibTeX
@online{kelahmet2026routing,
author = {Kelahmet, {\"O}zer Cem},
title = {{MoE routing explained: top-k gates, load balancing losses and loss-free bias updates}},
year = {2026},
month = {nov},
url = {https://www.ozercemkelahmet.com/articles/moe-routing-load-balancing-bias}
}Version historyfirst version
- Published
Factual corrections are listed here with what changed. Wording and formatting edits are not listed.