Unit 1 of 11 · about 4 hours · explain, derive
Replica serving and tensor-parallel inference shapes and collectives
A router distributes requests across replicas; tensor parallelism distributes one request's model work across ranks. Confusing the two gives the wrong capacity estimate and the wrong recovery boundary.
You'll be able to
- Distinguish independent serving replicas from ranks cooperating on one forward pass, including their request-level fault domains.
- Derive local MLP and attention projection shapes for a tensor-parallel serving plan.
- Place forward collectives and explain why added memory capacity need not reduce small-batch latency.
Covers
Read
In this order, only the parts listed
0 of 2 done
- Replicas versus model shardsHands-On LLM Serving and Optimization - Chapter 7, multi-GPU and disaggregation
Chapter 7, Data Parallelism, printed pp. 243 to 245; Tensor Parallelism and Pipeline Parallelism, printed pp. 245 to 250
Read the replica and TP paths now. Leave the pipeline decision path for the next unit; do not run the multi-GPU launch snippet.
- The paired column and row shardsLLM Inference: From scratch, one token at a time - Module 09
Module 09, Tensor parallelism: split inside the layer - The MLP block and The attention block
Stop before Communication volume. Two reductions per layer describes this replicated-activation dense forward schedule, not every TP implementation.
Focus on
- Reuse Collective contracts and the latency-bandwidth cost model. Serving replicas do not synchronize gradients; a replica can itself contain a TP group.
- For input of shape , column-shard the first MLP weight of shape , then row-shard the second of shape . Each local intermediate has shape for divisible width and ranks.
- An elementwise activation stays local between these shards. The second projection produces same-shaped partial outputs that sum, not concatenate. Add a replicated output bias once after summation.
- Attention head shards can compute independently before the output projection reduction. KV-head replication and vocabulary-parallel output paths need separate ownership accounting.
Common mistakes · 3
- Counting replicas as additional memory for a single request. Each independent replica needs the full model and its own admitted KV state.
- Calling every column-sharded output an all-reduce. Disjoint output features concatenate; row-sharded dot-product contributions sum.
- Promising a latency speedup from rank count. Smaller kernels, startup costs and dependencies can consume the extra compute or memory bandwidth.
Try it yourself
Closed-book, before checking anything
float64 tensors. State a numerical tolerance rather than demanding bitwise equality.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Does inference replica serving require the training gradient all-reduce?Answer
No. Independent requests run forward passes against fixed weights. Shared routing or cache metadata is a separate control-plane concern.
2.Why can the first projection's activation remain local?Answer
Each rank owns complete values for its output features, and ReLU acts independently on each feature. No partial sum is needed before that activation.
3.What shape does each second-projection partial have in the reproduce example?Answer
. Each rank multiplies a intermediate by its weight rows; the two partials sum to the full output.
4.Can replicas lower endpoint latency without making the forward pass faster?Answer
Yes. Distributing arrivals can reduce queueing. It does not shorten the isolated forward service time on an unchanged replica.
You're done when
Your paired-shard MLP matches the unsharded reference within the stated tolerance, and your diagram separates replica routing from TP collectives and their fault domains.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 11 more in the section
- 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.
- 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 - 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.
- 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.
- 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.
- 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.
- 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.