Unit 7 of 9 · about 5 hours · derive

All-to-all and MoE dispatch, combine and load balance

Expert parallelism replaces one big all-reduce with two all-to-alls per layer whose sizes follow routing, not ranks. Skew, not peak links, usually sets MoE step time.

You'll be able to

  • Derive all-to-all dispatch and combine bytes with capacity needs for a stated mixture-of-experts shape.
  • Predict hot-expert imbalance effects on step time, and defend replication, capacity or rebalancing against measured per-expert counts.

Covers

All-to-all and mixture-of-experts dispatch trafficMixture-of-experts dispatch, combine and communication kernelsToken skew, hot experts and load-balanced placement
1

Read

In this order, only the parts listed

0 of 4 done

  1. Expert parallelism and routingAI Systems Performance Engineering - Chapters 4, 15, 17 and 18

    Chapter 15, Expert Parallelism; Dynamic Routing Strategies for MoE Inference with Expert Communication Optimization and Load Balancing, Capacity Factor, and Expert Replication

  2. AlltoAll semantics for dispatchNCCL

    AlltoAll: each rank sends a distinct block to every rank with no reduction; dispatch and combine each move the full routed activation set

  3. Dispatch and combine pathsDeepEP

    README Interfaces and examples with dispatch and combine through one EPBuffer; do_cpu_sync True for exact training and prefill sizes, False for GPU-side decode counts; NVLink inside a node with RDMA and IB between nodes

    Reading and derivation only, unless you have Hopper GPUs with multi-GPU RDMA, which DeepEP needs.

  4. MoE dispatch and routing benchmarksAI Systems Performance Engineering companion code - Chapters 4, 15 and 17

    baseline_moe_dispatch.py with optimized_moe_dispatch.py; baseline_moe_routing_topology_aware.py with its optimized pair

2

Focus on

  • One MoE layer pays dispatch plus combine: about elements times bytes per element for tokens, top- routing and hidden size . Both halves are all-to-all; neither is a reduction.
  • Capacity per expert is for capacity factor over experts. Factors around 1.2 to 1.5 with top-2 gating are the book's starting point; overflow routes to second-choice experts and drops or spills only under a stated policy.
  • Uniform routing is a modelling convenience, not a measurement. Hot experts stretch the step while cold ranks wait, so per-expert token counts are mandatory evidence before any placement claim.
  • DeepEP V2 unified the low-latency and high-throughput paths into one EPBuffer interface switched by do_cpu_sync, and V2.5 removed V1 and its NVSHMEM backend. Older guides describing two separate modes no longer match the repository.
Common mistakes · 3
  • Sizing the fabric for average load. The step follows the hottest expert, so average-based provisioning underbuys the link and the buffer the hot rank needs.
  • Treating dispatch as an all-reduce. Summing routed activations corrupts every expert input; dispatch permutes blocks and combine returns them, with the routing metadata as part of the contract.
  • Running DeepEP paths on GPUs older than Hopper. The kernels assume Hopper with NVLink and RDMA; on other hardware the failure is a wrong-hardware error, not a tuning problem.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive per-layer dispatch and combine bytes for stated , , , dtype and expert count, plus per-expert capacity at a stated factor. Evaluate at , , , FP16 and , then show how one expert taking twice its share changes the max.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.What are the dispatch bytes at , , in FP16?Answer

    bytes, about 67 MB decimal or 64 MiB. Combine moves the same amount back.

  2. 2.With experts and capacity factor 1.25, what is each expert's token cap?Answer

    tokens. Tokens above the cap follow the overflow policy instead of the assigned expert.

  3. 3.One expert receives twice its average share. What happens to step time?Answer

    Its all-to-all peers and its compute stretch while other ranks wait at the next dependency. Step time follows the hot expert, so the fix is replication, rebalancing or a higher cap with measured counts.

  4. 4.Combine needs which metadata from dispatch?Answer

    The routing decisions: which token went to which expert. Without them combine cannot return each output to its source token.

