Port merge_embeddings benchmark to tritonbench#5650
Open
q10 wants to merge 1 commit intopytorch:mainfrom
Open
Conversation
Summary:
Add Kineto trace export support to the merge_embeddings benchmark for A/B comparison with the tritonbench port.
This diff extends `merge_embeddings_benchmark.py` with two new CLI options that enable exporting Kineto Chrome traces. This is needed for kernel-level A/B comparisons between the existing FBGEMM benchmark and the new tritonbench port of the same operator.
1. **`--export-trace` flag**: When enabled, switches the profiler from the existing `ProfilerActivity.CUDA` + table-print path to a `on_trace_ready` callback that exports a Chrome trace file.
2. **`--trace-url` template**: Configurable output path with `{ospid}` placeholder for the PID, defaulting to `merge_embeddings_fwd_trace_{ospid}.json`.
3. **`_kineto_trace_handler()` inner function**: Formats the trace URL with the current PID and calls `p.export_chrome_trace(url)`.
4. **Plumbing**: Both new options are threaded from the `cli()` Click entrypoint through to `benchmark_merge_pooled_embeddings()`.
The existing (non-trace) profiling behavior is preserved as the default path when `--export-trace` is not passed.
## Detailed Changes
### merge_embeddings_benchmark.py
- Added `import os` and `from contextlib import nullcontext` (note: `nullcontext` is unused and flagged by lint)
- Added `export_trace` and `trace_url` parameters to `benchmark_merge_pooled_embeddings()`
- Refactored profiling block into two branches: trace-export path (`on_trace_ready`) vs. existing CUDA activity profiling path
- Added `--export-trace` and `--trace-url` Click options to `cli()`
- Plumbed new options through both the sweep loop and single-run call paths
Reviewed By: henrylhtsang
Differential Revision: D101068554
Contributor
|
@q10 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D101068554. |
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.
Summary:
Add Kineto trace export support to the merge_embeddings benchmark for A/B comparison with the tritonbench port.
This diff extends
merge_embeddings_benchmark.pywith two new CLI options that enable exporting Kineto Chrome traces. This is needed for kernel-level A/B comparisons between the existing FBGEMM benchmark and the new tritonbench port of the same operator.--export-traceflag: When enabled, switches the profiler from the existingProfilerActivity.CUDA+ table-print path to aon_trace_readycallback that exports a Chrome trace file.--trace-urltemplate: Configurable output path with{ospid}placeholder for the PID, defaulting tomerge_embeddings_fwd_trace_{ospid}.json._kineto_trace_handler()inner function: Formats the trace URL with the current PID and callsp.export_chrome_trace(url).cli()Click entrypoint through tobenchmark_merge_pooled_embeddings().The existing (non-trace) profiling behavior is preserved as the default path when
--export-traceis not passed.Detailed Changes
merge_embeddings_benchmark.py
import osandfrom contextlib import nullcontext(note:nullcontextis unused and flagged by lint)export_traceandtrace_urlparameters tobenchmark_merge_pooled_embeddings()on_trace_ready) vs. existing CUDA activity profiling path--export-traceand--trace-urlClick options tocli()Reviewed By: henrylhtsang
Differential Revision: D101068554