Unit 2 of 11 · about 5 hours · explain, derive
Pipeline bubbles, expert-parallel MoE and context parallelism in serving
PP, EP and context parallelism partition different axes. Their serving value depends on available concurrency, expert skew and context length, not just whether the model fits.
You'll be able to
- Derive a forward-only pipeline timeline and identify the concurrency and stage balance needed to fill it.
- Map MoE dispatch and combine to serving ranks, preserving the selected experts and routing weights.
- Distinguish layer, expert, head and context-position partitioning, including the communication exact attention still needs.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Pipeline and expert serving pathsAI Systems Performance Engineering - Chapters 15 and 17, distributed and disaggregated inference
Chapter 15, Pipeline Parallelism; Expert Parallelism; Dynamic Routing Strategies for MoE Inference - Expert Communication Optimization and Load Balancing, Capacity Factor, and Expert Replication
Focus on serving dependencies and placement. Do not change the model's chosen experts to fix load: rerouting or dropping expert work changes outputs.
- Partitioning cached positionsLLM Inference: From scratch, one token at a time - Module 09
Module 09, Decode context parallelism: shard the cache by position, not by head - The mechanism, one decode step and Why decode specifically
Stop before the version-specific vLLM constraints and reported benchmark. Use the online-softmax merge from Stable and online softmax, normalization and fused residual paths, not a plain sum of locally normalized attention.
- A forward pipeline bubble exercise100 Days of LLM Inference - Days 12, 17 and 18
Day 17, Pipeline Parallelism: layer blocks + the bubble; Try These Experiments, item 4, PP bubble break-even
Only this timeline and exercise. Assume equal forward stage times and independent microbatches; do not import a training backward schedule.
Focus on
- Reuse All-to-all and MoE dispatch, combine and load balance. In serving, small decode batches can expose startup and hot-expert delay even when the aggregate dispatch byte count is small.
- With equal stages, ready independent microbatches and stage time , a transfer-free forward pipeline finishes in . Idle fraction is ; autoregressive feedback and uneven stage times invalidate that simple schedule.
- Expert placement changes which assignments cross a slow link. Replicating the same expert preserves its function; changing top-k choices or overflow semantics does not automatically preserve model quality.
- Context parallelism partitions positions; TP commonly partitions heads. Exact global attention still incorporates every permitted position using communicated KV blocks or partial softmax statistics. Sequence parallelism can instead mean partitioning intermediate activations around TP - state the axis, not just the acronym.
Common mistakes · 3
- Using a full-training pipeline bubble formula for forward-only inference, or treating future tokens of one request as already available microbatches.
- Placing paired hot experts together without checking compute imbalance. Fewer remote bytes can still leave one rank on the critical path.
- Summing locally normalized attention outputs. Each slice has a different softmax normalizer; exact merging must reweight them.
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.Does PP make four equal stages execute one isolated request simultaneously?Answer
No. Its activations traverse all four stages in order. Other independent requests can occupy the remaining stages; the isolated request retains the full dependency chain.
2.Why is an expert replica different from rerouting to another expert?Answer
A replica computes the same expert function with the same weights. A different expert generally computes a different function, changing the model output.
3.Do position shards let exact causal attention ignore distant earlier positions?Answer
No. Those positions remain legal keys. Their contributions must reach the query through KV exchange or a correctly normalized partial-result merge.
4.What does a slow PP stage do to steady-state capacity?Answer
It limits the rate at which microbatches can leave the pipeline. More stages or a low average stage time cannot remove that bottleneck.
Practice
- 100 Days of Inference, Day 17: PP bubble break-even
Try These Experiments, item 4: find the minimum microbatch count for idle fraction strictly below 10 percent with 4, 8 and 16 stages
Check your integer boundary by enumerating the forward timeline on CPU. The notebook has no public grader; add your own tests. The section mini-project covers expert skew and context-partition accounting.
You're done when
Your timeline agrees with the hand makespan and each integer bubble boundary, and you can name the partition axis, communication dependency and serving bottleneck for PP, EP and context parallelism.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 10 more in the section
- AI Systems Performance Engineering - Chapters 15 and 17, distributed and disaggregated inferenceChris Fregly (O'Reilly) · required
Read the disaggregated prefill and decode architecture and the MoE parallelism strategies in Chapter 15, then Chapter 17 on disaggregated pools, routing policies and scalability. Reproduce every communication and KV-transfer estimate for a small declared topology.
- 100 Days of LLM Inference - Days 12, 17 and 18Elizabeth Thomas · support
Use the Dynamo, model-parallelism and disaggregation notebooks for a compact topology simulator and request-handoff trace. Label notebook outputs as local analytical or simulated evidence unless real devices were used.
- LLM Inference: From scratch, one token at a time - Module 09Tushar Amrit · support
Work the Distributed Inference module's communication arithmetic before the tensor and pipeline parallel units.
Also in this section
- DistServe: Disaggregating Prefill and Decoding for Goodput-Optimized LLM ServingPeking University and Microsoft Research · primary
Read the interference model, independent phase parallelism, placement, KV transfer and goodput evaluation. Reuse the break-even method with your workload and topology; do not transfer the paper's speedups to different hardware.
- AI Systems Performance Engineering companion code - Chapters 15 and 17Chris Fregly · required
Use the single-device KV-handoff and simulation paths before the multi-GPU pairs. Then choose one disaggregation, routing or MoE target compatible with available hardware and keep bundled results separate from newly captured evidence.
- Hands-On LLM Serving and Optimization - Chapter 7, multi-GPU and disaggregationChi Wang and Peiheng Hu (O'Reilly) · support
Read "Multi-GPU and Multi-Node Inferencing" (data, tensor, pipeline and expert parallelism) and "Prefill-Decode Disaggregation" (architecture, KV transfer, when to use it) in Chapter 7.
- NVIDIA Dynamo - Disaggregated Serving and KV-Aware RoutingNVIDIA · required
Trace frontend, prefill router, prefill worker, KV transfer, decode routing and decode worker. Record how load, cache overlap, worker discovery and transfer metadata affect placement; implement only a small simulated or available-hardware slice.
- TensorRT-LLM Disaggregated Serving and KV Cache ExchangeNVIDIA · required
Study the KV exchange abstraction, unique request identity, layout conversion, overlap and fleet-worker model. Use its reproducible benchmark sections only on supported hardware and pin the release.
- SGLang documentation - PD DisaggregationSGLang Project · support
Use the transfer backends, router integration, heartbeat, timeout and cleanup behavior as a second engine's view of the same handoff.
- Mooncake: A KVCache-Centric Disaggregated Architecture for LLM ServingMoonshot AI · support
Read the KV-centric architecture, transfer engine and scheduling sections to understand remote cache pools. Compare its assumptions with DistServe and your simpler handoff; defer reproduction requiring a large cluster.
- TensorTonic Language Modeling from Scratch - Route Cache-Aware Prefill RequestsTensorTonic · support
Solve after the routing unit and compare its cost rule with your own placement model.
- AI Performance Engineering - Distributed InferenceWafer · reference
A curated index. Use Section 5 only to find a distributed-serving paper the other entries lack.
- Python 3.14 hashlib - byte digests for KV integrity checksPython Software Foundation · reference
Usage and Hash Objects only: compute and compare a SHA-256 digest over a declared canonical KV payload. Add request/version checks separately; a byte digest is not cache compatibility or authentication.