Add a Python script to benchmark mxr files#4876
Open
ahsan-ca wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
Script and other changes generated using AI. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a workflow to benchmark .mxr binaries dumped from GPU tuning and emit a MIGRAPHX_PROBLEM_CACHE-compatible JSON, supported by a small extension to the core program API and Python bindings so dumped programs can be made runnable without re-running GPU compile passes.
Changes:
- Add
tools/benchmark_mxr.pyto load dumped.mxrfiles, benchmark candidates per (preop, problem), and write out the fastest solutions as a problem-cache JSON. - Add
migraphx::program::finalize(const target&)to attach a target/context to deserialized, not-yet-compiled programs and finalize without running compilation passes. - Extend Python bindings to expose
program.finalize(target)and to allow passingmigraphx.argumentdirectly toprogram.run()/run_async().
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tools/benchmark_mxr.py | New script that parses @comment metadata, benchmarks dumped .mxr programs, and writes a problem-cache JSON. |
| src/py/migraphx_py.cpp | Python binding updates: expose program.finalize(target) and accept migraphx.argument directly in run parameter maps. |
| src/program.cpp | Implements program::finalize(const target&) by attaching target/context when needed and calling existing finalize. |
| src/include/migraphx/program.hpp | Declares and documents the new program::finalize(const target&) overload. |
Comment on lines
+84
to
+96
| _LITERAL_KEYWORDS = { | ||
| "null": None, | ||
| "true": True, | ||
| "false": True, | ||
| "nan": float("nan"), | ||
| "inf": float("inf"), | ||
| "infinity": float("inf"), | ||
| "-nan": float("nan"), | ||
| "-inf": float("-inf"), | ||
| "-infinity": float("-inf"), | ||
| } | ||
| _LITERAL_KEYWORDS["false"] = False | ||
|
|
Comment on lines
+318
to
+319
| for name, shape in prog.get_parameter_shapes().items(): | ||
| host_arg = migraphx.generate_argument(shape, next_seed) |
Comment on lines
112
to
+122
| void finalize(); | ||
|
|
||
| // Attach `t` to a program that hasn't been compiled yet (e.g. one loaded | ||
| // from an .mxr produced by `compile_plan::save_binaries`, which contains | ||
| // already-lowered GPU code objects but no targets/contexts), then | ||
| // finalize. Unlike `compile()`, this runs no passes -- it just sets up | ||
| // the target + context and calls `finalize()`. Mirrors what | ||
| // `time_program` (src/targets/gpu/time_op.cpp) does internally so the | ||
| // program becomes runnable without re-running any rewrites that would | ||
| // mutate already-lowered instructions. | ||
| void finalize(const target& t); |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4876 +/- ##
========================================
Coverage 92.85% 92.85%
========================================
Files 584 585 +1
Lines 30147 30126 -21
========================================
- Hits 27992 27973 -19
+ Misses 2155 2153 -2
🚀 New features to boost your workflow:
|
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.
Motivation
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable