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

Pipeline-parallel inference stages and bubblesExpert-parallel MoE dispatch and combineContext and sequence parallelism vocabularyTopology-aware MoE expert placement
1

Read

In this order, only the parts listed

0 of 3 done

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

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

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

2

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

Try it yourself

Closed-book, before checking anything

Draw the transfer-free forward timeline for four equal 2 ms stages and eight ready independent microbatches. Recover a 22 ms makespan and idle fraction . Then add the dependency from the final sampled token to the same request's next decode pass and explain why eight successive tokens of one request cannot fill the pipeline like eight independent microbatches.
4

Quiz yourself

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

0 got · 0 missed

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

5

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

Also in this section