Log inStart free
LESSON 31.C2 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

MoE inference across GPUs

Follow 16 tokens through one MoE layer on 4 GPUs, from router to combine.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 31.C2 · EXPERT BAY32 COPIES · MEAN 4 · HOT E3 9, E4 7
01
Stage 1 of 6 · Route tokens
Top-k routing sends each token to 2 of 8 experts. Experts 3 and 4 get 9 and 7 copies: they are hot.
Explain it simply

Each teal square is a token, and each ochre box is an expert. The bars below are one token's router scores: the blue ones are kept, the dashed ones skipped. A wider ribbon means a larger gate weight. The tokens come from one text, so many go to the same few experts, and those get hot.

16 tokens on 4 GPUs send 32 copies to 8 experts. The loads of experts 1 to 8 are 0, 0, 9, 7, 6, 4, 2, 4. Experts 3 and 4 are hot.

Weights are random, not trained.
tokens, copiesexperts, kernelsGPU work, outputshot, bottleneck, start, paddinggrey dashed: idle, skipped
E10E20E39hotE47hotE56E64E72E8412345678910111213141516router scores of token 1 (hover a token): the top 2 kept−0.31−0.680.36gate 0.510.33gate 0.49−0.34−0.39−0.480.24router picks 2 experts per tokenexperts, by number (copies)GPU 0GPU 1GPU 2GPU 327.14 GEMM11.15 All-to-All31.03 placement10.11 routingE10E20E39hotE47hotE56E64E72E8412345678910111213141516router scores of token 1 (hover a token): the top 2 kept−0.31−0.680.36gate 0.510.33gate 0.49−0.34−0.39−0.480.24router picks 2 experts per tokenexperts, by number (copies)GPU 0GPU 1GPU 2GPU 327.14 GEMM11.15 All-to-All31.03 placement10.11 routing
Toy: 16 tokens, 8 int8 experts, 4 GPUs; toy costs
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
gt=softmax⁡(top⁡k(xt Wr)),ne=#{t:e∈top⁡k}\sy{g}{out}{g_t} = \operatorname{softmax}\big(\operatorname{top}_k(\sy{x}{data}{x_t}\, \sy{wr}{param}{W_r})\big),\quad \sy{n}{data}{n_e} = \#\{t : e \in \operatorname{top}_k\}
n3=9>1.5 nˉ=6,nˉ=16⋅2/8=4n_{3} = 9 > 1.5\,\bar n = 6,\quad \bar n = 16 \cdot 2 / 8 = 4

An expert is hot when its load passes 1.5 times the mean.

Common mix-ups

MYTHPlacement by load always evens out the GPUs' work.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01At top 2, does placement by load lower the busiest link's 13 copies?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.