The idea, explained

A dense neural network uses the same layer parameters for every input. A mixture-of-experts, or MoE, layer instead contains several expert subnetworks and a router. For each token, the router produces affinity scores, converts them into probabilities and selects the highest-scoring expert or small group of experts. The chosen outputs are then passed onward through the model.

This separates total parameters from active parameters. A model may store many expert weights, giving it more representational capacity, while using only one or two experts per token. That can keep arithmetic per token closer to a much smaller dense model. It does not make computation free: experts may live on different accelerators, so routing creates communication, memory and coordination costs.

Capacity is a central constraint. In Switch-style routing, each expert receives a fixed token buffer. A common formula is expert capacity = tokens in the batch divided by number of experts, multiplied by a capacity factor. The capacity factor adds headroom because routing is rarely perfectly balanced. More headroom reduces overflow but reserves more memory and computation.

Load imbalance occurs when too many tokens choose the same expert while others sit underused. Overflowing tokens may be dropped, rerouted or handled by another mechanism, depending on the implementation. Training commonly uses balancing objectives or alternative routing designs. Google’s expert-choice method reverses the assignment: experts select tokens up to a fixed capacity, improving balance in its reported experiments. These are engineering trade-offs, not proof that every expert learns a clear human-readable specialty.

Follow a worked example.

Suppose one training batch contains 4,096 tokens and the MoE layer has 8 experts. With a capacity factor of 1.25, each expert receives:

4,096 divided by 8 = 512 average tokens per expert.

512 multiplied by 1.25 = 640 token slots per expert.

Across all experts, the layer reserves 8 multiplied by 640 = 5,120 slots. That is 1,024 slots above the 4,096-token batch, or 25% headroom. If routing were perfectly even, every expert would process 512 tokens and 128 slots per expert would remain unused.

Now assume Expert 3 attracts 700 tokens. Its buffer holds 640, so 60 tokens overflow. Raising the capacity factor to 1.5 would provide 512 multiplied by 1.5 = 768 slots per expert and prevent that particular overflow, but total reserved capacity would rise to 6,144 slots. The team should not choose 1.5 merely because it avoids one overflow. It should compare overflow rate, model quality, accelerator memory, communication time and cost across representative batches. The result illustrates the MoE trade-off: sparse activation saves arithmetic relative to running every expert, while uneven routing can waste capacity or lose work.

Where people get stuck

A common misconception is that a model with ten times more total parameters must require ten times more computation for every token. In a sparse MoE, only selected experts are active, so total and active parameters differ. The opposite misconception is also wrong: inactive experts still occupy storage, and dispatching tokens across devices can be expensive. Another pitfall is assuming that expert labels such as “math expert” or “language expert” are guaranteed. Routing patterns emerge from training and may be unstable or difficult to interpret. Evaluate the complete system, including quality, overflow, balance, latency and hardware utilization.

Now try it yourself.

Pause before opening each answer. Explain your reasoning in your own words.

1. Check the core idea

A batch has 2,400 tokens, 12 experts and a capacity factor of 1.2. What is the capacity per expert, and what does it mean if one expert receives 255 tokens?

Reveal the answer & reasoning

The even-share average is 2,400 divided by 12 = 200 tokens. Multiplying by the 1.2 capacity factor gives 240 slots per expert. An expert receiving 255 tokens exceeds its buffer by 15 tokens. Those 15 tokens must be dropped, rerouted or otherwise handled according to the implementation. The observation also signals load imbalance. Increasing capacity could reduce overflow, but the team should first measure how often it happens and weigh added memory and communication costs against quality effects.

Why this was added

The library explains Transformers and model compression but not sparse expert routing, active versus total parameters, capacity factors or load imbalance.