Same parameters, same compute — carved into sharper specialists.
Mixture-of-Experts is the trick that lets a language model store far
more parameters than it runs: each token is sent to a couple of
expert networks out of many, so capacity grows while per-token
compute stays flat. But the standard recipe of the time — GShard-style
top-2 routing over 8 or 16 experts — had a quiet flaw.
With so few experts, each one is forced to absorb a grab-bag of
unrelated knowledge, and all of them end up re-learning the same
common patterns. The paper names the two failure modes
knowledge hybridity and knowledge redundancy, and
argues they are what keeps MoE models below their potential.
DeepSeekMoE's bet: the missing ingredient is not more capacity but
specialization. Two structural edits deliver it. Cut each
expert into m smaller ones and activate m×
more of them — parameters and compute stay exactly the same, but the
number of possible expert combinations explodes. Then set aside a few
shared experts that every token visits, so common knowledge
has one home and the routed experts can stop hoarding the basics.
A 2B model built this way matches a GShard model with 1.5× its
expert parameters; at 16B it holds even with LLaMA2 7B on roughly
40% of the compute.
Don't buy more experts. Cut the ones you have into specialists — and give common knowledge a permanent desk.
The machine and its leaks
What a mixture-of-experts layer is — and where the classic recipe wastes it.
Step 1 · The black box
A model that stores 16.4B parameters but runs 2.8B per token.
From the outside, DeepSeekMoE 16B looks like any language model you already know: text goes in, the next token comes out, and inside sit 28 stacked Transformer blocks, each one an attention module followed by a feed-forward network (FFN — the two-matrix multiply that holds most of a block's parameters). The strange part is the bookkeeping. The model stores 16.4 billion parameters, yet any single token flows through only about 2.8 billion of them.
Let's give the box something concrete to chew on. Our working sentence for the whole page is "The enzyme speeds up digestion." — and our working token is enzyme, the kind of word that needs real biology knowledge, not just grammar. In the figure, the darker outline marks the enzyme chip; watch for that same chip in every diagram that follows.
How can 14 billion parameters sit idle on every token without being wasted? That's the whole subject of this page. The mechanism is called Mixture-of-Experts (MoE): in almost every block, the single FFN is replaced by a bank of many FFNs — the experts — plus a tiny router that picks which few of them run for each token. Different tokens wake different experts, so all the parameters earn their keep across a corpus even though each token pays for only a slice.
The payoff shows up in the compute bill. Per 4K tokens, DeepSeekMoE 16B costs 74.4T FLOPs where LLaMA2 7B — a dense model it matches on benchmarks — costs 187.9T. Same class of quality, 39.6% of the arithmetic. Holding onto why that's possible, and what the 2021-era version of the idea got wrong, is where we go next.
Simplification up front: we ignore layer normalization in every formula on this page — the paper does the same for brevity (§2) — and attention is untouched throughout; MoE only replaces the FFNs. One more wrinkle for later: in the 16B model the very first block keeps a plain dense FFN.
Step 2 · Inside one MoE layer
The router scores every expert with one dot product — the top 2 run.
Step 1 promised that a token pays for 2 experts while 16 sit on the shelf. The device that makes the choice — the router — is small enough to compute by hand, so let's do exactly that.
Here is the machine as it existed before this paper: the
GShard-style MoE layer of 2021, the baseline DeepSeekMoE starts
from. Enzyme arrives at the layer as a hidden vector
u (the running summary of the token after attention).
Every expert i owns a learned vector ei
called its centroid — think of it as the
expert's business card, pointing at the region of meaning-space it
claims. Routing is three cheap moves:
Dot, squash, keep two. Take the dot product
u·ei with all 16 centroids (how aligned is
this token with each expert's specialty?), push the 16 scores
through a softmax (exponentiate and
normalize, so they become positive and sum to 1), and keep only the
top 2. Those two scores become gate values — mixing weights
— and everyone else's gate is 0, which is precisely why 14 experts
cost nothing. In the figure below, follow enzyme's vector up
through the router: the two teal boxes are the winners, and their
outputs are blended by the gates before rejoining the residual
stream.
Drag the meaning dial — watch the router re-vote
A real centroid lives in 2,048 dimensions. To make the arithmetic
visible we shrink the world to 2 dimensions and 4 experts with
human-readable specialties. The token is
u = [x, 1.0], where x is a "meaning
dial": positive leans biology, negative leans code. Every number
below is genuinely computed — dot products, softmax, gates.
h = 0.59·FFNbiology(u) + 0.29·FFNsyntax(u) + u
Centroids: biology [1.0, 0.2] · syntax [0.3, 0.6] · code [−0.5, 0.9] · math [−0.8, −0.4]. What to notice: the winners' gates are the raw softmax scores — 0.59 + 0.29 ≈ 0.87, and the paper leaves them un-renormalized (eq. 5). Around x ≈ 0.5 the vote flips: a token can be genuinely torn between specialties.
h =Σi gi· FFNi(u) + u
gi = si if si ∈ top-K, else 0 · si = softmaxi(u·ei) — eqs. (3)–(5)
That one line is the whole layer: the three moves you just did on the dial, written compactly. Since only K gates are nonzero, only K experts ever compute — sparsity is enforced by the gate, not by any special hardware trick.
The labelled centroids are our cartoon: real centroids are learned 2,048-dimensional vectors, and what an expert actually specializes in is emergent — nobody stamps "biology" on expert 3. The routing arithmetic, though, is exactly the paper's eqs. (3)–(5).
Step 3 · The diagnosis
Few big experts: every one a generalist, every one a copy.
You just routed enzyme to 2 winners out of 16. Now ask the question the paper asks: after training on trillions of tokens, what does each of those 16 experts end up containing?
Run the numbers from the router's side. With top-2 over 16, each expert receives on average an eighth of the entire corpus — enzyme kinetics today, Python tomorrow, sonnets on Thursday. All of it must be packed into one set of FFN weights and, worse, those weights all fire together whenever the expert is chosen. The paper calls this knowledge hybridity: the left pane below is one expert's crowded shelf, and the token chips crammed into it have nothing to do with each other.
The second leak is subtler. Every token — biological or not — needs the same base skills: English glue words, agreement, spelling. Whichever experts a token lands on must supply those skills, so many experts each learn a private copy. That's knowledge redundancy — the right pane, the same glue chip duplicated shelf after shelf, parameters spent on repetition instead of new knowledge.
Leak 1 · knowledge hybridity
One expert, an eighth of the corpus. Unrelated knowledge sharing one set of weights that always fire together.
Leak 2 · knowledge redundancy
Every expert a token can land on must know the basics — so all 16 learn their own copy of them.
Both leaks trace to one number being too small: how many ways the router can compose experts for a token. The paper's fix never touches the budget — it changes only the granularity of the choice. And it will let us measure how much the leaks were costing: keep an eye out for the "upper bound" experiment in Step 8.
Two edits to the expert layer
Cut the experts finer, pin one always on — and count what that buys.
Step 4 · Edit no. 1 — fine-grained segmentation
64 quarter-size experts cost exactly what 16 full-size ones did.
Step 3 blamed both leaks on coarse-grained choice. The first edit attacks the coarseness directly — while touching neither the parameter count nor the compute bill.
The move: slice each expert FFN into m smaller ones by
cutting its intermediate hidden width to 1/m of the
original. With m = 4, the 16 experts become
64 quarter-size experts. Each is a quarter as big and a
quarter as expensive — so, to spend the same compute, the router
now activates 4 × 2 = 8 of them instead of 2. Enzyme
no longer gets two generalists; it gets an eight-member committee
of narrow specialists.
Honest admission: this was the part of the paper we re-read the most. "More experts, more activations, same cost" sounds like an accounting trick — surely something got bigger? The way out is to write the two ledger lines yourself and watch both stay fixed while a third quantity moves:
| Layout | Experts | Size each | Stored | Run per token | Compute |
|---|---|---|---|---|---|
| GShard-style | 16 | 1 | 16 × 1 = 16 | 2 | 2 × 1 = 2 |
| Fine-grained (m=4) | 64 | ¼ | 64 × ¼ = 16 | 8 | 8 × ¼ = 2 |
The figure makes the same ledger visual. Both strips have the same total width — that's the stored parameters — and the same amount of teal — that's the per-token compute. The only difference is how finely the width is diced, and therefore how precisely the teal can be placed.
Why does finer dicing fight hybridity? Because knowledge can now be decomposed. The old expert 3 held enzyme kinetics, cell membranes and Greek roots in one lump that always fired together; after the cut, those can live in different quarter-experts, and the router summons only the ones this token needs. Each small expert keeps a tighter, cleaner portfolio — the paper's phrase is that knowledge is "decomposed more finely and learned more precisely."
Formally (§3.1): the layer is still h = Σ gi·FFNi(u) + u — the sum now runs over mN = 64 experts and the router keeps the top mK = 8. Same machinery as Step 2, only the ranges changed.
Step 5 · The combinatorial payoff
120 possible expert teams become 4,426,165,368.
Step 4's ledger showed nothing got bigger. So what exactly did the edit buy? Teams. Let's count them — this is the number the whole paper leans on.
Start with the old layer, and count by hand. A "team" is a set of
experts serving one token. Choosing 2 out of 16: the first pick
has 16 options, the second 15, and order doesn't matter, so
16 × 15 / 2 = 120 possible teams. That's the entire
menu — every token in every context must be served by one of 120
combinations.
Now the fine-grained layer: choosing 8 out of 64. Same counting
rule, eight picks deep — written as the binomial
C(64, 8) = 64! / (8! · 56!) — and it comes to
4,426,165,368. From 120 to 4.4 billion, a
37-million-fold richer menu, and the ledger from Step 4 says we
paid nothing for it. This is the paper's own worked example, and
it's the sense in which segmentation attacks hybridity: with a
menu that rich, the router can compose a bespoke committee per
token instead of forcing tokens into 120 pigeonholes.
Slide the granularity m — the budget stays pinned, the menu explodes
What to notice: the two dashed tiles never move — that's the free-lunch suspicion answered. m = 4 is the configuration the 2B and 16B models actually ship with; m = 8 is what the 145B trial uses. Every team count is computed exactly, not looked up.
Two honest boundaries before we move on. First, 4.4 billion is a count of possible routing patterns, not knowledge the model has already earned — the router still has to learn to use the menu, and Step 7 adds guardrails to keep it from collapsing onto a few favorites. Second, m can't grow forever: matrix multiplies below a certain size waste GPU throughput, which is why the 16B model stops at quarters and only the 145B trial dares eighths (§5.1.2).
Fine-grained segmentation moves none of the budget and all of the flexibility: stored parameters and per-token compute are invariant in m, while the team menu grows as C(16m, 2m) — 120 at m=1, 4.4 billion at m=4.
Step 6 · Edit no. 2 — shared expert isolation
One expert never routes: it holds what every token needs.
Finer slicing lets each small expert stay narrow — that was leak 1. But leak 2 is still open: all 64 of them would still each learn a private copy of the glue that every sentence needs.
The second edit is almost embarrassingly direct: take
Ks of the experts — one, in the 2B model —
and pin it on. Every token visits the shared expert,
deterministically, no router vote at all. To keep the compute bill
pinned too, the router now picks only 8 − 1 = 7
routed experts from the remaining 63. In the slot picture below,
enzyme's eight activation slots are one amber pin plus seven teal
choices.
Why does one pinned expert fix redundancy? Because it changes what the routed experts are for. Common knowledge — the glue in "The … speeds up …" — now has a guaranteed home that every token passes through, so a routed expert gains nothing by storing its own copy. Gradient descent quietly stops paying for duplicates, and the 63 routed experts compress toward what is genuinely theirs. The paper's word for the effect is isolation: common knowledge is isolated out of the routed pool.
There is a price, and the paper doesn't hide it: pinning a slot
shrinks the menu. Choosing 7 from 63 gives
C(63,7) = 553,270,671 teams — half a billion, well
under Step 5's 4.4 billion. The bet is that a permanent desk
for the basics is worth more than those combinations. Is it? Make
your own call before revealing the measurement:
Take the trained 2B model (Pile loss 1.808 — cross-entropy on the Pile test set, the paper's running quality meter; lower is better). At evaluation time, switch its shared expert off and let the router pick one extra routed expert instead — same compute. What happens to the loss?
1.808 → 2.414
Catastrophic. Losing one expert out of 64 — 1.6% of the expert parameters, instantly replaced by an extra routed pick — leaves the 2B model scoring worse than the 0.2B dense baseline (2.060) from the same paper. The paper reads this as direct evidence that the shared expert holds fundamental knowledge the routed experts never bothered to copy: exactly the de-duplication the edit was designed to cause, demonstrated by its absence.
Credit where due (§3.2): shared experts appeared first in DeepSpeed-MoE (Rajbhandari et al., 2022) as an engineering optimization. This paper arrives at them from the specialization argument — and pairs them with segmentation, which is where the measured gains stack up (Step 9). The 1.808 → 2.414 surgery is an inference-time ablation of the trained model, not a retraining.
Step 7 · The assembled layer
1 pinned + 7 routed of 63 — and two small losses keep the router honest.
Both edits are in place. Time to reassemble the full layer that enzyme actually traverses in DeepSeekMoE 2B — Step 2's diagram, upgraded.
Read the figure bottom-up, exactly as before: u rises
into the router, which now scores only the 63 routed experts and
keeps 7. Meanwhile the amber path on the left bypasses the router
entirely — the shared expert runs unconditionally, with no gate.
Everything meets at the same summation: seven gated teal outputs,
one ungated amber output, plus u itself.
h = Σshared FFNi(u) + Σrouted gi· FFNi(u) + u
eq. (9) · shared: Ks terms, no gate · routed: top (mK − Ks) of (mN − Ks) by softmax score
One loose end from Step 5: with 63 experts to choose from, what stops the router from feeding its early favorites forever — the rich-get-richer spiral known as routing collapse? Training adds two gentle penalty terms. An expert-level balance loss nudges the 63 routed experts toward comparable usage; its coefficient is kept deliberately tiny (0.01 at 2B, 0.001 at 16B) because forcing perfect balance would override the router's actual judgment. A device-level balance loss ignores individual experts and only evens out the compute landing on each GPU — the 145B run sets it 17× stronger than the expert-level one, balancing machines, not experts.
At every size the recipe pins the activated budget near 2 standard FFNs per token and spends it ever finer: 2B — 1 shared + 7 of 63 quarters; 16B — 2 shared + 6 of 64 quarters; 145B — 4 shared + 12 of 128 eighths. The knob is always the dicing, never the bill.
We're not unpacking the balance-loss algebra (the fi·Pi products) — §3.3 of the paper has the four-line derivation. Worth knowing: a successor to this architecture, DeepSeek-V3, later drops both losses for a bias-based "auxiliary-loss-free" scheme — built on exactly this layer.
The evidence
A pinned-budget bake-off, three probes of specialization, then two trillion tokens.
Step 8 · Same budget, five machines
With everything pinned, architecture alone moves Pile loss 1.867 → 1.808.
The design case is complete — two edits, zero extra budget. Now the burden of proof: do the edits buy measurable quality when nothing else is allowed to vary?
The validation setup is as controlled as it gets. Five models, the same 2.0B total parameters for every MoE (0.2–0.3B activated), the same 100B training tokens, the same everything else. The lineup below is a short history of MoE routing: a dense baseline sized like the activated compute, Hash Layer (top-1 by hash), Switch Transformer (top-1 learned), GShard (top-2 learned — Step 2's machine), and DeepSeekMoE (1 shared + 7 of 63). Lower loss is better; the bars tell the ranking at a glance.
Pile loss after 100B tokens (Table 1) — cinnabar bar = this paper. Bars start at 1.75, not 0, to make the gaps readable. The same ordering holds on HellaSwag (38.8 → 46.2 → 49.1 → 50.5 → 54.8) and the other 11 benchmarks.
Beating peers is one thing; the paper also asks the sharper question from Step 3 — how much of the leaked potential did we recover? Two harder yardsticks. First, a GShard scaled to 1.5× the expert parameters and compute: DeepSeekMoE ties it (1.808 vs 1.808) from a smaller machine. Second, the ceiling: a model with the same 16 units of expert parameters where all 16 experts run for every token — no routing, no wrong choices, every parameter available always. That costs 5.7× the FLOPs and defines the best any router could hope to reach with this parameter pool. Its loss: 1.806. DeepSeekMoE sits at 1.808 — 0.002 from the ceiling — while paying the sparse price. In the table, read the FLOPs column against the loss column.
| Model | Expert params | FLOPs / 2K tokens | Pile loss |
|---|---|---|---|
| GShard ×1.5 | 2.83B | 5.8T | 1.808 |
| Dense ×16 — the ceiling | 1.89B | 24.6T | 1.806 |
| DeepSeekMoE | 1.89B | 4.3T | 1.808 |
At the 2B scale, the two edits recover nearly all of the gap between GShard-style routing and the theoretical best use of the same parameters — the paper's emphasized claim, italics theirs: performance "aligns closely with the theoretical upper bound of MoE models."
Step 9 · Is it actually specializing?
Disable its best experts and it hurts more — low redundancy, made visible.
Step 8 says the model is better. It doesn't yet say why — maybe something other than specialization improved. So the paper operates on the trained 2B model three times and watches what breaks.
Probe 1 — remove the favorites. For each token, mask the routed experts the router most wanted, and make it route among the rest. If experts were interchangeable generalists, understudies would cover fine. The left chart shows the result: DeepSeekMoE's loss (cinnabar) climbs far more steeply than GShard×1.5's (gray) — its experts are not interchangeable. The paper reads the steeper curve as lower redundancy: each routed expert holds something the others genuinely don't.
Probe 2 — use fewer experts. Run the trained model with only 4 routed picks instead of 7. On the right chart, the cinnabar curve crosses the gray dashed line at 4 experts: with roughly five-eighths of the activated expert parameters, DeepSeekMoE already matches full GShard. Knowledge sits where the router expects it, so fewer, sharper picks suffice.
Probe 1 · disable top routed experts
Pile loss vs share of top routed experts disabled (Figure 4). Steeper = less redundancy among experts.
Probe 2 · activate fewer experts
Pile loss vs activated routed experts (Figure 5). The circled point: 4 picks ≈ GShard's full loss.
Probe 3 — halve it and retrain. The strongest version: train a fresh model from scratch with 1 shared + only 3 of 63 routed activated — half of GShard's activated expert parameters. It still beats GShard across HellaSwag, PIQA, ARC, TriviaQA and NaturalQuestions (Figure 6). Not a surgical trick on a lucky checkpoint; the efficiency is in the architecture.
Chart honesty: the intermediate curve values are read off the paper's Figures 4–5 and are approximate; the anchor numbers (1.808 at zero disabled, 1.867 for GShard, the crossing at 4 experts) are stated in the text or tables. Probe 1 compares against GShard×1.5 because both start from the same 1.808 loss — that's what makes the slopes comparable.
Step 10 · Two trillion tokens later
At 16B it holds even with LLaMA2 7B — on 40% of the compute.
Everything so far is a 2B model fed 100B tokens — a lab bench. The fair worry: does the specialization story survive a real training run?
DeepSeekMoE 16B keeps the recipe (2 shared + 6 of 64 quarter-experts per layer) and trains on 2T tokens — the same diet as LLaMA2 7B. The scoreboard below is the head-to-head: look first at the FLOPs row, then at everything under it. Wins on most rows, a standout gap on code and math (the pretraining corpus is rich in both), all for 39.6% of the compute.
| Metric | LLaMA2 7B | DeepSeekMoE 16B |
|---|---|---|
| Total params | 6.7B | 16.4B |
| Activated params | 6.7B | 2.8B |
| FLOPs per 4K tokens | 187.9T | 74.4T |
| HellaSwag (acc.) | 75.6 | 77.1 |
| HumanEval (pass@1) | 14.6 | 26.8 |
| MBPP (pass@1) | 21.8 | 39.2 |
| GSM8K (EM) | 15.5 | 18.8 |
| MMLU (acc.) | 45.8 | 45.0 |
The MMLU row is the honest asterisk. On multiple-choice suites the 16B model trails slightly, and the paper's own diagnosis is instructive: with FFNs replaced by cheap sparse experts, only ~0.5B of its activated parameters are attention (a dense 7B has ~2.5B), and multiple-choice performance tracks attention capacity. The weakness isn't the expert layer misfiring — it's the corner that didn't get more parameters. A successor architecture (DeepSeek-V2's MLA) is largely about fixing that corner.
Before the bookend, close the loop yourself. Five questions, one per load-bearing idea — each opens onto a two-sentence answer.
What are the two leaks in top-2-of-16 MoE?
Knowledge hybridity: each of the few big experts must absorb an eighth of the whole corpus, so unrelated knowledge shares weights that always fire together. Knowledge redundancy: every expert a token might land on must know the common basics, so many experts store duplicate copies of them.
Where does 120 → 4.4 billion come from — and what did it cost?
C(16,2) = 120 teams versus C(64,8) = 4,426,165,368 after cutting each expert into quarters and activating 4× as many. Cost: zero — 64 × ¼ = 16 units stored and 8 × ¼ = 2 units computed, both identical to before.
Why pin a shared expert instead of letting the router learn one?
A pinned expert gives common knowledge a deterministic home, so routed experts stop storing duplicates. The ablation is the proof: switch the trained shared expert off (same compute) and Pile loss jumps 1.808 → 2.414 — worse than a 0.2B dense model.
What stops the router from overusing its favorite experts?
An expert-level balance loss with a deliberately tiny coefficient (0.01 at 2B, 0.001 at 16B) — just enough to prevent routing collapse without overriding the router's judgment — plus a stronger device-level loss that balances compute across GPUs rather than across experts.
What did the 16B run prove that the 2B run couldn't?
That the specialization gains survive a production-scale diet: trained on the same 2T tokens as LLaMA2 7B, it wins the majority of benchmarks on 39.6% of the compute — and the recipe held again in a preliminary 145B run at 28.5% of a dense 67B's compute.
What happened next — this layer became DeepSeek's MoE backbone. V2 bolted MLA attention onto it; V3 pushed granularity to 1 shared + 256 routed and replaced the balance losses with an auxiliary-loss-free bias; R1's reasoning training sits on top of V3. The bookend below traces the family line.
"Through fine-grained expert segmentation and shared expert isolation, DeepSeekMoE achieves significantly higher expert specialization and performance compared with prevailing MoE architectures." — the conclusion, Dai et al., 2024
The default shape of the open MoE model.
"Many small experts plus a pinned shared one" left this paper and became infrastructure. Within two years, the fine-grained recipe validated here at 2B was carrying frontier-scale models — inside DeepSeek and far beyond it.
The backbone of V2
DeepSeek-V2 pairs this exact layer — 2 shared + 160 fine-grained routed experts — with MLA, the attention redesign that patches the weakness Step 10 flagged. 236B parameters, 21B active.
Finer still, at 671B
V3 stretches the recipe to 1 shared + 256 routed experts (8 picked) and swaps the balance losses for an auxiliary-loss-free bias. R1's reasoning runs on that stack — 671B stored, 37B active.
Everyone's expert layer
Qwen's MoE line, Llama 4 and Kimi K2 all ship fine-grained expert banks with shared experts — the once-contrarian answer to "8 big experts or 64 small ones?" is now the reference design.
Two edits, zero extra compute — and "more experts, smaller experts, one always on" became how sparse models are built.