Skip to content

Add CUPTI monitor profiler support - #70

Merged
drisspg merged 1 commit into
mainfrom
cupti-monitor-profiler
Aug 19, 2026
Merged

Add CUPTI monitor profiler support#70
drisspg merged 1 commit into
mainfrom
cupti-monitor-profiler

Conversation

@drisspg

@drisspg drisspg commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Human Note

Agent note

Add an opt-in CUPTI monitor configuration to the shared profiler wrapper, including PM metric
sampling, environment counters, CUDA Graph dependency recording, event-node attribution, and
metric discovery. Constructing the profiler now prepares the backend immediately, which lets graph
recorders arm before capture while preserving existing context-manager usage.

Monitor traces use PyTorch's native Perfetto exporter and normalize its unconditional .gz suffix,
so callers receive the requested .pftrace or JSON path instead of having to discover a differently
named artifact. The optional dependency keeps cupti-python out of the default installation.

The monitor path was also exercised on an NVIDIA B200 with native Perfetto output, PM counter
tracks, graph flows, and kernel annotations.

Test Plan

~/.venvs/nightly/bin/python -m pytest test/test_profiler.py test/test_perfetto.py -q
uvx ruff check transformer_nuggets/utils/benchmark.py transformer_nuggets/utils/__init__.py test/test_profiler.py
uvx ruff format --check transformer_nuggets/utils/benchmark.py transformer_nuggets/utils/__init__.py test/test_profiler.py
prek

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9847c9801b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread transformer_nuggets/utils/benchmark.py Outdated
Comment on lines +611 to +612
if trace_path.exists():
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Replace an existing trace with the newly exported monitor trace

When the requested path already exists—for example, when rerunning an experiment with the same output name—the CUPTI exporter still writes the new data to <trace_path>.gz, but this check returns solely because the old target exists. The advertised path therefore retains the stale trace while the current run is left under an unexpected .gz name, silently associating previous profiling data with the new experiment.

Useful? React with 👍 / 👎.

Comment thread transformer_nuggets/utils/benchmark.py Outdated
Comment on lines +623 to +624
with gzip.open(monitor_path, "rb") as source, trace_path.open("wb") as destination:
destination.write(source.read())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Convert native monitor output before labeling it Chrome JSON

When cupti_monitor is combined with trace_format="chrome_json", the monitor backend's exporter produces a gzip-compressed native Perfetto protobuf trace; this branch merely decompresses those bytes rather than converting them to Chrome JSON. The resulting .json file is therefore not JSON, and with gzip_trace=True the uncompressed bytes are additionally written under a .json.gz suffix, so downstream JSON readers fail for every advertised Chrome-JSON monitor export.

Useful? React with 👍 / 👎.

@drisspg
drisspg force-pushed the cupti-monitor-profiler branch from 9847c98 to eb4754a Compare August 19, 2026 21:21
## Human Note

## Agent note

Add an opt-in CUPTI monitor configuration to the shared profiler wrapper, including PM metric
sampling, environment counters, CUDA Graph dependency recording, event-node attribution, and
metric discovery. Constructing the profiler now prepares the backend immediately, which lets graph
recorders arm before capture while preserving existing context-manager usage.

Monitor traces use PyTorch's native Perfetto exporter and normalize its unconditional `.gz` suffix,
so callers receive the requested `.pftrace` or JSON path instead of having to discover a differently
named artifact. The optional dependency keeps cupti-python out of the default installation.

## Test Plan

```bash
~/.venvs/nightly/bin/python -m pytest test/test_profiler.py test/test_perfetto.py -q
uvx ruff check transformer_nuggets/utils/benchmark.py transformer_nuggets/utils/__init__.py test/test_profiler.py
uvx ruff format --check transformer_nuggets/utils/benchmark.py transformer_nuggets/utils/__init__.py test/test_profiler.py
prek
```
@drisspg
drisspg force-pushed the cupti-monitor-profiler branch from eb4754a to 24d5580 Compare August 19, 2026 21:23
@drisspg
drisspg merged commit 531f361 into main Aug 19, 2026
2 checks passed
@drisspg
drisspg deleted the cupti-monitor-profiler branch August 19, 2026 21:27
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