Unit 9 of 14 · about 4 hours · measure

Kernel launch gaps and rank and node straggler localization

Thousands of tiny launches leave the accelerator idle between kernels, and one slow rank holds every barrier. Both look like low throughput until per-rank timelines separate them.

You'll be able to

  • Detect kernel launch gaps and small-operation overhead from kernel counts and non-matmul fractions.
  • Localize a rank or node straggler by elimination with per-rank timings.
  • Apply graphs or fusion only after traces identify launch overhead as the dominant cost.

Covers

Kernel launch gaps and small-operation overheadRank and node straggler localization
1

Read

In this order, only the parts listed

0 of 4 done

  1. CUDA graphs for launch overheadAI Systems Performance Engineering - Chapters 1 to 5, 13 and 14

    Chapter 13, Reducing Kernel Launch Overhead with CUDA Graphs, with Capturing a CUDA Graph and Preallocating Memory and Best Practices for CUDA Graphs

  2. Straggler detection and mitigationMegaScale: Scaling Large Language Model Training to More Than 10,000 GPUs

    arXiv:2402.15627v1, Section 5: straggler detection, mitigation and diagnosis tooling with measured MFU attached

  3. Kernel census from tracesCS336 Assignment 2 (Spring 2026) - Profiling and Parallelism Analysis

    Section 2.1.4 nsys_profile in the Spring 2026 handout: top CUDA kernels, non-matmul share and the AdamW matmul fraction

  4. Gray stragglers at fleet scaleMachine Learning Systems Volume II - Fleet Orchestration and Performance Engineering

    Measurement at Scale with tiered canaries and gray straggler detection, and System Profiling with bottleneck patterns

2

Focus on

  • Launch gaps show as many short kernels with CPU time between them and a high non-matmul share. Small payloads are launch bound: in the MLSys example, a 32.8 KB tensor-parallel all-reduce at batch size 1 takes about 36 ns on 900 GB/s NVLink, against about 5 microseconds of launch overhead.
  • Localize stragglers with per-rank step times and barrier waits, then eliminate by node subset. Report max versus median, never the mean alone.
  • torch.cuda.CUDAGraph replay removes Python and launch gaps for static shapes. It is the fix only when the trace already proves launch dominates.
Common mistakes · 3
  • Fusing kernels before traces identify launch as dominant. Kernel work without a measured launch bottleneck adds complexity for no step-time gain.
  • Averaging rank times. One slow rank hides inside a healthy mean; max versus median exposes it.
  • Calling a barrier waiter slow. The waiter is the victim of the straggler that arrives last.
3

Try it yourself

Closed-book, before checking anything

Without notes, take one profiler trace and compute the top kernel by time, the non-matmul time share, and max versus median rank step time. State launch-bound, kernel-bound or straggler-bound with the numbers.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.What trace signature says launch-bound?Answer

    High kernel count with short mean duration, visible CPU gaps between launches, and a large non-matmul time share.

  2. 2.Ranks report steps of 100, 102, 99 and 250 ms. What do you report?Answer

    A straggler on the fourth rank: median about 101 ms, max 250 ms. The mean hides it; investigate that rank or node first.

  3. 3.When do CUDA graphs help, and what breaks them?Answer

    They help when launch overhead dominates at static shapes. Dynamic shapes, data-dependent control flow and host syncs break capture or force recapture.

5

Practice

  • CS336 Assignment 2: nsys_profile kernel census

    Section 2.1.4 nsys_profile in the Spring 2026 handout; report the top kernels, the non-matmul share and whether launch or kernels dominate

    Nsight needs NVIDIA tooling. On CPU use the PyTorch profiler kernel list as the portable substitute and state the substitution.

You're done when

Your trace census names launch, kernel or straggler as the dominant cost with per-rank max versus median evidence.

Only when you can do this without notes.

Leads to

Notes

