Unit 5 of 9 · about 4 hours · measure
Compute-communication overlap and communication streams
Overlap is where data-parallel scaling comes from: buckets reduce while later layers still compute. A missing dependency or a stray sync turns it back into serial time.
You'll be able to
- Diagnose serialized or non-overlapping communication from a timeline, naming the dependency that serializes it.
- Measure exposed communication with streams and events, and attribute the remaining tail to bucketing, ordering or hardware.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Overlap, streams and bucket tuningAI Systems Performance Engineering - Chapters 4, 15, 17 and 18
Chapter 4, Overlapping Communication and Computation (Pipelining); Asynchronous Execution with Streams; Reducing Communication Frequency and Volume; Achieving Maximal Overlap in Practice
- Stream semantics and grouped launchesNCCL
CUDA Stream Semantics: collectives enqueue asynchronously to the calling stream; order across streams needs events; group calls under
ncclGroupStartandncclGroupEnd - Overlapped versus serial data-parallel pathsAI Systems Performance Engineering companion code - Chapters 4, 15 and 17
ddp_overlap.pyagainstddp_no_overlap.py: bucketed reduction while compute continues, with the exposed tail isolated
Focus on
- Overlap needs two things: a dedicated communication stream with correct event dependencies, and ready compute to cover each bucket. Streams alone create no parallelism; backprop order supplies the covering work as each bucket fills.
- Bucket size trades launch count against exposure. The default 25 MB bucket launches reductions as soon as buckets fill, and only the tail (roughly the last bucket) stays exposed when compute covers the rest.
- Larger buckets delay the first launch and enlarge the exposed tail; smaller buckets add launch overhead. Gradient accumulation divides all-reduce frequency by the accumulation count before any overlap tuning matters.
- Host-side sync on the critical path (value reads, prints, logging, device synchronize) forces the very serialization overlap removes. Profile first, then delete the sync, then retune buckets.
Common mistakes · 3
- Launching communication and compute on two streams with no dependency and calling it overlap. Without event ordering the consumer can read a buffer the collective has not finished, and without covering work the timeline just shows two serial kernels.
- Tuning bucket size while a logging
.item()sits in the loop. The sync dominates the exposed time, so every bucket measurement is really a measurement of the logging. - Expecting overlap to help when communication dwarfs compute. Overlap hides the smaller side; a bandwidth-bound collective with tiny covering compute stays exposed almost in full.
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.Which stream runs an NCCL collective, and how do other streams wait for it?Answer
The calling stream the collective was enqueued to. Other streams wait through recorded events, not through host synchronization.
2.Why does only the last bucket stay exposed when compute covers communication?Answer
Each earlier bucket reduces while later layers still compute. The last bucket has no later compute left to hide behind, so its communication time remains.
3.What timeline pattern proves overlap rather than fast kernels?Answer
Communication and compute ranges concurrent on different streams with end-to-end time below their sum, plus identical outputs to the serial run.
4.Gradient accumulation over 4 minibatches changes what before overlap is tuned?Answer
It cuts all-reduce frequency by 4x, shrinking total communication first. Overlap tuning then applies to a smaller remaining cost.
Practice
- AI Systems companion code ch04: overlapped versus non-overlapped DDP
Run
ddp_overlap.pyagainstddp_no_overlap.pywithtorchrunwith two GPUs and attribute the difference with a rank timelineTargets that fail fast with SKIPPED: on unsupported hosts are blockers, not results; record the topology dump with the run. With one GPU, model the exposed tail analytically checked against published nccl-tests results, or use a recorded public trace, and label it simulation.
You're done when
Your timeline shows concurrent communication and compute with matching outputs, and you can name the bucket or dependency behind every exposed millisecond.
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 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/ch15andcode/ch17for 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.
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.pycases and pytest files. It runs on CPU processes with Open MPI andmpi4py. - CS336 Assignment 2 - Section 8.1 Communication PrimitivesStanford University · support
Work
alternate_ring_all_reduceand 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.
- 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.
- 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.