6.1.4 · D3Scaling & Efficient Architectures

Worked examples — Mixture-of-Experts (MoE) architecture

3,796 words17 min readBack to topic

Everything here uses only three tools. Let us fix their meaning once, in plain words, before any symbol appears again.


The scenario matrix

Every example below is tagged with the cell it covers.

Cell Case class What could break the naive intuition
A Standard Top-2 route nothing tricky — the baseline
B Exact tie in logits () who wins Top-? deterministic tie-break
B2 Tie straddling the cutoff tie splits across the keep/drop boundary
C Negative & zero logits softmax still works; ,
D All logits equal (degenerate) uniform routing, maximal entropy
E Top-1 () the gate still matters (gradient!)
F Capacity overflow → dropped tokens residual carries the token, output changes
G Load-balance loss, balanced vs collapsed min vs worst case
H Params vs FLOPs word problem capacity compute
I Exam twist: change , watch FLOPs & output which quantity moves, which doesn't

We will hit A–I across ten examples.

Before the examples, one picture of the whole pipeline — every example is a walk along this same arrow chain, so keep it in mind. Cyan boxes are the fixed machinery; amber is where a token's fate is decided.

Figure — Mixture-of-Experts (MoE) architecture
Figure — the routing pipeline shared by every example: logits → softmax → Top- keeps some, zeros the rest → re-normalise survivors → gate-weighted blend . Amber marks the two decision points (which experts survive, whether the expert has room).


Cell A — the baseline route

The bar picture below is the whole example in one glance: the tall grey bars are the softmax probabilities ; the two cyan bars are the survivors Top-2 keeps; the two faded bars are zeroed. Watch how re-normalising stretches the two cyan bars up so they fill the height between them.

Figure — Mixture-of-Experts (MoE) architecture
Figure — Cell A: softmax probabilities (grey), the Top-2 survivors (cyan), and the same two after re-normalising to sum to 1 (amber outline). Experts 1 and 4 are faded — they contribute nothing.


Cell B — an exact tie ()


Cell B2 — a tie straddling the cutoff

Cell B had the tie at the top with . The nastier case is a tie sitting exactly on the keep/drop boundary: more experts are tied for the last surviving slot than there are slots left. The figure shows this — two equal-height bars share rank 2, but Top-2 has only one slot left after taking rank 1.

Figure — Mixture-of-Experts (MoE) architecture
Figure — Cell B2: logits , . Rank-1 (cyan) is taken outright; experts 2 and 3 tie for the single remaining slot (amber-striped). The lowest-index tie-break keeps expert 2, drops expert 3.


Cell C — negative and zero logits


Cell D — the degenerate case: all logits equal


Cell E — Top-1, why the gate still bites


Cell F — capacity overflow and dropped tokens

First, one new quantity.

The figure below draws this literally: each expert is a fixed-height bin of height . Cyan fill = tokens that fit and get processed; the dashed white line is the capacity ceiling ; amber above the line = overflow tokens that are dropped and pushed sideways by an amber arrow onto the residual path. Read it bin by bin as you follow the steps.

Figure — Mixture-of-Experts (MoE) architecture
Figure — Cell F: four experts as fixed-capacity bins. Expert E1 receives 200 tokens but its bin only holds C=128; the 72 tokens above the dashed ceiling (amber) are dropped and carried forward unchanged by the residual connection. Experts E2–E4 stay under C and drop nothing, yet their unused slots cannot be lent to E1.


Cell G — the load-balance loss, best vs worst

The bowl figure gives the intuition the algebra hides: plot as we slide from perfectly uniform usage toward collapse. It is a bowl with its lowest point exactly at uniform — any move away from the centre only raises the penalty.

Figure — Mixture-of-Experts (MoE) architecture
Figure — Cell G: the load-balance term traced as usage moves from uniform (centre, value 1.0) to full collapse (edge, value N). The curve is a bowl bottoming out at uniform — the visual proof that uniform is the unique minimum.


Cell H — a word problem: capacity is not compute


Cell I — exam twist: change , what moves?

The paired bar figure shows the same softmax vector twice — once with the survivors highlighted, once with the set. Notice the grey bars are identical between panels; only which bars are lit and how tall the re-normalised gates rise changes.

Figure — Mixture-of-Experts (MoE) architecture
Figure — Cell I: identical softmax in both panels. Left () keeps experts 1,2 and re-normalises them taller; right () keeps 1,2,3, so each survivor gate is shorter (shared over a bigger denominator).


Recall Quick self-test

All four logits equal — what is each softmax probability for ? ::: each (shift-invariance, value of the constant irrelevant). A logit — can its softmax probability be negative? ::: No; . Softmax is always positive. Logits , — who is dropped? ::: The tie at rank 2 is broken by lowest index: expert 2 kept, expert 3 dropped. Batch 800, , capacity factor 1.0, one expert gets 200 tokens — how many dropped there? ::: , dropped . At , why keep the raw gate instead of forcing it to 1? ::: So the gate carries gradient to the router — it learns confidence, not just choice. Does raising change the softmax ? ::: No — softmax runs over all logits before Top-; only the survivor set, gates, and FLOPs change.

Back to the parent MoE note · related: Feed-Forward Networks (Transformer FFN), Model Parallelism & Expert Parallelism.