Communication-computation overlap
Construct the dependency and resource timeline before treating asynchronous submission as hidden communication time.
On this page
The question for today
What you’ll understand
- Compare serial time with an ideal independent-resource overlap bound.
- Identify producer, collective, and consumer stream dependencies.
- Explain how bucket size and shared memory bandwidth can change the training critical path.
A training timeline can launch gradient communication before all backward computation finishes. That creates an opportunity to hide part of the communication behind independent work. It does not guarantee overlap. Gradients must exist before they are sent, consumers must wait for completed reductions, and both activities may compete for accelerator cores, memory bandwidth, or scheduling resources.
Draw dependencies before drawing overlapping rectangles
A gradient bucket becomes eligible only after all its contributing producers have finished. The communication operation can then read that bucket on a stream whose dependencies include those producers. An optimizer must not consume the reduced result before the appropriate completion dependency. Separate streams permit independent scheduling but do not create missing data or remove a true dependency. An incorrectly omitted event can appear fast by reading incomplete gradients, while an unnecessary global synchronization can serialize work that was genuinely independent.
NCCL 2.32.3 documents stream-ordered collective submission and group behavior. MPI 4.1 nonblocking collectives have a different request-completion interface and implementation-dependent progress characteristics. In either case, a successful host return is not the same measurement as communication completion. Confirm the linked library/runtime and progress environment before inferring that time spent on the CPU is available to drive another operation. A queued asynchronous call may wait behind earlier stream work or consume resources needed by the computation it was supposed to overlap.
Shared resources can invalidate standalone-time assumptions
A collective kernel can read and write device memory while the next backward kernel needs the same bandwidth. Both standalone durations can then change when run together. Concurrent launch does not imply independent-resource execution, and actual combined time can be worse than a naïve sum of isolated measurements if the schedule creates extra contention or stalls. Compare end-to-end step time and useful progress as well as the fraction of a profiler timeline containing visually overlapping activity. Overlap is a means of shortening the critical path, not a cosmetic occupancy target.
Bucket size trades startup overhead against readiness and scheduling. A large fused bucket amortizes communication launch but waits for its last gradient producer. Smaller buckets can begin earlier yet pay more per-call startup and retain additional state. The best partition depends on parameter order, backward compute times, datatype, network behavior, and resource contention. Preserve matching collective order across ranks while changing bucket layout; a faster local readiness sequence is not valid if different ranks launch incompatible collectives.
Measure the remaining exposed communication
Record when each bucket becomes ready, when its communication actually starts, and when the next dependent consumer can proceed. The last collective often leaves an exposed tail after backward computation ends; optimizing earlier collectives may not shorten that tail. Include CPU launch gaps, event waits, and variation across ranks. Use synchronized measurement boundaries appropriate to the tool, while avoiding instrumentation that forces serialization and destroys the behavior being studied. Validate that numerical output and rank sequence remain correct after every scheduling change.
The queue lab isolates one contention-style capacity mismatch. Reset, set both λ=4 and μ=3, predict one normalized work unit of backlog growth per second from four, then Play or Step. Separately Reset, set both λ=2 and μ=3, predict drainage at t=4, then Play or Step. These separate fluid runs do not execute CUDA streams, kernels, or overlapping communication. They show why additional concurrent submissions can increase waiting rather than service capacity. The M/M/1 mean has separate assumptions; a real overlap claim still needs its actual dependency and shared-resource timeline.
Work it through
The ideal overlap limit leaves a measurable tail
A simplified interval has forty milliseconds of computation and thirty milliseconds of communication, both ready at its start. First assume independent resources and perfect overlap; then suppose contention makes computation take fifty milliseconds and communication thirty-five while concurrent.
Serial standalone time is 40+30=70 ms. Ideal independent-resource overlap completes in max(40,30)=40 ms, giving a speedup of 70/40=1.75.
Under the stipulated concurrent slowdowns, even a perfect schedule of those changed tasks needs at least max(50,35)=50 ms. The original forty-millisecond prediction no longer follows.
Compared with the original seventy-millisecond baseline, fifty milliseconds would be a 1.4-fold speedup. Extra launch gaps or dependencies can make it slower still; measure the complete interval rather than assuming asynchronous calls imply the ideal limit.
Overlap saves time only through an actual feasible resource schedule. Standalone task durations are not constants under every concurrent execution.
The living notebook
Explore the model
Interactive lab · queue
More concurrent submissions need not add service capacity
Reset, set both λ=4 and μ=3, predict growth from four at one unit/s, then Play or Step. Separately Reset, set both λ=2 and μ=3, predict drainage at t=4, then Play or Step. This fluid backlog analogy contains no CUDA streams, collectives, or overlap scheduler; M/M/1 assumptions are separate.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forAn overlap claim needs dependency and contention evidence, rather than merely showing that work was submitted concurrently.
Pause & reason
Check your understanding
Your turn
Try it yourself
Two ready independent tasks last eighteen and twelve milliseconds on separate resources. Compute serial time, ideal overlap time, and ideal speedup. State one dependency that would remove this opportunity.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Compare the sum with the larger duration.
Compare with the solution
Serial time is thirty milliseconds, ideal overlap is eighteen, and speedup is 30/18≈1.667. If the twelve-millisecond task requires the final output of the eighteen-millisecond task before starting, their true dependency makes this complete overlap impossible. Shared-resource contention or launch gaps can also change the model.
Keep the idea
Take it with you
- Asynchronous submission does not establish completed communication or actual overlap.
- Respect producer and consumer dependencies across streams or requests.
- Optimize exposed critical-path time while accounting for shared resources and bucket readiness.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.