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

Tokens-per-expert histograms and imbalance metricsHot experts, stragglers and all-to-all skew
1

Read

In this order, only the parts listed

0 of 3 done

  1. 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

  2. Token counting instrumentationTorchFeather - Expert Parallelism

    TokenChoiceTopKRouter.forward and TokenReorderer.forward (torch.histc counts, which run on CUDA; on CPU use torch.bincount, since torch.histc on int64 indices raises histogram_cpu not implemented for Long), and MoE.forward accumulation into tokens_per_expert

  3. 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

2

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 gloo skew timings as interconnect evidence. They exercise the accounting path only; link claims need the link hardware.
3

Try it yourself

Closed-book, before checking anything

Closed-book, instrument the 6-token oracle from the dispatch unit: emit per-expert counts, , and the max-to-mean ratio, plus a per-rank send and receive table for EP degree 2 with one hot expert. Point at the rank and the expert that set the step.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 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. 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. 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. 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/ and distributed/expert_parallel.py. Build a tiny router-dispatch-expert-combine oracle first, then map each group, placement and all_to_all_single call 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.py and moe.py in 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_single for input_split_sizes and output_split_sizes on dim 0 and its uneven-split example. Use it for the dispatch and combine calls in the tiny oracle, and check zero splits yourself.