You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[graph_trainer] Add CUDA graph kernel annotation pass
Adds `insert_kernel_annotations_pass` that labels CUDA graph kernels with
their originating nn.Module path in profiler traces.
How it works:
1. `annotate_module_fqns(model)` wraps each submodule's forward with
`torch.fx.traceback.annotate_fn({"module_fqn": fqn})`, setting
`node.meta["custom"]["module_fqn"]` on FX nodes during tracing.
2. `insert_kernel_annotations_pass` reads the `module_fqn` metadata and
inserts `mark_kernels` enter/exit calls at module boundaries. Bundled
with the cudagraph pass.
3. `CUDAGraphWrapper` captures annotations during graph recording when the
pass is active.
4. `Profiler.Config.trace_post_processors` (new field) runs
`cudagraph_annotate_trace_post_processor()` on each exported trace so
profiler traces automatically carry `module_fqn` fields on graphed
kernel events.
Requires PyTorch with `torch.cuda._graph_annotations` and the
`enable_annotations` kwarg on `torch.cuda.graph()`. Falls back gracefully
when unavailable (pass is a no-op).
Authored with Claude.
0 commit comments