Skip to content

[profiler] Drop enable_event_node_ids: torch's CuspyConfig removed it - #6390

Merged
shuhuayu merged 1 commit into
mainfrom
cuspy-drop-event-node-ids
Nov 25, 2026
Merged

shuhuayu merged 1 commit into
mainfrom
cuspy-drop-event-node-ids

Conversation

@tianyu-l

Copy link
Copy Markdown
Contributor

Summary (human-written)

Why

PyTorch nightly removed torch.profiler.CuspyConfig.enable_event_node_ids (pytorch/pytorch#206322). Cuspy now reads CUPTI's native CUDA graph fields for event-record nodes, and their spans come with enable_cuda_sync_events. torchtitan still passes the kwarg, so every CPU unit test run against the new nightly fails:

FAILED tests/unit_tests/cpu/observability/test_profiler.py::TestProfilerEnabled::test_cuspy_activity_config
TypeError: CuspyConfig.__init__() got an unexpected keyword argument 'enable_event_node_ids'

It shows up on unrelated PRs from about 10:00 UTC on 2026-11-25, e.g. #6385 and shuhuayu/k3-dm-stack-05.

What changed

  • CuspyTraceProfiler.Config.enable_event_node_ids is removed, and is no longer passed to CuspyConfig.
  • get_cuspy_cuda_graph_annotation_config always keys annotations by the capture graph (key_by="auto"). The exec-graph keying existed only because Cuspy used to resolve event-record nodes by exec-graph id.
  • Tests and the observability README are updated to match.

User-facing changes

Before After
CuspyTraceProfiler.Config(enable_event_node_ids=True) removed; graph event-node spans come with enable_cuda_sync_events=True

Testing

  • pytest tests/unit_tests/cpu/observability/test_profiler.py tests/unit_tests/cpu/test_trainer.py: 63 passed, on torch 2.16.0.dev20261030, which still has the field. The new code passes no kwarg the new nightly lacks.
  • Not checked on a GPU: Cuspy traces of CUDA-graphed NCCL event nodes with the new nightly. key_by="auto" relies on upstream's native graph fields (CUPTI and driver 13.5+, per the upstream PR).

PyTorch nightly removed CuspyConfig.enable_event_node_ids (pytorch/pytorch#206322):
Cuspy now reads CUPTI's native graph fields for event-record nodes, and their spans
come with enable_cuda_sync_events. Passing the kwarg fails every CPU unit test run
(TypeError in test_cuspy_activity_config), so drop the field; annotations always
key by the capture graph (key_by=auto).
@pytorch-bot pytorch-bot Bot added ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl labels Nov 25, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 25, 2026
@tianyu-l

Copy link
Copy Markdown
Contributor Author

@claude review

@claude

claude Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 47s —— View job


Approve -- review posted.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- upstream removed CuspyConfig.enable_event_node_ids, so the torchtitan knob has nothing left to control. Deleting it, rather than gating on the torch version, is the right fix.

What this PR does. It removes CuspyTraceProfiler.Config.enable_event_node_ids and stops passing it to torch.profiler.CuspyConfig. Graph annotations are now always keyed by the capture graph (key_by="auto"). The "exec" keying existed only so Cuspy could resolve event-record nodes by exec-graph id, which upstream no longer does. Tests and the observability README are updated to match.

Example.

# Before, on a nightly that includes pytorch/pytorch#206322:
CuspyTraceProfiler.Config()  # any Cuspy run
# -> profile_activities() calls CuspyConfig(..., enable_event_node_ids=False)
# -> TypeError: unexpected keyword argument 'enable_event_node_ids'
#    (seen as test_cuspy_activity_config failing on unrelated PRs)

# After:
CuspyTraceProfiler.Config(enable_cuda_sync_events=True)
# -> CuspyConfig(enable_cuda_sync_events=True, enable_environment_counters=False,
#                enable_graph_dependencies=False); annotations use key_by="auto"
Details
  • Callsites: enable_event_node_ids and key_by="exec" have no other references in the repo (checked torchtitan/, torchtitan_recipes/, tests/, scripts/, .claude/, .github/). Nothing is left stale.
  • test_cuspy_activity_config now uses enable_graph_dependencies as its pass-through probe. It still builds a real CuspyConfig, so a future upstream field removal will still fail there. The deleted test_trainer.py case covered only the removed "exec" branch, so dropping it loses no coverage.
  • On torch nightlies that still have the field, it defaults upstream, so behavior there matches the old enable_event_node_ids=False default.
  • No numerics, metric-key, or main-path impact: this is profiler-only config.

Not verified: on a GPU with the new nightly, that CUDA-graphed NCCL event-record nodes show up under enable_cuda_sync_events and resolve with key_by="auto". This depends on CUPTI/driver 13.5+, per the upstream PR. A maintainer still needs to review.

@shuhuayu
shuhuayu merged commit a71e607 into main Nov 25, 2026
29 checks passed
tianyu-l added a commit that referenced this pull request Nov 25, 2026
…again

#5792 and #6390 merged 10 minutes apart and conflict at the meaning level:
#5792 calls get_cuspy_cuda_graph_annotation_config(enable_event_node_ids=True),
and #6390 removed that kwarg. Kernel spans look annotations up by exec-graph node
id, so pass key_by explicitly: "auto" for the Cuspy trace, "exec" for kernel spans.
tianyu-l added a commit that referenced this pull request Nov 25, 2026
…again (#6395)

## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the
problem, why
     this approach, and what you checked yourself. -->

## Why
#5792 and #6390 merged 10 minutes apart and conflict at the meaning
level; git merged them cleanly. #5792 added a kernel-spans call
`get_cuspy_cuda_graph_annotation_config(enable_event_node_ids=True,
...)`. #6390, branched before #5792 landed, removed that kwarg. So
`main` (a71e607) fails:

```
lint: ERROR Unexpected keyword argument `enable_event_node_ids` in function
      `torchtitan.distributed.accelerator_graph.get_cuspy_cuda_graph_annotation_config`
      --> torchtitan/observability/profiler.py:541:21
test: tests/unit_tests/cpu/test_trainer.py::test_training_engine_configures_gradient_accumulation_accelerator_graph
      (kernel_spans case) TypeError, same kwarg
```

The lint failure shows up on every open PR, since pyrefly checks the
whole project.

Dropping the kwarg at the call would not be enough. In #5792's helper,
`enable_event_node_ids=True` also meant `key_by="exec"`, and kernel
spans need that for a reason of their own:
`KernelSpanRecorder._record_graph_nodes` looks annotations up by the
exec graph's node ids (`tools_id`), the ids CUPTI reports for replayed
kernels. With `key_by="auto"`, annotations are keyed by capture-graph
ids wherever CUPTI supports `sourceGraphNodeId`, so the lookup would
silently find nothing.

## What changed
- `get_cuspy_cuda_graph_annotation_config` takes a required `key_by:
Literal["auto", "exec"]`.
- `CuspyTraceProfiler` passes `"auto"`, as after #6390. Kernel spans
pass `"exec"`, as before #6390.

**Example.**
```
                         before #6390   main today   this PR
Cuspy trace only         auto           auto         auto
kernel spans (+ trace)   exec           TypeError    exec
```

## Testing
- `pytest tests/unit_tests/cpu/test_trainer.py
tests/unit_tests/cpu/observability`: 210 passed, 1 skipped. This
includes the kernel-spans case of
`test_training_engine_configures_gradient_accumulation_accelerator_graph`,
which expects `key_by: "exec"` and is unchanged.
- Pyrefly reports no errors in the touched files.
IvanKobzarev added a commit to IvanKobzarev/torchtitan that referenced this pull request Dec 1, 2026
Port the Cuspy configuration and golden-loss updates from pytorch#6390 and pytorch#6398. Use the GPT-OSS attention backend split from pytorch#6400 so varlen LSE backward runs on FA4 hardware. Select both Gloo and NCCL for the Muon CPU-offload test mesh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl 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