Skip to content

A mixture-of-experts router needs a load-balancing loss

2026-11-09

A mixture-of-experts layer sends each token to a few of its experts instead of all of them. A small learned router decides which. The Switch Transformer simplifies this to one expert per token: the router's softmax gives a probability for each of the N experts, and the token goes to the largest.

Left alone, this can collapse. An expert that does well early receives more tokens, trains more, and does better still, while the others starve. Each expert also has a fixed capacity per batch, and tokens beyond it are dropped, passing on through the residual connection.

The fix is an auxiliary loss, added to the training loss. Let fᵢ be the fraction of tokens in the batch sent to expert i, and Pᵢ the average router probability for expert i. The loss is α·N·Σᵢ fᵢ·Pᵢ. When both are uniform, at 1/N each, the loss equals α, and the paper uses the term to encourage balanced routing. It is a nudge, not a guarantee: for some router outputs a lopsided assignment scores below α. With two tokens whose probabilities are (0.51, 0.001, 0.489) and (0.001, 0.51, 0.489), the loss is 0.7665 α. The paper uses α = 0.01 after trying values from 0.1 to 0.00001.

Why both factors? fᵢ counts which expert won each token, which has no gradient. Pᵢ is smooth, so the loss can push the router's probabilities toward balance.

The paper reports up to 7 times faster pre-training than T5-Base at the same compute per token.

Fedus, Zoph and Shazeer, JMLR 2022, §2.1, §2.2 (Eqs. 4 to 6) and §3.1