6.1.6 · D3Scaling & Efficient Architectures

Worked examples — Load balancing in MoE

2,421 words11 min readBack to topic

This is the worked-example companion to the parent note on load balancing. There we derived the Switch Transformer auxiliary loss

and explained why only the routing probability carries gradients while the dispatch fraction is a frozen constant. Here we run the machinery on every kind of input it will ever meet — balanced, collapsed, degenerate, over-capacity, and a couple of exam traps — so no scenario surprises you.

Recall Symbols we will reuse (all built in the parent, restated here)

::: number of experts. ::: number of tokens in the batch. ::: how many experts each token is routed to (Top-). ::: fraction of tokens actually dispatched to expert ; a hard count, so . Non-differentiable (frozen constant in backprop). ::: average softmax routing probability the router gives expert ; differentiable, and . ::: strength knob on the auxiliary loss (typically ). ::: capacity factor; expert capacity tokens.

Before any numbers, one picture of what the loss actually measures so every example lands on the same mental image.

Figure — Load balancing in MoE

The scenario matrix

Every situation this topic can throw at you falls into one of these cells. The examples below are labelled with the cell(s) they cover — together they fill the whole table.

Cell Scenario class What is stressed Example
A Perfectly balanced, , The fixed-point value Ex 1
B Fully collapsed, one expert takes almost all Upper end of the loss Ex 2
C Top- with bookkeeping Ex 3
D Degenerate: for a dead expert A zero factor kills its term Ex 4
E Gradient sign — which goes up vs down The feedback controller in action Ex 5
F Capacity + token dropping Hard constraint, dropped-token count Ex 6
G Real-world word problem (the chef restaurant) Translating words → Ex 7
H Exam twist: the "double-" trap Total-loss composition Ex 8


Recall Rapid self-test

Balanced fixed-point loss for , any , ? ::: (independent of ). With Top-2, what does equal? ::: , not 1. Gradient on from the aux loss? ::: — proportional to current load. Does a dead expert () get a balancing gradient? ::: No — its gradient is ; it is rescued indirectly via softmax renormalization. Expert capacity with , , ? ::: tokens per expert.

Related deep dives: Top-K Routing in MoE, GShard, MoE Training Dynamics, Gradient Routing in MoE, Mixture of Experts (MoE) Architecture.