Skip to content

Feature/rfc 2408 compute comms overlap - #3020

Merged
tianyu-l merged 13 commits into
mainfrom
feature/rfc-2408-compute-comms-overlap
Apr 18, 2026
Merged

tianyu-l merged 13 commits into
mainfrom
feature/rfc-2408-compute-comms-overlap

Conversation

@yushangdi

@yushangdi yushangdi commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Land #2418

Summary

Adds an automated compute-communication overlap diagnostic to help identify communication bottlenecks in FSDP2 training. Implements #2408

Motivation

Achieving high MFU in large-scale training requires effective overlap of compute and NCCL communication. Currently, identifying "communication bubbles" requires manually downloading multi-GB trace files and inspecting them in Chrome Trace Viewer. This feature provides an immediate diagnostic signal directly in the logs.

Changes

New Feature: CommsComputeOverlapAnalyzer

  • Analyzes profiler traces to compute overlap efficiency between compute kernels and NCCL operations
  • Reports Total Compute Time, Total NCCL Time, Total Active Time, Overlap Efficiency, and GPU time unutilized due to NCCL comms
  • Enabled via --profiler.enable_overlap_analysis flag (off by default)

Implementation Details

  • Uses prof.events() to collect raw CUDA kernel events and their wall-clock time intervals
  • Classifies kernels by name: nccl for communication; gemm, aten, cublas, cudnn, cutlass, triton, flash for compute
  • Computes the union of time intervals per category using interval merging, correctly deduplicating concurrent kernels across CUDA streams
  • Overlap is derived as compute_us + comm_us - active_us, where active_us is the union across both categories

Example Output

Llama 3 8B (8B params) on 2x H200:

[CommsComputeOverlapAnalyzer] Compute-Communication Overlap Report
  Total Compute Time               : 165.12 ms
  Total NCCL Time                  : 255.94 ms
  Total Active Time                : 386.52 ms
  Overlap Efficiency               : 13.5 %
  GPU Unutilized due to NCCL comms : 86.5 %

Debug model (6M params) on 2x H200:

[CommsComputeOverlapAnalyzer] Compute-Communication Overlap Report
  Total Compute Time               : 4.80 ms
  Total NCCL Time                  : 19.97 ms
  Total Active Time                : 23.83 ms
  Overlap Efficiency               : 4.7 %
  GPU Unutilized due to NCCL comms : 95.3 %

Both results are expected communication-bound baselines with no overlap optimizations enabled. The debug model is more severely bottlenecked because its compute-to-communication ratio (0.24x) is far lower than the 8B model (0.65x) — there is almost no compute to overlap with.

Testing

Tested on 2x NVIDIA H200 with:

  • Llama 3 8B:
    NGPU=2 ./run_train.sh --module llama3 --config llama3_8b \
      --hf_assets_path=./tests/assets/tokenizer \
      --profiler.enable_profiling --profiler.profile_freq=10 \
      --profiler.enable_overlap_analysis --training.steps=20 \
      2>&1 | tee 8B_output.log
    
  • Debug model:
    NGPU=2 ./run_train.sh --module llama3 --config llama3_debugmodel \
      --profiler.enable_profiling --profiler.profile_freq=10 \
      --profiler.enable_overlap_analysis --training.steps=20 \
      2>&1 | tee 6M_output.log
    

Limitations

  • Only CUDA kernels are considered; CPU-side work is excluded
  • Kernels not matching the classify patterns (e.g. custom ops) are excluded from both categories and do not affect the reported overlap percentage

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 17, 2026
@yushangdi
yushangdi force-pushed the feature/rfc-2408-compute-comms-overlap branch from 2c0f7c9 to 5b3ce59 Compare April 18, 2026 00:25
@yushangdi
yushangdi marked this pull request as ready for review April 18, 2026 00:27
@yushangdi

Copy link
Copy Markdown
Contributor Author

added a commit at the end to address the nit comments

  1. naming from prof_session to profiler
  2. removed the changes in train.sh
  3. One of the unit test in test_profiler is failing due to wrong setup, added a mock.patch to fix it.

@yushangdi

yushangdi commented Apr 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Conflicts resolved during rebase to main

1. torchtitan/tools/profiling.py (commit 4/12 — "Refractor to use Profiler.Config pattern")

Main added profiler_repeat, profiler_skip_first, profiler_skip_first_wait fields to the flat ProfilingConfig dataclass. The PR restructured this into a nested Profiler.Config class. Merged the new fields into the nested Config with proper indentation, and fixed stale profiling_config.profiler_* references to cfg.profiler_*.

2. torchtitan/experiments/forge/example_train.py (commit 5/12 — "Make Profiler buildable and other consistency fixes")

Main still imported old-style functions (maybe_enable_memory_snapshot, maybe_enable_profiling). The PR replaced those with the Profiler class. Kept init_logger (still used in the file's main()) and dropped both the old function imports and the PR's stale from torchtitan.train import main.

3. torchtitan/tools/profiling.py (commit 7/12 — "Simplify profiler lifecycle")

Main had an inline MemoryProfiler class definition inside a method. The PR extracted it to a top-level class. Removed the duplicate inline class, keeping the top-level one.

4. torchtitan/experiments/forge/example_train.py (commit 12/12 — "Refactor config system from TOML to Python dataclass registry")

Same init_logger import conflict again (later commit in the PR touched the same line). Kept init_logger.

5. torchtitan/tools/profiler.py — Fix None in profiler activities list

build_torch_profiler() set gpu_device_profiled = None when no CUDA/XPU was available, then passed it directly in the activities list to torch.profiler.profile(). Nightly PyTorch (2.13.0.dev) added stricter validation in _parse_activities() that rejects None. Fixed by building the activities list dynamically — start with [CPU], then append CUDA or XPU only if available. This was caught by the CPU unit test CI.

@yushangdi
yushangdi force-pushed the feature/rfc-2408-compute-comms-overlap branch from 5b3ce59 to 51558c3 Compare April 18, 2026 00:53
@yushangdi

Copy link
Copy Markdown
Contributor Author

8 GPU Model Tests is also broken on main: https://github.com/pytorch/torchtitan/actions/runs/24590708198/job/71910660385

The tranformer test CI is broken and should be fixed by #3022

@tianyu-l
tianyu-l merged commit de7fc7b into main Apr 18, 2026
20 of 25 checks passed
yushangdi added a commit that referenced this pull request Apr 20, 2026
## Summary
- Update CLI flag references from `--profiling.*` to `--profiler.*` in
docs, benchmarks, and `.claude/` files to match the config rename from
`ProfilingConfig` to `Profiler.Config` landed in #3020

## Changed files
- `docs/debugging.md` — CLI flags, inline code references, and config
example
- `torchtitan/experiments/graph_trainer/.claude/CLAUDE.md` — CLI flags
in example commands
- `benchmarks/llama3-8b_h200_202506_trainy-whitefiber.md` — CLI flag in
benchmark command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants