Only throw on the root module when dumping benchmark-mxr files#4851
Only throw on the root module when dumping benchmark-mxr files#4851ahsan-ca wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the GPU compile_ops benchmarking-MXR dump path to avoid throwing an exception unless MXR binaries were actually produced, improving usability of MIGRAPHX_GPU_DUMP_BENCHMARK_MXR in cases where no dump occurs.
Changes:
- Track whether benchmark MXR binaries were emitted during compilation.
- Gate the post-dump
MIGRAPHX_THROWon that “binaries dumped” condition instead of the dump setting alone.
Comments suppressed due to low confidence (1)
src/targets/gpu/compile_ops.cpp:567
- The PR title/description mention adding a flag to control whether an exception is thrown after dumping MXR files, but this change only adjusts the throw condition based on a local
has_binariesboolean (no new user-facing option/env var). Either update the PR metadata to match the actual behavior change, or add the intended user-controlled flag and use it to gate thisMIGRAPHX_THROW.
if(has_binaries)
{
MIGRAPHX_THROW(
"Benchmark MXR files dumped to " + mxr_path +
". Run the MXR files to create a problem cache, then recompile with the cache.");
|
Why do we need this flag? |
I noticed that the mxr files were not being dumped. I debugged and it turns out we hit the exception before the mxr files are dumped. |
|
Ok I see the issue. This can throw on a submodule which will stop before the main module is run. This doesnt fix that issue(only for the rare case that submodules dont have kernels). We need to just throw on the root module. We need to take void compile_ops::apply(module_pass_manager& mpm) const
{
bool is_root = &mpm.get_module() == mpm.get_root_module();
compile_manager cm;
...
cm.compile(mpm.get_module(), is_root);
...
}Then update the condition to check |
1aa3c4b to
d9ee29d
Compare
Thanks! Made the change. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/targets/gpu/compile_ops.cpp:571
- When MIGRAPHX_GPU_DUMP_BENCHMARK_MXR is set, this always throws on the root module even if no benchmark MXR files were actually written (e.g., no compile_plan had results.size()>1). That makes the error text inaccurate and can abort compilation unnecessarily; consider tracking whether any MXR file was dumped and only throwing (and wording the message) when at least one file was created.
static const auto mxr_path = string_value_of(MIGRAPHX_GPU_DUMP_BENCHMARK_MXR{});
bool dump_mxr = not mxr_path.empty();
if(dump_mxr)
{
fs::create_directories(fs::path(mxr_path));
}
for(const auto& cp : cps)
{
if(cp.results.empty())
continue;
if(dump_mxr and cp.results.size() > 1)
{
cp.save_binaries(fs::path(mxr_path));
}
else
{
cp.replace(m);
}
}
// Only throw on the root module so that submodules (which are processed
// first by the pass manager and may legitimately have no precompile ops
// or no multi-solution candidates) don't abort compilation before the
// root module has had a chance to dump its benchmark MXR files.
if(dump_mxr and is_root)
{
MIGRAPHX_THROW(
"Benchmark MXR files dumped to " + mxr_path +
". Run the MXR files to create a problem cache, then recompile with the cache.");
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/targets/gpu/compile_ops.cpp:571
- The unconditional throw in dump-mxr mode is still reachable even when no MXR files were actually written (e.g., no precompile ops in the module, or every plan resolves to a single solution so
save_binaries()is never called). That makes the message "Benchmark MXR files dumped" misleading and can unnecessarily abort compilation. Consider tracking whether at least one binary was saved and only throwing (or adjusting the message) when something was actually dumped.
// Only throw on the root module so that submodules (which are processed
// first by the pass manager and may legitimately have no precompile ops
// or no multi-solution candidates) don't abort compilation before the
// root module has had a chance to dump its benchmark MXR files.
if(dump_mxr and is_root)
{
MIGRAPHX_THROW(
"Benchmark MXR files dumped to " + mxr_path +
". Run the MXR files to create a problem cache, then recompile with the cache.");
}
|
@pfultz2 PR is ready for review. Thanks! |
Motivation
Only throw on the root module so that submodules (which are processed
first by the pass manager and may legitimately have no precompile ops
or no multi-solution candidates) don't abort compilation before the
root module has had a chance to dump its benchmark MXR files.
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable