Skip to content

[RFC] Feature: Automated Compute-Communication Overlap Diagnostic in Profiler #2408

Closed as not planned

Description

@pbpatre

[RFC] Feature: Automated Compute-Communication Overlap Diagnostic in Profiler

Status: Proposed Target Repo: pytorch/torchtitan Suggested Tags: feature-request, performance, experimental

1. Motivation

In large-scale training (e.g., Llama 3.1 70B/405B), achieving high Model FLOPs Utilization (MFU) requires a perfect orchestration of compute and communication overlap. In FSDP2/3D parallel setups, identifying "Communication Bubbles"---where the main compute stream stalls while waiting for all_gather or reduce_scatter kernels---is currently a manual, labor-intensive process.

Engineers must download multi-gigabyte .json trace files and visually inspect CUDA streams in the Chrome Trace Viewer to see if NCCL operations are effectively "hidden" under GEMM kernels.

2. Proposed Feature

I propose adding a lightweight OverlapAnalyzer utility that automatically quantifies this overlap. This tool hooks into the on_trace_ready callback of the PyTorch profiler and outputs a high-level diagnostic summary directly to the logs.

Key Metrics:

  • Total Compute Time: Sum of CUDA time for math-heavy kernels (GEMM, cuBLAS, aten).

  • Total NCCL Time: Sum of CUDA time for communication kernels (all_gather, reduce_scatter).

  • Overlap Efficiency %: A heuristic calculating how much of the network latency was successfully overlapped with computation.

3. Design & API Contract

To maintain torchtitan's "clean-room" philosophy and minimize overhead, I suggest the following implementation details:

  • Location: House the core logic in torchtitan/experiments/overlap_analysis/ or as a utility in torchtitan/components/profiler_utils.py.

  • Config Toggle: Add an experimental flag to the [profiling] section of the .toml config:

    Ini, TOML

    [profiling]
    enable_profiling = true
    enable_overlap_analysis = true  # New experimental flag
    
    
  • No "Hot-Path" Impact: The analysis only runs inside the on_trace_ready callback, meaning it has zero impact on actual training performance steps.

Alternative (Very Low Risk) I can house this in torchtitan/experiments/overlap_analysis to keep it decoupled from the core trainer

4. Expected Impact

This provides an immediate "Network Health" signal. For example, if a user sees an Efficiency of < 50%, it's a clear signal to investigate their interconnect (NVLink vs. PCIe) or adjust their sharding strategy, without needing to open a single trace file.

Activity

  1. tianyu-l commented on Feb 20, 2026

    @tianyu-l
    Contributor

    How much code does it have? Also do you think torch.profiler is better place to put this tool?

  2. pbpatre commented on Feb 21, 2026

    @pbpatre
    ContributorAuthor

    Thanks for taking a look

    1. The OverlapAnalyzer is very lightweight — approximately 80 lines of Python (including docstrings and constants). It is entirely decoupled from the training loop (running only in the on_trace_ready callback) and adds zero overhead to the critical path. It effectively acts as a post-processing utility for the existing Kineto trace.
    2. While torch.profiler is the upstream home, landing this there would require making it generic for all workloads (CV, RecSys, etc.), which likely incurs a long RFC/review cycle.
      Since this metric (Communication/Compute Overlap) is the primary KPI for 3D-Parallel LLM training, I believe it fits better in torchtitan (the application layer) where we can make opinionated assumptions about FSDP/NCCL patterns. We can treat torchtitan as an incubator; if the metric proves universally useful, we can look at upstreaming it to Core PyTorch in the future.

    Does that sound reasonable? If so, I can put up a draft PR so you can gauge the complexity directly

  3. pbpatre commented on Feb 21, 2026

    @pbpatre
    ContributorAuthor

    I've just submitted a PR (#2418) that implements this as an experimental component. It includes a standalone analyzer that parses the on_trace_ready callback. Looking forward to the team's feedback!

  4. fegin commented on Feb 23, 2026

    @fegin
    Contributor

    @pbpatre People have started to try adding Claude skills to read trace and memory profiling. I'm thinking to add the same skills for TorchTitan. Of course, you have to do this offline. But I found (from other people's experience) that this approach is useful as one can interact with Claude to understand the performance gaps, not just hardcoded rules only.

    Would like to hear your opinion too.

  5. pbpatre commented on Feb 24, 2026

    @pbpatre
    ContributorAuthor

    @fegin Offline analysis of traces with claude is extremly useful and even I have used it recently. +1 to having such an integration. That said, a lot of users might not bother to do it unless they are prompted by a metric that their GPU utlization is low. This metrics tries to give that signal as a single metric of overlap efficiency/GPU unutilized. Once users see a low enough number here they can start analyzing the traces to figure where is the model spending wasteful time.
    What do you think?

  6. acisseJZhong commented on Feb 26, 2026

    @acisseJZhong
    Contributor

    People have started to try adding Claude skills to read trace and memory profiling.

    +1, I found Claude reading profiling trace super fast and useful; and you can ask followup questions! would love to see how other people are using; and having a skill in Torchtitan.

    Once users see a low enough number here they can start analyzing the traces to figure where is the model spending wasteful time.

    I like this idea! Giving users a number on compute-comm overlap without any extra steps sounds great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions