Update rocMLIR integration API to version 5 (perfConfig, cluster size)#4761
Update rocMLIR integration API to version 5 (perfConfig, cluster size)#4761dhernandez0 wants to merge 6 commits intoadd_rock_prefixfrom
Conversation
src/targets/gpu/mlir.cpp
Outdated
| } | ||
| // 2nd pipeline to call | ||
| run_backend_pipeline(); | ||
| run_backend_pipeline(solution_str); |
There was a problem hiding this comment.
I undertsand solution is never null when we call run_backend_pipeline, is that correct?
There was a problem hiding this comment.
Yes that should be the case. Probably should throw an exception if its null. Then you can just do: run_backend_pipeline(solution.to<std::string>())
| MlirMIGraphXBackendOptions opts{}; | ||
| opts.arch = target_arch.c_str(); | ||
| opts.perfConfig = solution.c_str(); | ||
| opts.optLevel = 3; |
There was a problem hiding this comment.
added this because it could be useful for debugging on your side as well. It's often the case that LLVM bugs go away if you pass optLevel=0.
There was a problem hiding this comment.
Pull request overview
Updates MIGraphX’s rocMLIR integration to match rocMLIR MIGraphX dialect API v5 by switching the backend pipeline hook to the new options-based API and by reading the newly returned kernel cluster size attribute.
Changes:
- Bump
MLIR_MIGRAPHX_DIALECT_API_VERSIONcompatibility check from 4 → 5. - Update backend pipeline invocation to use
MlirMIGraphXBackendOptions(arch, perfConfig, optLevel). - Extend
get_launch_params()to return cluster size (currently ignored bycode_object_op).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mlirMIGraphXAddBackendPipeline(pm_back.get(), target_arch.c_str()); | ||
| MlirMIGraphXBackendOptions opts{}; | ||
| opts.arch = target_arch.c_str(); | ||
| opts.perfConfig = solution.c_str(); |
There was a problem hiding this comment.
opts.perfConfig is always set to solution.c_str(). When solution is empty (common path when no explicit tuning solution is provided), passing an empty string may be interpreted as an explicit perfConfig by rocMLIR and could cause parse/validation failures. Prefer setting perfConfig to nullptr when solution.empty() (or only setting it when a solution exists).
| opts.perfConfig = solution.c_str(); | |
| opts.perfConfig = solution.empty() ? nullptr : solution.c_str(); |
| MlirMIGraphXBackendOptions opts{}; | ||
| opts.arch = target_arch.c_str(); | ||
| opts.perfConfig = solution.c_str(); | ||
| opts.optLevel = 3; | ||
| mlirMIGraphXAddBackendPipeline(pm_back.get(), &opts); |
There was a problem hiding this comment.
opts.optLevel is hard-coded to 3 without explanation or configuration. If MIGraphX supports varying optimization levels elsewhere, consider threading that setting through (env var / compile option) or at least defining a named constant to avoid an unexplained magic number here.
src/targets/gpu/mlir.cpp
Outdated
| set_tuning(solution); | ||
| solution_str = *solution.if_string(); |
There was a problem hiding this comment.
After set_tuning(solution) validates that solution is a string, the code re-fetches it via solution.if_string() and dereferences again to populate solution_str. Consider reusing the validated pointer (or have set_tuning return the string) to avoid redundant lookups and make the control flow clearer.
| set_tuning(solution); | |
| solution_str = *solution.if_string(); | |
| const auto solution_ptr = solution.if_string(); | |
| set_tuning(solution); | |
| solution_str = *solution_ptr; |
| #if !defined(MLIR_MIGRAPHX_DIALECT_API_VERSION) || MLIR_MIGRAPHX_DIALECT_API_VERSION != 5 | ||
| #warning "Incompatible version of rocMLIR library used, disabling" |
There was a problem hiding this comment.
PR metadata indicates this change should be included in CHANGELOG.md (category marked "Added"), but this PR does not include a changelog entry. Please add an appropriate CHANGELOG.md entry (or update the PR category to "Not Applicable" if that was intended).
d14c41b to
5e0001d
Compare
MERGE AFTER #4748
Motivation
Update MIGraphX integration to support rocMLIR API version 5, which passes perfConfig through the backend pipeline (for triton backend compatibility) and returns cluster size from kernel attributes (for gfx1250+).
rocMLIR PR: ROCm/rocMLIR#2341 (I'll update the commit hash when merged).
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable