Repository navigation
Bake CUDA graph annotations into the profiler export - #4447
Merged
Merged
Conversation
ngimel
requested review from
IvanKobzarev,
SherlockNoMad,
aditvenk,
fegin,
sanketpurandare,
tianyu-l,
wconstab,
wwwjn and
xmfan
as code owners
September 3, 2026 19:54
SherlockNoMad
approved these changes
Sep 3, 2026
ngimel
force-pushed
the
ngimel/inline-cudagraph-annotations
branch
from
September 3, 2026 20:25
a4eb8b5 to
bc16838
Compare
torch is removing torch/cuda/_annotate_cuda_graph_trace.py, the offline joiner that merged CUDA-graph kernel annotations into an already-written trace. Its replacement is a cuda_graph_annotations argument on export_chrome_trace, which splices the annotations in during the export pass, so the trace is never read back and re-written -- for the gzipped traces the profiler has produced since pytorch#3483 that was paying the compression cost twice. The trace handler now passes get_cudagraph_annotations() straight to export_chrome_trace, and cudagraph_annotate_trace_post_processor goes away with its import. Passing an empty mapping is defined to mean the same as passing none, so the handler no longer needs the early return the post-processor had. The two post-processor tests are replaced by one that checks the handler hands the captured annotations to the export of the .json.gz path. The gzip round-trip case they covered is now torch's exporter picking compression off the file suffix, tested there rather than here. The argument is passed only when the installed torch accepts it, checked once against the export_chrome_trace signature. On an older torch the trace is still written, without the annotations, and a warning says so -- so this does not have to wait for the torch-side change to reach a nightly. Authored with assistance from Claude Code.
ngimel
force-pushed
the
ngimel/inline-cudagraph-annotations
branch
from
September 3, 2026 20:28
bc16838 to
8a66af8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
torch is removing torch/cuda/_annotate_cuda_graph_trace.py, the offline joiner that merged CUDA-graph kernel annotations into an already-written trace. Its replacement is a cuda_graph_annotations argument on export_chrome_trace, which splices the annotations in during the export pass, so the trace is never read back and re-written -- for the gzipped traces the profiler has produced since
#3483 that was paying the compression cost twice.
The trace handler now passes get_cudagraph_annotations() straight to export_chrome_trace, and cudagraph_annotate_trace_post_processor goes away with its import. Passing an empty mapping is defined to mean the same as passing none, so the handler no longer needs the early return the post-processor had.
The two post-processor tests are replaced by one that checks the handler hands the captured annotations to the export of the .json.gz path. The gzip round-trip case they covered is now torch's exporter picking compression off the file suffix, tested there rather than here.
Depends on the torch-side change; until it lands in a nightly, export_chrome_trace does not accept cuda_graph_annotations.
Authored with assistance from Claude Code.