Unit 10 of 10 · about 4 hours · derive

MoE communication and memory accounting and topology-aware placement

MoE trades dense FLOPs for token movement. The byte count decides whether more experts help or just buy communication, and placement decides which links pay it.

You'll be able to

  • Derive dispatch and combine bytes for one MoE layer from tokens, top-, hidden width and dtype.
  • Apply the JAX roofline rule for when expert parallelism stays cheap across nodes.
  • Explain node-limited routing and topology-aware expert placement.

Covers

Communication and memory accounting for MoE layersNode-limited routing and topology-aware expert placement
1

Read

In this order, only the parts listed

0 of 3 done

  1. Expert-parallel roofline on GPUsHow to Scale Your Model - Expert Parallelism on GPUs

    Rooflines for LLM Scaling on GPUs, Expert Parallelism: math versus communication time with the takeaway on small versus large feed-forward width (page read 2026-10-14); Quiz 5: LLM rooflines (page read 2026-10-14)

    Work Quiz 5 on paper before opening the answers. Use the all-to-all cost half for your own accounting; keep its H100 numbers labeled as H100 numbers.

  2. Capacity factor and communication costsMixture of Experts Explained

    Capacity Factor and communication costs: raising capacity raises quality, communication and activation memory; top-2 at 1.25 as the starting point

  3. Node-limited routing and EP scaleDeepSeek-V3 Technical Report - MoE Sections

    Section 3.2.2 and Section 3.2 (arXiv:2412.19437v2): at most 4 nodes per token, IB and NVLink overlap with 20 SMs, 64-way EP spanning 8 nodes with 16-way PP and ZeRO-1 DP; all figures are the authors cluster results

2

Focus on

  • One all-to-all moves elements; dispatch plus combine doubles it before bytes per element. In fixed-capacity schemes the padding rows move too; in dropless uneven dispatch padding is added locally after the exchange and never crosses the network.
  • The JAX rule compares feed-forward width against scaled compute-to-bandwidth: narrow experts stay within about 2 nodes, wide experts scale further. Restate it with your own and , never with borrowed constants.
  • Node-limited routing caps the nodes each token touches (4 in DeepSeek-V3) so slow inter-node links carry less. Topology-aware placement then keeps hot experts behind fast intra-node links.
  • DeepSeek-V3 trains without tensor parallelism by pairing 64-way EP with 16-way PP and 2-way DP. That mix is their cluster answer, not a universal recipe.
Common mistakes · 3
  • Counting one all-to-all. Dispatch and combine both move the full routed payload; forgetting combine halves the bytes.
  • Mixing units: GB against GiB, Gbit/s against GB/s, FLOPs against FLOP/s, algorithm against bus bandwidth. The byte count is exact; the time needs the stated bandwidth and its definition.
  • Lifting H100 or TPU constants onto your machine. The JAX numbers assume their fabric; your accounting must plug in measured or explicitly assumed links, and CPU gloo timings never stand in for them.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive bytes for tokens, , in bf16: 2048 bytes per all-to-all, 4096 total for dispatch plus combine. Then state the JAX takeaway condition in words and apply it to one narrow and one wide expert case.
4

Quiz yourself

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

0 got · 0 missed

  1. 1., , , bf16. How many bytes per all-to-all and total?Answer

    bytes each; 4096 total.

  2. 2.Capacity factor rises from 1.0 to 1.5 with no routing change. What happens to bytes?Answer

    In a fixed-capacity scheme the buffer grows to 1.5 times the even share, so up to 1.5 times the rows move and activation memory grows with them even though real tokens did not. Dropless uneven dispatch moves only the real rows.

  3. 3.What does node-limited routing buy?Answer

    It bounds slow-link traffic per token. With at most 4 nodes, most expert fan-out stays behind fast intra-node links under the overlap design.

  4. 4.When does the JAX rule favor wide multi-node EP?Answer

    When feed-forward width exceeds the scaled compute-to-bandwidth threshold, so math outweighs the cross-node all-to-all cost.

You're done when

Your byte derivation matches 2048 and 4096 from memory, and you can defend a placement with named links and labeled bandwidths.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 9 more in the section
  • 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.

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

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.

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

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

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

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