Distributed workload profiling follows unfinished dependencies to the synchronized step boundary before selecting an optimization.
Summary
Which dependency must finish before the next optimizer transition can begin? Compare these hypothetical schedules, holding work and numerical results fixed. Assume aligned clocks and no compute/network resource interference.
| Schedule | Compute interval, ms | Collective interval, ms | Completion, ms | Exposed tail, ms |
|---|---|---|---|---|
| Overlap | 0..10 | 4..10 | 10 | 0 |
| Serialized | 0..10 | 10..16 | 16 | 6 |
Both schedules contain sixteen milliseconds of aggregate activity, but only one needs sixteen milliseconds of elapsed time. The retained schematic also changes compute length; use the table, not that extra difference, to isolate overlap alone.
Learning objective: distinguish an operation’s total duration from the exposed portion that extends synchronized step time.
Critical-path accounting
Two step traces with the same collective duration but different exposed time
Reference drawing
Critical-path accounting
Only the collective time exposed beyond useful computation extends the step
Derivation
Read the trace from the outside in
1. Mark the training or inference step
Let compute finish at , a ready collective start at , and its duration be . If both results are required, completion is . The network tail is , not automatically . This simplified model excludes additional dependencies and interference. Launching an asynchronous operation does not establish that its result is ready.
2. Find large idle gaps
Trace each wait back to input readiness, a producing kernel, another rank, or host synchronization. If one rank’s required bucket is ready at twelve ms, the collective cannot start at four ms. With a six-ms collective, completion is at least eighteen ms in this simplified arrival model. Inspect all ranks, not only the fastest backward pass.
3. Find the longest exposed operations
Moving the six-ms collective inside the ten-ms compute window saves six ms in the controlled example. Halving a completely hidden collective saves zero ms there. Resource contention can invalidate either prediction; measure the resulting compute duration too.
Run controlled experiments
Keep shapes, batch, dtype, topology and timing scope fixed. Check numerical outputs before accepting a speedup. Record one hypothesis, change, predicted boundary movement, correctness result, measured median/tail, trace difference and keep/revert decision. Retain unsuccessful trials.
Change bucket readiness
New task: overlap the last bucket without using gradients before they exist.
Picture and change: move readiness from ten ms to four ms by changing bucket order or size. The six-ms collective then ends at ten instead of sixteen ms, if compute remains unchanged.
Check: a bucket ready at nine ms ends at fifteen ms; the tail is still five ms. An earlier API call without earlier data readiness does not produce the predicted gain.
Use when: the trace shows a genuinely exposed final communication bucket.
Change tensor handoff
New task: remove a redundant gather/reshard between adjacent operations.
Picture and change: a serial handoff costs two ms around ten-ms useful work, giving twelve ms total. A compatible producer/consumer layout removes that event, predicting ten ms before resource effects.
Check: two ranks holding additive partial results two and three represent five, not two. Removing their reduction is incorrect, even if the trace becomes shorter. Verify global outputs, communication semantics and temporary memory peaks.
Use when: layout conversion, rather than required mathematical reduction, extends the dependency path.
Reconstruct the diagnosis
Why can a shorter local backward pass leave the synchronized step unchanged?
Reasoned answer
Another rank or required transfer may still finish later. Compare input-ready, kernel and collective timestamps on aligned clocks. Only movement of the completion dependency establishes a step-time improvement.
Why AI labs care
Low utilization can reflect input stalls, small kernels, memory traffic, network waits, pipeline bubbles or host work. It does not identify a repair.
Start with stable measurements
Verify correctness, exclude compilation/warmup and capture several representative steady steps. Store software versions, topology, shapes, seed and profiler settings. State whether median and p95 measure rank-local device work or synchronized wall-clock steps. Check instrumentation overhead and clock alignment.
Build three lower bounds
Compute bound
Useful FLOPs divided by applicable peak FLOPs gives an optimistic compute-time floor. State precision and the FLOP convention.
Memory bound
Bytes moved divided by effective bandwidth bounds a specified kernel’s memory time. Roofline compares intensity against the compute/bandwidth ratio.
Communication bound
Use latency plus per-device bytes divided by measured collective bandwidth for the matching message size and group. Peak link bandwidth is insufficient. These bounds may overlap; adding them is not a general elapsed-time bound.
4. Group kernels by type
Separate matmuls, attention, elementwise work, copies and collectives. Tiny kernels suggest launch/fusion investigations; poor matmul shapes suggest a different experiment.
5. Compare ranks
Compare input lengths, arrivals, device clocks, network placement and thermal behavior.
Common trace patterns
| Pattern | Discriminating check |
|---|---|
| Early idle gap | input-ready timestamp |
| Tiny kernels and gaps | launch overhead versus fusion |
| Late bucket | readiness and rank arrivals |
| Repeated reshard | producer/consumer layouts |
| Pipeline bubbles | stage balance and microbatches |
Profiling a sharded program
Record layouts and identify inserted gathers, reduce-scatters, all-reduces, all-to-alls and host transfers. Preserve the distinction between complete values and additive partial results.
Profiling compilation
Match source operations and shapes to compiled fusions, device kernels, communications and allocation peaks. One source operation need not correspond to one kernel.
In an interview
Define the workload and metric, locate the completion dependency, predict one change, then measure correctness and timing together.
Common mistakes
One fast warmup-contaminated sample is not a steady-state speedup. Changing batch size confounds a kernel comparison. Synthetic timelines establish arithmetic, not measured hardware performance.
Related: GPU memory hierarchy, strong scaling and parallelism selection, and optimize an accelerator workload. Further reading: profiling in the JAX Scaling Book.