Unit 5 of 14 · about 3 hours · measure
NCCL traces, Flight Recorder and desynchronization reports
A hung job parks every rank inside the same collective wait. The desync report and recorder history name the rank that never arrived.
You'll be able to
- Enable the desynchronization report and Flight Recorder controls and read which rank and collective fell out of step.
- Analyze per-rank dumps with the
fr_tracetool to separate first cause from synchronization victims. - Distinguish PyTorch-level recorder controls from NCCL-level transport controls.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Flight Recorder for stuck jobsPyTorch Flight Recorder Tutorials
Enabling Flight Recorder through Analyzing Flight Recorder Dumps, with
TORCH_NCCL_TRACE_BUFFER_SIZE,TORCH_NCCL_DUMP_ON_TIMEOUTandTORCH_FR_DUMP_TEMP_FILE(page read 2026-10-14) - Hangs with TorchComms and the debug serverPyTorch Flight Recorder Tutorials
The Scenario through Running the FR CLI on Per-Rank Pickle Dumps, with
TEST_BACKEND=glooandTEST_DEVICE=cpu(page read 2026-10-14)The tutorial runs on CPU with
TEST_BACKEND=glooandTEST_DEVICE=cpu, but it needs the separate torchcomms package, and itspip install torchcommsline fetches a PyPI placeholder (0.0.1) whose import raises "can't be installed via PyPi"; install it as the torchcomms README describes. Treat dump reading as the core skill and the CPU run as optional. - Desync reports, recorder traces and NCCL transport logsMachine Learning Engineering Open Book - Network, Debug, Training Performance and Orchestration
Diagnosing crashes hangs and tracing execution: The desync report with
TORCH_NCCL_DESYNC_DEBUG, The flight recorder trace withTORCH_FR_BUFFER_SIZEandTORCH_FR_DUMP_TEMP_FILE, andNCCL_DEBUG=INFOwithNCCL_DEBUG_SUBSYS
Focus on
- The desync report names the rank and collective that fell out of step at timeout. The recorder adds per-rank collective history with Python stacks. Enable both before launching; dumps are post-mortem.
- The
fr_traceanalysis aggregates per-rank pickles and shows states and sequence numbers. A collective with matchingcollective_seq_idacross ranks but a missing rank points at the rank that never arrived. TORCH_FR_BUFFER_SIZEandTORCH_NCCL_DUMP_ON_TIMEOUTare PyTorch recorder controls.NCCL_DEBUGandNCCL_DEBUG_SUBSYSare NCCL transport controls. Before PyTorch 2.9 the buffer variables carriedTORCH_NCCL_names that still work with a warning.
Common mistakes · 3
- Mixing recorder and transport layers.
NCCL_DEBUG=INFOshows devices and sockets, not which Python collective mismatched. - Using the pre-2.9 buffer names without knowing they warn. Old and new names both arm the recorder, but only the new names are quiet.
- Assuming CPU runs record nothing. In PyTorch 2.14.1 the recorder also logs gloo collectives, with entries such as
gloo:all_reduceand their sequence ids, but the automatic dump on timeout comes from the NCCL watchdog. A CPU drill needs an explicit dump: the privatetorch._C._distributed_c10d._dump_fr_trace()returns the pickled trace as bytes.
Try it yourself
Closed-book, before checking anything
TORCH_FR_BUFFER_SIZE=2000, TORCH_NCCL_DUMP_ON_TIMEOUT=1 and TORCH_FR_DUMP_TEMP_FILE=/tmp/fr/rank_ (one file per rank, /tmp/fr/rank_0 and so on), plus TORCH_NCCL_ENABLE_MONITORING=1, which the installed ProcessGroupNCCL.hpp requires for the dump, then python -m torch.distributed.flight_recorder.fr_trace /tmp/fr -p rank_.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.What does the desync report add over a bare timeout?Answer
It names which collective and which rank fell out of step, instead of leaving every rank parked in the same wait with no attribution.
2.The aggregated dump shows a collective with
missing_ranksholding one rank. What does that mean?AnswerThat rank never reached the collective with the matching sequence number. It is the first suspect; the waiting ranks are victims.
3.Which controls belong to PyTorch and which to NCCL?Answer
PyTorch owns the recorder buffer, dump-on-timeout and dump path. NCCL owns
NCCL_DEBUG,NCCL_DEBUG_SUBSYS, interface selection and transport logging.
You're done when
You can arm the recorder variables from memory and read a desync plus fr_trace output down to the first-cause rank.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 9 more in the 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 ofdebug/pytorch.md,training/performance/README.md,storage/README.mdandorchestration/slurm/users.mdas 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_traceanalysis), then the newer tutorial at https://docs.pytorch.org/tutorials/intermediate/debug_hangs_with_flight_recorder.html, which needstorchcommsand can run on CPU with Gloo. Diagnose one injected hang from per-rank dumps.
Also in this 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.
- 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.
- 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.
- 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 undertests/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.