Back to blog
ai-engineering

Mixture-of-Experts training, explained with live figures

Five ideas behind Mixture-of-Experts training, each with a figure you can move: routers, load balance, and why an uneven router makes training slow.

HA

November 11, 2026

10 min read

Mixture-of-Experts training, explained with live figures

On 5 November 2026 three engineers at Hugging Face published The Ultimate MoE Training Handbook. It is the best single document we know on training Mixture-of-Experts models, and by its own estimate it takes one to two days to read.

This post is the short version: about ten minutes of reading, plus whatever time you spend playing with the figures. It covers the five ideas you need before the handbook makes sense, and each one comes with a figure you can move. We have not trained a Mixture-of-Experts model ourselves. Every training result quoted here is the handbook's, or a paper it cites, and is marked as such. Every figure is a simulation or plain arithmetic, and says so underneath. Where our own measurements touch the subject, we say that too.

The machine: one training step

Before the model, the machine. A large model does not fit on one GPU, so it is cut into stages, and each stage runs on its own group of GPUs. A batch passes forward through every stage, then its gradients pass back. The figure plays one such step. Open the schedule to scrub through it, click a board to inspect a node, or build the whole thing up from a single GPU.

An interactive simulation of one training step on four pipeline stages of 64 nodes each. Micro-batches pass forward through the stages and their gradients pass back, following a standard one-forward-one-backward schedule, and the step ends with a gradient sync.

One training step across four pipeline stages

1. A model that holds more than it uses

A normal transformer layer sends every token through the same feed-forward block. A Mixture-of-Experts layer replaces that block with many smaller ones, called experts, and a small router that picks a few of them for each token. The token only pays for the experts it uses. The model keeps all of them in memory.

The handbook's example makes the trade concrete. Its dense baseline has about 1.22 billion parameters. Its small MoE swaps each feed-forward block for 64 experts and uses 8 per token. That model holds 6.86 billion parameters, about 5.6 times as many, yet each token still passes through about 1.22 billion of them.

Move the sliders to see where that ratio comes from.

An interactive figure. With 64 experts and 8 used per token, one layer holds 8 times the parameters a single token uses: 402.7 million held, 50.3 million used.

One layer: what it holds against what a token uses

The compute per token stays flat while the knowledge the model can store grows. That is the whole appeal, and it is why most of the strongest open models are now built this way. The handbook counts 18 of the 20 highest-scoring open-weights models on the Artificial Analysis index as mixtures of experts.

The catch is in the handbook's own words about that saving: turning it into faster training is the hard part. The rest of this post is about why.

2. The router: scores in, weights out

For every token, the router produces one score per expert. Two things then happen. The top few experts are kept, and their scores are turned into weights that say how much each expert's answer counts.

There are three common ways to turn scores into weights: softmax, sigmoid, and the square root of softplus. Labs disagree on which to use. The handbook's table of ten current open models shows all three in production.

The figure shows why that disagreement matters less than it seems.

An interactive figure. Softmax, sigmoid and the square root of softplus keep the same top experts for a given set of scores and only change the weights among them.

Three ways to turn router scores into weights

Three things to try:

  • Change the function. The same experts stay red in every row. The function changes how the work is shared among the winners. It does not change who wins.
  • Raise the sharpness. The top expert takes almost everything. A router this sure of itself is effectively using one expert, whatever top-k says.
  • Turn off renormalising. The kept weights no longer add up to one, so the layer's output shrinks or grows with the router's confidence. The handbook reports that renormalising lowered the loss in the study it cites.

One setting is not a matter of taste. A router computed in 16-bit precision can round two close scores to the same value and pick a different winner. The handbook's advice is to always compute the router in 32-bit, and it cites Switch Transformers, where a 16-bit router diverged and a 32-bit one trained at the same speed.

3. The problem: routers play favourites

Nothing forces a router to spread tokens evenly. Left alone, it finds a few experts that work well early on and keeps sending them more. Those experts get more training, so they get better, so they get even more tokens.

The standard measure of this is MaxVio, short for maximal violation: how far the busiest expert's load sits above the even share, divided by the even share. Zero is perfectly even. One means the busiest expert gets twice its share.

An animated simulation. As the router grows more confident, tokens pile onto a few of the 16 experts and MaxVio rises.

Tokens routed across 16 experts

Raise the router's confidence and watch MaxVio climb while half the experts sit almost idle. Those idle experts are parameters you paid for in memory and are not training.

