Unit 7 of 10 · about 4 hours · measure
Tokens-per-expert histograms, hot experts and all-to-all skew
Averages hide the failure. One hot expert sets the step time and the largest all-to-all, so diagnosis reads per-expert and per-rank distributions, not global means.
You'll be able to
- Report tokens-per-expert histograms with token fractions , mean probabilities and a max-to-mean ratio.
- Explain hot experts, stragglers and all-to-all skew from per-rank send and receive splits.
- State why balanced counts need not imply equal compute or equal network load.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Load statistics definitionsTensorTonic - Top-k MoE Router with Load Statistics
Token fraction and probability mass definitions with the three public cases as worked histogram examples
- Token counting instrumentationTorchFeather - Expert Parallelism
TokenChoiceTopKRouter.forwardandTokenReorderer.forward(torch.histccounts, which run on CUDA; on CPU usetorch.bincount, sincetorch.histcon int64 indices raiseshistogram_cpu not implemented for Long), andMoE.forwardaccumulation intotokens_per_expert - Cross-node skew and its fixDeepSeek-V3 Technical Report - MoE Sections
Section 3.2.2 (arXiv:2412.19437v2): IB at 50 GB/s versus NVLink at 160 GB/s, at most 4 nodes per token, IB and NVLink overlap, 20 SMs for communication; cluster figures only
Focus on
- Histogram first: counts per expert, for selection share, for router confidence, and max-to-mean count ratio for the hotspot size.
- Read the dispatch splits per rank: sends by destination expert group, receives for owned experts. The slowest rank and the largest receive set the all-to-all, not the mean.
- Balanced counts still allow skew: top- duplicates multiply rows, padding wastes FLOPs, and co-located hot experts pile traffic on one link.
- Name the setup behind every number: these traces come from CPU processes or a simulator unless two or more GPUs ran them.
Common mistakes · 3
- Calling uniform counts proof of uniform compute. Duplicated top- rows, padding and uneven expert shapes break that equality.
- Calling uniform counts proof of uniform network load. Tokens for one expert may arrive from many ranks while another expert sits local; the receive table tells the truth.
- Quoting CPU
glooskew timings as interconnect evidence. They exercise the accounting path only; link claims need the link hardware.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Counts over 6 tokens with . What are and the max-to-mean ratio?Answer
Assignments total 12, mean 3. ; max-to-mean is .
2.Two ranks send and receive . Which rank sets the all-to-all?Answer
Rank 0: it receives 12 rows against 4. Receives size the payload each rank must absorb.
3.Every expert holds exactly 3 tokens but step time still skews. Name two causes.Answer
Any two of: top- duplicates counted once but computed twice, padding on some ranks, co-located hot experts sharing one link, or a slow rank outside routing.
4.How do and disagree under collapse?Answer
Both pile on the favored expert, but is 0 or 1 from hard selection while spreads residual mass; the gap measures router overconfidence versus assignments.
You're done when
Your oracle tables name the hot expert, the slow rank and the max-to-mean ratio from memory, with the hardware behind each number stated.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 9 more in the section
- TorchFeather - Expert ParallelismTorchFeather · required
Watch the video segments from 16:49:58 (MoE) through 18:36:24 (expert parallelism), 19:01:56 (all-to-all dispatch and combine) and 19:27:38 (expert tensor parallelism), then trace
model/moe/anddistributed/expert_parallel.py. Build a tiny router-dispatch-expert-combine oracle first, then map each group, placement andall_to_all_singlecall to it. - DeepSeek-V3 Technical Report - MoE SectionsDeepSeek-AI (2024) · support
Read the DeepSeekMoE architecture (shared and fine-grained experts, auxiliary-loss-free balancing, node-limited routing) and the all-to-all communication design. Its throughput figures are its own cluster's results.
- TensorTonic - Top-k MoE Router with Load StatisticsTensorTonic · support
Solve Top-k MoE Router with Load Statistics, including its lower-index tie rule, before building dispatch.
Also in this section
- Ultra-Scale Playbook - Expert ParallelismHugging Face · primary
Read Expert Parallelism and its interaction with DP in the 5D summary. Derive tokens, bytes and expected imbalance for one top-k routing example; use the linked MoE introduction only if the architecture is unfamiliar.
- How to Scale Your Model - Expert Parallelism on GPUsGoogle DeepMind · support
Read the expert-parallelism part of Rooflines for LLM Scaling on GPUs and work its quiz before the answer. Use it for the all-to-all cost half of your MoE accounting.
- Mixture of Experts ExplainedHugging Face · required
Study routing, capacity, token dropping, auxiliary loss and the expert-parallelism sections. Implement the small routing examples and verify conservation of token contributions through combine; group composition and FSDP interaction come from the papers and TorchTitan.
- GShard: Scaling Giant Models with Conditional Computation and Automatic ShardingLepikhin et al. (ICLR 2021) · support
Read the mixture-of-experts layer: top-2 gating, expert capacity, the auxiliary loss and random routing. Compare its capacity rule with Switch.
- ST-MoE: Designing Stable and Transferable Sparse Expert ModelsZoph et al. (2022) · support
Read the stability section that introduces the router z-loss and compare it with the auxiliary balancing loss.
- Bumblebee - Router, Dispatcher and Expert PrimitivesBumblebee · depth
Only as a possible capstone target: read
primitive/modules/router.py,dispatcher.py,experts.pyandmoe.pyin a clean checkout. Its own todo lists no multi-GPU correctness test yet, so do not treat it as a reference implementation. - TorchTitan - MoE Model and ParallelismPyTorch · support
Read the MoE model files and their parallelization plan only after the tiny oracle passes, at a pinned commit. Record how a production PyTorch stack composes EP, expert FSDP and the other mesh dimensions.
- Switch TransformersGoogle Research · support
Read Section 2 for simplified routing, the capacity factor and the load-balancing loss, and Section 5 for combining data, model and expert parallelism. Reproduce its capacity arithmetic for one batch.
- PyTorch Distributed - all-to-all collectivePyTorch · reference
Read
all_to_all_singleforinput_split_sizesandoutput_split_sizeson dim 0 and its uneven-split example. Use it for the dispatch and combine calls in the tiny oracle, and check zero splits yourself.