You're done when

Your hand dispatch, combine and capacity numbers match a worked example, and you can name the hot expert and the fix from per-expert counts alone.

Only when you can do this without notes.

Leads to

Notes

Resources · 4 for this unit, 9 more in the section
  • AI Systems Performance Engineering - Chapters 4, 15, 17 and 18Chris Fregly · primary

    Read Chapter 4 on distributed networking communication, the parallelism parts of Chapter 15, and Chapters 17 and 18 on disaggregated prefill and decode and KV-cache transfer. Re-derive every volume and crossover for the hardware you actually have.

  • AI Systems Performance Engineering companion code - Chapters 4, 15 and 17Chris Fregly · support

    Use compatible examples from code/ch04, code/ch15 and code/ch17 for NCCL, topology, overlap and disaggregated inference. Run preflight checks, lock and record clocks through the harness, and mark unsupported transport or topology paths as explicit blockers.

  • NCCLNVIDIA · required

    Study the collective API, communicator and topology behavior, then run a bounded nccl-tests message-size sweep when multiple GPUs are available. Correlate algorithm bandwidth, bus bandwidth and rank timelines with the - model.

  • DeepEPDeepSeek · depth

    Reconstruct expert dispatch and combine paths, low-latency versus high-throughput modes and hardware assumptions. Test a small supported path only after a standard collective baseline and load-skew model exist.

Also in this section

  • AI Performance Engineering - Distributed InferenceWafer · reference

    A curated index. Use Section 5 only to find primary papers for a communication mechanism you are measuring.

  • UCSD CSE 291A/DSC 291 (Spring 2026) PA2 Part 2 - Tensor Parallel CommunicationUC San Diego · required

    Build all-reduce and all-to-all from point-to-point MPI calls (Section 2.1), then the data split, layer initialization and naive model-parallel forward and backward communication (Sections 2.2 to 2.5) against the provided mpi-test.py cases and pytest files. It runs on CPU processes with Open MPI and mpi4py.

  • CS336 Assignment 2 - Section 8.1 Communication PrimitivesStanford University · support

    Work alternate_ring_all_reduce and the communication-volume reasoning in Section 8.1 as a written check on your cost model.

  • TensorTonic Language Modeling from Scratch - collective problemsTensorTonic · support

    Solve Simulate Distributed Collectives, Calculate Collective Effective Bandwidth, Synchronize Data-Parallel Gradients and Reconstruct a Column-Parallel MLP Layer after the collective units.

  • GPU MODE - Collective CommunicationGPU MODE · support

    Use Lectures 17, 67, 70 and 78 for NCCL, NVSHMEM, fault-tolerant collectives and multi-GPU Triton. Implement or inspect one communication mechanism only after the volume and topology model is written.

  • DistServeDistServe Authors · required

    Study prefill-decode interference, phase-specific parallelism and goodput optimization. Build a small simulator or measured two-pool experiment and test the key-value transfer crossover rather than reproducing the complete serving system.

  • NVIDIA Inference Xfer LibraryNVIDIA · support

    Inspect memory registration, transfer backends and metadata APIs as the state-movement layer for disaggregation. Run only supported local transports and compare measured transfer setup and steady-state cost with the model.

  • Splitwise: Efficient Generative LLM Inference Using Phase SplittingMicrosoft Research · support

    Read arXiv:2311.18677v2 (ISCA 2024) for the phase characterization and the homogeneous and heterogeneous cluster designs. Test the throughput, cost and power claims as hardware-specific results, and compare its placement with DistServe on your workload.

  • Mooncake: Trading More Storage for Less ComputationUSENIX FAST 25 · support

    Study the KVCache-centric disaggregated architecture, the global cache with its transfer engine, and the prefill scheduling with early rejection. Test the effective-capacity claims as trace-specific results.