That would be a quality problem on its own. In training on many GPUs it is also a speed problem, and that part surprised us most.

4. Why an uneven router is a slow router

During training, the experts are spread across GPUs. Every step, each token is shipped to the GPUs that hold its experts, processed, and shipped back. A step is not finished until every GPU is finished.

The figure plays one training step on a cluster of 64 nodes. Drag the timeline to move through the step, click a node to look at its four GPUs, and change the two settings to see what each one costs.

An interactive simulation of one training step on 64 nodes with 4 GPUs each: tokens are routed, sent to the GPUs holding their experts, processed, and returned. Uneven routing makes a few GPUs work long after the rest have finished, and spreading experts across nodes sends tokens over the network.

One training step on a cluster of 64 nodes

The switch between "inside each node" and "across all nodes" is a real choice you make when you set up a run. The handbook's advice is to keep the experts inside one node when the model fits that way, because GPUs in a node are linked far faster than nodes are linked to each other. In its own test, spreading the experts over two nodes ran 59% below keeping them in one, though it notes the two runs differed in other ways too.

The unevenness slider is the part no placement fixes. Push it up and watch the experts' phase: a few GPUs are still working long after the rest have finished. The GPU that happens to hold the popular experts sets the pace, and every other GPU waits for it.

An interactive model. Eight GPUs share the tokens; the step ends when the busiest GPU finishes, so uneven routing leaves the others idle.

The busiest GPU sets the step time

The handbook measured this directly on its own run, by forcing the routing instead of learning it:

  • With routing forced perfectly even, the run reached 149.4 TFLOP/s.
  • With routing forced as uneven as it would go, it fell to 100.5 TFLOP/s, about a third lower.
  • A freshly initialised learned router started near that worst case. With the standard balancing loss it had climbed back to 125 TFLOP/s by the end of 120 iterations.

In a profile of another of its runs, forcing even routing made the same training step 40% faster. Those are the handbook's numbers on its hardware, not ours. The lesson travels: on a new MoE run, check the balance before you tune anything else.

5. Pushing the load back

There are two main ways to make a router share.

An auxiliary loss adds a penalty to training whenever the load is uneven. It works, but it pulls the router away from what the language-modelling loss wants, so its strength is a trade. The handbook starts at a coefficient of 1e-3. In the study it cites on a 1-billion-parameter model with 64 experts, that setting gave a MaxVio of 0.72. With no auxiliary loss at all, MaxVio was about 5.1. Turning the loss up to 1e-2 brought MaxVio down to about 0.1, and raised perplexity from 9.56 to about 9.69, so the model got worse at its actual job.

A loss-free bias leaves the training signal alone. Each expert gets a small number added to its score, raised when the expert is under-used and lowered when it is over-used. In the same study this reached a MaxVio of 0.04 with slightly better quality than the auxiliary loss. It has limits too: the handbook reports it hurting quality above 128 experts, and balancing far worse than an auxiliary loss at 1,024.

The figure below is a toy version of that dial for one layer of 64 experts. Drag it to turn it.

A 3D simulation. Sixty-four experts shown as bars whose height is their share of tokens; raising the balance pressure evens them out and lowers MaxVio.

Load across 64 experts, in 3D

The real choice is not "balanced or not". It is how much quality you will give up for how much speed, and the only way to know is to watch both numbers together.

Where our own work meets this

We said at the top that we have not trained an MoE. There is one place the handbook lands on ground we have measured.

Splitting a layer into more, smaller experts helps quality up to a point. The handbook's advice is to stop going finer once small matrix multiplications and token copies start to dominate the step. Small matrix multiplications are exactly where GPU maths libraries are weakest, because they are tuned for large ones.

We have spent months on that problem on AMD's MI250X, and wrote up one result in MI250X GEMM: a 128-byte offset beats hipBLASLt on 8 shapes. We have not tested those shapes inside an MoE layer, so we make no claim about MoE training speed on that hardware. It is the experiment we would run next.

What to do with this

  • Compute the router in 32-bit precision. This is the one setting the handbook says to always use.
  • Log tokens per expert per layer from the first step, and read it as MaxVio.
  • Check balance before tuning speed. An uneven router can hide a large share of your throughput.
  • Start with an auxiliary loss of 1e-3, then watch the language-modelling loss and MaxVio together.
  • Then read the handbook. It covers what this post leaves out: expert sizing, block layout, optimisers, memory, precision and serving.

Sources

Tags

model-trainingllm-opsperformance
HA

About the author

Hamza Abdagić

View profile