1. More capacity, without running every branch
Increasing a model's parameter capacity can improve its performance when paired with suitable data and training. But storing and evaluating a larger model also introduces costs. More parameters do not automatically mean better answers, and latency does not follow parameter count by a universal fixed ratio.
A dense Transformer normally applies the same attention and feed-forward sublayers at each position. Can we provide several alternative feed-forward networks while executing only a few for each token?
That is the central idea of a sparsely activated mixture of experts, or MoE. The model stores multiple expert networks and routes each token representation to a selected subset.
2. Why replace the feed-forward network?
For a conventional block with model width , full-width query, key, value and output projections contain approximately attention parameters, ignoring biases.
A non-gated FFN with width contains approximately:
Within that simplified block, the FFN accounts for:
of the attention-plus-FFN weights. This is a useful example, not a universal ratio. Gated FFNs, different hidden widths, shared key/value heads and other architecture choices change the counts.
A typical sparse MoE replaces an FFN with multiple expert FFNs plus a router. Attention and other parts of the block remain shared. Some architectures use MoE only in selected layers, or combine routed and shared experts.
FFNs contribute to learned associations, but describing them as the model's only “knowledge warehouse” is too literal. Information and computation are distributed across embeddings, attention, experts and the rest of the network.
3. Route each token to selected experts
For a contextual representation , a simple router calculates logits and probabilities :
Select a set containing the top experts. In the convention used in our example, renormalise the selected probabilities:
The expert outputs are combined as:
Contextual token representation x → router scores → select experts
Expert 1
selected
Expert 2
not selected
Expert 3
selected
Expert 4
not selected
Combine selected outputs → residual stream
For logits , top-two routing selects experts 1 and 3. Their renormalised weights are approximately and .
The full four-way Softmax probabilities are different from those two selected weights. Selecting and then normalising must not be confused with simply reporting the original probabilities.
Expert 1 · selected
Logit 3.10 · full Softmax 62.99% · selected weight 0.6682
Fixed output: [1, 0]
Expert 2 · inactive for this input
Logit 0.50 · full Softmax 4.68% · selected weight 0.0000
Fixed output: [0, 1]
Expert 3 · selected
Logit 2.40 · full Softmax 31.28% · selected weight 0.3318
Fixed output: [2, 1]
Expert 4 · inactive for this input
Logit -1.00 · full Softmax 1.04% · selected weight 0.0000
Fixed output: [-1, 2]
Combined output: [1.3318, 0.3318]
Hand-picked logits and expert outputs, not a trained model. We renormalise selected probabilities; ties favour the lower expert index. Choosing all four experts removes sparse expert selection in this example.
The expert output vectors in this experiment are fixed by hand. Changing the preset changes the example logits, not the behaviour of a trained FFN. The experiment is designed to make selection and weighted addition inspectable.
Routing conventions vary. Some designs use top-one routing, retain different gate normalisations or use other assignment rules. Top-k membership is discrete, so training a router is not simply taking an ordinary derivative through the index-selection operation. Gate values, auxiliary objectives and architecture-specific training methods provide learning signals.
Routing is usually computed per token representation and per MoE layer, rather than choosing one expert pair for an entire conversation. Different layers can route the same token differently.
The analogy with multi-head attention has limits: standard attention heads normally all run, while sparse MoE deliberately skips unselected expert computation.
4. Count total parameters and active work separately
Let denote shared weights, the weights in one expert and the router weights. With stored experts and selected experts per token:
The active count includes the router because it still scores all experts in this example. Other designs may organise routing differently.
Shared attention weights: 1,048,576
Weights per expert: 2,097,152
Router weights: 4,096
Total block weights: 17,829,888
Active block weights per token: 5,246,976
Dense baseline block: 3,145,728
Total / dense baseline: 5.668× · active / dense baseline: 1.668×
Model width 512; each expert uses a non-gated 512 → 2048 → 512 FFN. Counts include a 512 × N router and standard full-width attention projections, but omit biases, normalisation, embeddings and other layers. Active weight count is not measured FLOPs, memory traffic or latency.
Adding experts while holding fixed increases stored capacity much more than selected expert work. But selecting two experts of the same size also performs approximately twice the expert FFN work of selecting one. It is not automatically the same compute as the original single-FFN block.
Mixtral 8×7B is a published example with eight experts per layer and two selected for each token. Its paper reports approximately 47 billion total parameters and 13 billion active parameters per token. The name does not mean eight independent seven-billion-parameter models: shared attention and other shared components are counted once.
These counts illustrate sparse activation; they are not interchangeable with measured FLOPs, GPU memory traffic, latency or quality. Actual speed depends on batching, hardware, expert placement and implementation.
A model with more experts can gain capacity, but the amount of usable knowledge and performance cannot be read directly from its total parameter count. Training data, expert utilisation and optimisation remain important.
5. Load balance, capacity and communication
Experts do not come with assigned professions
An expert is a learned neural subnetwork, not a separately prompted person or agent. Labels such as “law expert”, “coding expert” and “poetry expert” can be misleading if presented as facts about its learned role.
Routing can correlate with token forms, syntax, language or other features. Useful specialisation can emerge, but it need not match a neat human-readable topic label, and it should be investigated rather than assumed.
Uneven routing wastes capacity
If most tokens are sent to one expert, that expert becomes a bottleneck while others receive less work. Training often includes load-balancing mechanisms, but the exact method varies; an auxiliary loss is not the only possible approach.
Even top-one assignment
Expert 1: 3 assignments
Expert 2: 3 assignments
Expert 3: 3 assignments
Expert 4: 3 assignments
Skewed top-one assignment
Expert 1: 9 assignments
Expert 2: 1 assignments
Expert 3: 1 assignments
Expert 4: 1 assignments
Some implementations impose a per-expert capacity on token assignments. Overflow assignments may be dropped, rerouted or handled using a different policy. In a dropped-branch scheme, a residual path can carry the representation onwards; it does not mean the token is deleted from the sequence. Dropless implementations make different memory and execution trade-offs.
A schematic training objective can include an auxiliary term:
Its detailed definition depends on the model. Balancing utilisation is an engineering and optimisation goal, not a guarantee that all experts will learn distinct useful functions.
Sparse execution still needs stored weights
An expert that is inactive for the current token does not disappear from the model. Serving systems must make the full set of required weights available, often sharded across accelerators. Offloading or fetching weights on demand can reduce resident accelerator memory at a transfer and latency cost; it is too strong to say every expert must always reside on one GPU.
When experts are distributed, dispatching token representations and returning expert outputs requires communication. This can offset arithmetic savings, particularly with small batches or uneven loads. Packing work efficiently and balancing compute with network traffic are part of making sparse activation useful in practice.
6. What you have discovered
- Sparse MoE commonly replaces an FFN with several expert networks and a learned router.
- The router selects experts for each contextual token representation; selected outputs are combined using architecture-specific gate weights.
- Total stored capacity and per-token active work are different quantities.
- More experts at fixed selection count do not promise fixed latency, automatic quality gains or lower memory requirements.
- Load balance, assignment capacity and distributed communication are central practical constraints.
Next, we will study model distillation: how a student can learn from a teacher's outputs or distributions, and what can be retained or lost when reducing the deployed model.