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_trace tool to separate first cause from synchronization victims.
  • Distinguish PyTorch-level recorder controls from NCCL-level transport controls.

Covers

NCCL traces, flight recorder and desynchronization reports
1

Read

In this order, only the parts listed

0 of 3 done

  1. 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_TIMEOUT and TORCH_FR_DUMP_TEMP_FILE (page read 2026-10-14)

  2. 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=gloo and TEST_DEVICE=cpu (page read 2026-10-14)

    The tutorial runs on CPU with TEST_BACKEND=gloo and TEST_DEVICE=cpu, but it needs the separate torchcomms package, and its pip install torchcomms line 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.

  3. 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 with TORCH_FR_BUFFER_SIZE and TORCH_FR_DUMP_TEMP_FILE, and NCCL_DEBUG=INFO with NCCL_DEBUG_SUBSYS

2

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_trace analysis aggregates per-rank pickles and shows states and sequence numbers. A collective with matching collective_seq_id across ranks but a missing rank points at the rank that never arrived.
  • TORCH_FR_BUFFER_SIZE and TORCH_NCCL_DUMP_ON_TIMEOUT are PyTorch recorder controls. NCCL_DEBUG and NCCL_DEBUG_SUBSYS are NCCL transport controls. Before PyTorch 2.9 the buffer variables carried TORCH_NCCL_ names that still work with a warning.
Common mistakes · 3
  • Mixing recorder and transport layers. NCCL_DEBUG=INFO shows 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_reduce and their sequence ids, but the automatic dump on timeout comes from the NCCL watchdog. A CPU drill needs an explicit dump: the private torch._C._distributed_c10d._dump_fr_trace() returns the pickled trace as bytes.
3

Try it yourself

Closed-book, before checking anything

Closed-book, list the variables that arm dump-on-timeout and the analysis command: 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_.
4

Quiz yourself

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

0 got · 0 missed

  1. 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. 2.The aggregated dump shows a collective with missing_ranks holding one rank. What does that mean?Answer

    That rank never reached the collective with the matching sequence number. It is the first suspect; the waiting ranks are victims.

  3. 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 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.

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 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.