Resources · 4 for this unit, 7 more in the section
  • Machine Learning Systems Volume II - Fleet Orchestration and Performance EngineeringML Systems Textbook · primary

    Read Scheduling Problem, Orchestration Paradigms, Topology-Aware Scheduling, Elastic Scheduling, Cost Optimization, Multi-Tenancy and Quotas and Debugging Cluster Utilization, then Memory Wall and Roofline Diagnosis, Graph Compilation, Communication-Computation Overlap, System Profiling and Measurement at Scale at https://mlsysbook.ai/vol2/performance_engineering/performance_engineering.html. Use the framework to choose one bottleneck-specific lab and one rollback metric.

  • AI Systems Performance Engineering - Chapters 1 to 5, 13 and 14Chris Fregly (O'Reilly) · required

    Use Chapter 1 for goodput and reproducibility, Chapters 2 to 5 for topology, orchestration, communication, storage and the data pipeline, Chapter 13 for PyTorch profiling and scaling, and the Chapter 14 sections on graph breaks and recompilation. Run only the companion labs for the bottleneck you observe, preserve workload correctness and record hardware assumptions.

  • MegaScale: Scaling Large Language Model Training to More Than 10,000 GPUsJiang et al. (NSDI 2024) · support

    Read the efficiency optimizations, the fault-tolerance loop (heartbeats, diagnostics, fast restart) and the straggler and diagnosis tooling. Its MFU and scale numbers are its own cluster's results.

  • CS336 Assignment 2 (Spring 2026) - Profiling and Parallelism AnalysisStanford University · required

    Revisit Section 2 profiling and Section 8 communication analysis. Produce warmup-controlled timing, Nsight or PyTorch traces, memory evidence and analytic DP, FSDP, TP and 2D comparisons on configurations you can execute honestly.

Also in this section

  • Machine Learning Engineering Open Book - Network, Debug, Training Performance and OrchestrationStas Bekman · required

    Use network/debug/README.md, the hang, crash and OOM sections of debug/pytorch.md, training/performance/README.md, storage/README.md and orchestration/slurm/users.md as an incident-driven reference. Build one symptom-to-evidence-to-cause runbook rather than reading every page.

  • PyTorch Flight Recorder TutorialsPyTorch · support

    Read the environment-variable Flight Recorder tutorial (trace buffer, dump on timeout, fr_trace analysis), then the newer tutorial at https://docs.pytorch.org/tutorials/intermediate/debug_hangs_with_flight_recorder.html, which needs torchcomms and can run on CPU with Gloo. Diagnose one injected hang from per-rank dumps.

  • Revisiting Reliability in Large-Scale Machine Learning Research ClustersKokolis et al. (2024) · support

    Read the failure taxonomy, mean time to failure versus job size and the scheduler-side metrics. Use them to model goodput with failures for one job size.

  • How to Scale Your Model - Chapters 1, 5, 9 and 12Google DeepMind · required

    Use rooflines, training cost models, profiling workflow and GPU topology to predict the dominant limit of one run. Compare the prediction with a trace and quantify the residual before proposing a change.

  • Ultra-Scale Playbook - Benchmarking ConfigurationsHugging Face · support

    Study the configuration-search experiments and Lessons learned on benchmarking as method. Its heatmaps are its own H100 cluster's results; reproduce the method on a tiny legal search space, separating analytic predictions, simulations and measurements.

  • TorchTitanPyTorch · depth

    Read docs/debugging.md (memory snapshots, fake-backend modes, Flight Recorder dumps) and the CPU unit tests under tests/unit_tests/cpu/, then the configuration, metrics, profiling, checkpoint and parallelization seams at a pinned commit. Select one bounded issue or measurable improvement and follow the contribution standards; do not attempt a wholesale rewrite.

  • Distributed Training Systems LaboratoryRoadmap-Final · support

    Complete the capstone with a fixed workload, correctness oracle, analytic plan, fault campaign, aligned traces and one real-code extension. Label CPU simulation, single-GPU evidence and multi-GPU evidence separately.