Skip to content

[Profiler] Add opt-in ROCTx ranges to record_function#3483

Open
EvanPhoukong wants to merge 1 commit into
developfrom
users/ephoukong/emit-roctx
Open

[Profiler] Add opt-in ROCTx ranges to record_function#3483
EvanPhoukong wants to merge 1 commit into
developfrom
users/ephoukong/emit-roctx

Conversation

@EvanPhoukong

@EvanPhoukong EvanPhoukong commented Jul 23, 2026

Copy link
Copy Markdown

Rocprofiler-sdk PR: ROCm/rocm-systems#9109

Motivation

Allow ROCm profiling tools to capture Python record_function annotations as ROCTx ranges.

Technical Details

  • Add opt-in ROCTx emission through TORCH_PROFILER_EMIT_ROCTX.
  • Lazily import roctx and report a clear error when unavailable.
  • Keep ranges balanced across nesting, exceptions, and deferred callbacks.
  • Avoid duplicate markers while the NVTX profiler is active.
  • Add tests covering lifecycle, configuration, imports, and failures.

Test Plan

  1. Run the targeted rocprofv3 option and environment-propagation tests.

  2. Build rocprof-sys and run its CLI help and environment-propagation tests.

  3. Profile a real ROCm PyTorch workload containing:

    with record_function("optimizer_step"):
        optimizer.step()
  4. Verify that both profiler outputs contain an optimizer_step marker region with GPU work inside it.

Test Result

  • All targeted rocprofv3 integration tests passed.
  • rocprof-sys built successfully and its targeted tests passed.
  • Validated on an AMD Instinct MI300X with PyTorch 2.10.0 and ROCm 7.1.
  • rocprofv3 and rocprof-sys both captured the optimizer_step range.
  • Each captured range enclosed the expected optimizer GPU kernel.

Enable ROCTx markers via TORCH_PROFILER_EMIT_ROCTX and add coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant