A mixture-of-experts (MoE) model holds far more parameters than it uses. In Mistral AI’s Mixtral 8x7B, each feed-forward block contains eight expert networks and a router selects two per token, so only part of the model contributes to any forward pass. You get the capacity of a large model at compute closer to a much smaller one.
The routing arithmetic is simple; the engineering is not. Routers drift towards favourites, buffers overflow and drop tokens, and on multi-GPU clusters tokens must cross the network to reach their experts. A badly tuned MoE layer can be slower than the dense layer it replaced. This article covers the mechanics, the failure modes, and what they mean for your own training or fine-tuning.
What changes inside the transformer block
In a dense transformer, every token passes through the whole feed-forward network on every layer. That cost scales with parameter count, so dense scaling eventually becomes unaffordable.
An MoE layer keeps attention shared but replaces the feed-forward network with parallel ones. For each token:
- attention runs as usual, producing a token representation;
- a small router network scores that representation against every expert;
- the top-k experts run on the token;
- their outputs are combined using the router’s weights.
The value of k has shifted over time. GShard used top-2 routing over as many as 2,048 experts per layer, while Mixtral 8x7B used top-2 over just eight large ones. Recent DeepSeek models instead use many smaller, fine-grained experts and activate more per token. According to DeepSeek’s technical reports, DeepSeek-V3 (December 2024) activates 8 of 256 routed experts plus one shared expert, and DeepSeek-V4-Flash (April 2026) activates 6 of 256 routed experts plus one shared expert. Its successor, DeepSeek-V4.1-Flash, released in September 2026, has 384 routed experts plus one shared expert, still with six routed experts active per token.
This is conditional compute: the path depends on the input. The model can learn that certain experts handle code-like tokens and others domain-specific text, without that split being specified.
Inside the router
The router is usually a linear projection from the token representation to one score per expert. The classic gate, used in the sparsely-gated layer of Shazeer et al. (2017), the Switch Transformer and Mixtral, turns those scores into a softmax distribution over experts. DeepSeek has moved away from it: DeepSeek-V3 computes expert affinities with a sigmoid and normalises only the scores of the selected experts, and DeepSeek-V4 replaces the sigmoid with a Sqrt(Softplus) function. In every case the top-k experts’ outputs are mixed by their normalised weights, for example 0.6 of one plus 0.4 of another.
Because gate weights multiply the expert outputs, gradients flow back into the router as well as the selected experts. The top-k selection itself remains a hard, non-differentiable choice: in Shazeer et al. (2017), logits outside the top k are masked out before the softmax, so an expert that narrowly missed selection receives no gradient from that token. Top-k gating stays trainable because the router learns through the weights of the experts it picked, while noise and balancing terms keep the others in play.
Why routers collapse
Left alone, a router develops favourites: an expert that gets slightly more traffic early improves faster, attracting more traffic. A few experts absorb most tokens, and the rest become dead parameters: memory and optimiser state contributing nothing.
Collapse hurts quality, because effective capacity shrinks towards a small dense network. It hurts throughput, because the GPU hosting the popular expert does most of the work while peers idle, and step time is set by the slowest device.
The classic remedy is an auxiliary load-balancing loss, as used in GShard (Lepikhin et al., 2020) and the Switch Transformer (Fedus et al., 2021). The Switch version combines two quantities per expert over a batch: the fraction of tokens actually dispatched to it and the total router probability mass assigned to it. Their product, summed across experts, is a penalty that grows when one expert dominates both, pushing the router back towards an even spread. Some designs also add noise to router logits during training to encourage exploration, as in Shazeer et al.’s (2017) noisy top-k gating.
DeepSeek argues that a strong auxiliary loss can degrade model quality, and with DeepSeek-V3 (December 2024) it moved to auxiliary-loss-free balancing. A per-expert bias, used only for selection rather than output weighting, is added to routing scores and lowered for overloaded experts and raised for underloaded ones during training. Only a very small sequence-wise balance loss remains as a complement, and DeepSeek reports that V3 drops no tokens during training. DeepSeek-V4 (April 2026) keeps this approach. The latest refinement, described in the DeepSeek-V4.1-Flash technical report (arXiv 2609.19969, 17 September 2026), makes balancing modality-specific: text and image tokens each have their own correction biases, updated from their own expert loads, and the small sequence-level balance loss is retained.
Capacity, overflow and the three bad options
Experts often run as batched matrix multiplications, so each needs a fixed buffer per step, derived from the capacity factor:
capacity = (tokens per batch x top-k x capacity factor) / number of experts
With 2,048 tokens, eight experts, top-2 routing and a capacity factor of 1.25, the expected load is 2,048 x 2 / 8 = 512 tokens per expert, and the buffer is 512 x 1.25 = 640, a 25% margin for uneven batches.
When a hot expert exceeds its buffer, you must choose how to pay:
- Drop the overflow. Fastest; the token skips that expert and loses signal.
- Reroute to a backup expert. Keeps the token, but dilutes specialisation and adds coordination work.
- Go dropless. Let each expert process a variable number of tokens using block-sparse or grouped kernels, as in the dropless MoE of MegaBlocks (Gale et al., 2022); no tokens are lost, at the cost of more complex kernels and less predictable memory and latency.
Capacity factor trades memory against quality: too low drops tokens constantly; too high wastes sparsity’s memory advantage on unfilled buffers. Good balancing eases all three, because fewer experts overflow.
All-to-all: when the network sets your step time
At scale, experts are spread across devices, so routing becomes data movement. Each GPU ships tokens to the devices holding the chosen experts and receives results back: an all-to-all exchange for dispatch and another for combining, in every MoE layer, repeated in the backward pass during training.
First, load imbalance becomes a wall-clock problem: if one device is overloaded, every other device waits. Second, interconnect bandwidth becomes a first-class constraint. On well-connected nodes the exchange can hide behind compute; across slower links it can dominate the layer; activating more fine-grained experts per token raises the stakes, since each token may reach more devices. So sparse models are not automatically faster than dense ones, and reported speed-ups depend on batch size, sequence length and hardware topology.
What to monitor, and when to prefer dense
Key health signals for an MoE layer:
- Expert utilisation: tokens per expert across a batch.
- Overflow rate: how often capacity is hit and tokens dropped or rerouted.
- Router entropy: falling steadily towards zero means collapse is underway.
- Dispatch time: the share of step time spent in all-to-all rather than compute.
- Balancing signal: an auxiliary loss plateauing high, or routing biases that keep drifting, means the router is not settling.
DeepSeek’s MoE models since V2 combine shared experts that process every token with a larger pool of routed experts selected per token, so common work is handled by always-on parameters and routing wobble does less damage. Sparse layers are worth the complexity when the model is large, the data is diverse and throughput matters more than per-request latency. For smaller models, tight latency budgets, limited interconnect bandwidth or small teams, a dense model remains the sensible default: fewer moving parts, no dispatch overhead, predictable memory.
What this means for organisations training on their own data and hardware
Treat an MoE architecture as an infrastructure decision as much as a modelling one. Budget for the memory expert buffers and optimiser state require, measure dispatch cost on your actual interconnect before committing, and instrument routing from the first run. Sparse parameters only become cheaper parameters when the router stays balanced and the network keeps up. The same applies at inference, where expert placement interacts with batching and memory questions covered in serving LLMs on your own GPUs and with the trade-offs discussed in LLM quantization.
AMD Telecom trains and fine-tunes deep-learning models and large language models on its own in-house GPUs, and its BigParser platform turns web content and documents into structured training data. That data matters for sparse models too, since routers learn their specialisation from the distribution they are fed.
If you are planning a project of this kind, our AI Model Training and AI Model Development services cover architecture selection, training infrastructure and evaluation. Contact us to discuss your requirements.
