cuda_graph_trace_compaction
CUDA Graph Trace Compaction
CUDA graph replay gives each captured region its own stream, so a profiler
trace opens in Perfetto as hundreds of near-empty rows.
scripts/compact_cuda_graph_trace.py repacks the slices into a few semantic
lanes (compute, NCCL all-gather, reduce-scatter, ..., memcpy, memset).
Visualization only. Slices keep their name, pid, ts, dur, and args
-- only the display placement (tid/args.stream) changes. Hand the user the
original for measurement and the compacted copy for reading.
The script is agent-maintained, not a torchtitan API -- edit it for the trace
in front of you rather than working around it. Common tweaks: _classify_slice
and GROUP_ORDER/GROUP_LABELS for new lane groupings, PP_ANNOTATION_PATTERN
for a different annotation scheme. Keep the tests passing.