Skip to content

[AIROCMLIR-1078] Port MIOpen conv layout translation to rocmlirTriton - #359

Merged
bogdan-petkovic merged 7 commits into
developfrom
users/bpetkovi/port-miopen-conv-layout-translate
Sep 22, 2026
Merged

bogdan-petkovic merged 7 commits into
developfrom
users/bpetkovi/port-miopen-conv-layout-translate

Conversation

@bogdan-petkovic

Copy link
Copy Markdown
Collaborator

Motivation

While running the MIOpen benchmark, every conv config fails with Invalid Layout Parameter Value because rocMLIR passes its own layout names (e.g. GNC01, NGC01) to MIOpenDriver, which only accepts NCHW/NHWC. The failures were silently converted to NaN, so nightly CI stayed green even though the MIOpen conv benchmarks never actually ran. This ports the fix from ROCm/rocMLIR#2422 over to rocmlirTriton.

Technical Details

Adds rocmlir_layout_to_miopen() and conv_commandline_to_miopen_layouts() to mlir/utils/performance/perfRunner.py, which translate the -f/-I/-O layout arguments to NCHW/NHWC only when they map exactly (the group dimension G is dropped since MIOpen conveys the group count via -g, and the spatial dims are renamed 0->H, 1->W). Configs whose layouts have no faithful MIOpen equivalent, or where filter/input/output do not agree on a single NCHW/NHWC layout, are skipped instead of being benchmarked against a different layout. ConvConfiguration.benchmark_external now raises RuntimeError on a real MIOpen benchmark failure or an output-parse failure instead of silently returning NaN, so CI fails on genuine errors (the raised error points at MIOpenDriver's stderr, which run_pipeline already prints to the log). This is a direct port of ROCm/rocMLIR#2422, unit tests were not ported because rocmlirTriton does not have a perfRunner test harness.

Test Plan

yapf and flake8 run clean on the changed file. The translate-or-skip logic was exercised locally over the full mlir/utils/performance/configs/tier1-conv-configs, and the mixed-layout skip decision was confirmed directly against MIOpenDriver on a gfx942 GPU (all-NCHW and all-NHWC run fine, a mixed filter/input/output layout fails at runtime with "No suitable algorithm was found to execute the required convolution").

Test Result

  • Over tier1-conv-configs, 1296/1363 configs are translated and benchmarked (1294 NCHW, 2 NHWC) and 67 are skipped, all of which are genuinely non-representable orderings (G0NC1, 01NGC) or mixed NCHW/NHWC combinations. No layout errors and no silent NaN fallbacks remain.
  • Nightly CI

Submission Checklist

…il CI on MIOpen

Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
@bogdan-petkovic bogdan-petkovic self-assigned this Jul 20, 2026
@bogdan-petkovic bogdan-petkovic changed the title [AIROCMLIR-426] Port MIOpen conv layout translation to rocmlirTriton [AIROCMLIR-1078] Port MIOpen conv layout translation to rocmlirTriton Jul 20, 2026
@bogdan-petkovic
bogdan-petkovic marked this pull request as ready for review July 20, 2026 14:13
@bogdan-petkovic
bogdan-petkovic requested a review from Copilot July 20, 2026 14:14
@bogdan-petkovic bogdan-petkovic added the claude-review Request a Claude PR review label Jul 20, 2026

@rocmlir-pr-reviewer rocmlir-pr-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: APPROVE -- submitted as COMMENT (automated reviews are advisory)  ·  Findings: 0 (0 Critical, 0 Major, 0 Minor)


Scope

Ports the MIOpen conv-layout translation fix from ROCm/rocMLIR PR #2422 to mlir/utils/performance/perfRunner.py. Adds rocmlir_layout_to_miopen() / conv_commandline_to_miopen_layouts() to translate -f/-I/-O layout args to NCHW/NHWC (or skip when non-representable / mixed), and makes ConvConfiguration.benchmark_external raise on MIOpen failure or output-parse failure instead of silently returning NaN.

Findings

No blocking issues found.

Notes

  • The normalization in rocmlir_layout_to_miopen (perfRunner.py:32) checks out against the on-command-line layout alphabet in FILTER_LAYOUT_MAP/INPUT_LAYOUT_MAP/OUTPUT_LAYOUT_MAP (perfRunner.py:85-87): e.g. GNC01→NCHW, NG01C→NHWC; the len(seen_layouts) > 1 guard (perfRunner.py:59) correctly skips inconsistent filter/input/output combinations. The .replace('K', 'C') step is effectively defensive (these configs express the output channel dim as C, not K) but is harmless.
  • The new if not match: guard (perfRunner.py:879) fixes a latent AttributeError on ELAPSED_TIME_RE.search(...).group(1) when MIOpenDriver output can't be parsed — a real improvement over the prior code.
  • The skip path still returns config.table_entry(np.nan) (perfRunner.py:863); this is an intentional "skip" signal (accompanied by a log line), distinct from the now-fatal genuine-error path, and matches the upstream rocMLIR behavior.
  • rocMLIR back-port: mlir/utils/performance/ is shared with ROCm/rocMLIR, but the PR description explicitly identifies this as a direct port of rocMLIR PR #2422, satisfying the back-port note requirement. Unit tests were intentionally not ported (no perfRunner test harness in rocmlirTriton) — reasonable given the constraint.

CI status

No non-self checks are failing; py-checks/detect/ml-ci-internal.amd.com pass, Jenkins/Build and Test still pending. The auto-review check being in-progress is expected.

@rocmlir-pr-reviewer rocmlir-pr-reviewer Bot removed the claude-review Request a Claude PR review label Jul 20, 2026

Copilot AI 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.

Pull request overview

This PR updates the convolution performance runner to translate rocMLIR-style conv layout strings into the limited NCHW/NHWC layouts accepted by MIOpenDriver, skipping non-representable/mixed-layout configs and failing fast on real MIOpen benchmark or output-parse failures to avoid silently producing NaN.

Changes:

  • Added rocmlir_layout_to_miopen() and conv_commandline_to_miopen_layouts() to translate -f/-I/-O layout arguments to NCHW/NHWC or skip when no faithful mapping exists.
  • Updated ConvConfiguration.benchmark_external() to (a) skip configs without a faithful MIOpen layout and (b) raise RuntimeError on MIOpen execution failures or elapsed-time parse failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mlir/utils/performance/perfRunner.py
Comment thread mlir/utils/performance/perfRunner.py

@justinrosner justinrosner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think that we currently run the MIOpen benchmarking tests in the nightly CI (It's currently commented out in the Jenkinsfile). It's also not addressed in #274 or #275.

Do we have any tickets to add running the MIOpen benchmarking tests to rocmlirTriton?

@bogdan-petkovic

Copy link
Copy Markdown
Collaborator Author

I don't think that we currently run the MIOpen benchmarking tests in the nightly CI (It's currently commented out in the Jenkinsfile). It's also not addressed in #274 or #275.

Do we have any tickets to add running the MIOpen benchmarking tests to rocmlirTriton?

You're right, we don't run the MIOpen benchmarking test at the moment. There is a ticket for it though, AIROCMLIR-901, which lists "Benchmark and Report Performance" as the remaining one to turn on. I picked it up from Djole last week.

It depends on AIROCMLIR-899, because the performance checks need the tuning DB that the weekly job produces. The original 899 PR had gone stale and a lot of it already landed on develop, so I opened a fresh PR for just the remaining part #361.

Once 899 is merged I'll do the 901 work to enable the nightly Benchmark and Report Performance stage, and then this port can go in on top of that.

@umangyadav

Copy link
Copy Markdown
Member

unit tests were not ported because rocmlirTriton does not have a perfRunner test harness.

Would it be possible to add test harness ?

@dhernandez0

Copy link
Copy Markdown
Collaborator

unit tests were not ported because rocmlirTriton does not have a perfRunner test harness.

rocmlirTriton does have perfRunner tests: see perf-scripts/runtime/perfRunner-gemm.py

@bogdan-petkovic

Copy link
Copy Markdown
Collaborator Author

unit tests were not ported because rocmlirTriton does not have a perfRunner test harness.

Would it be possible to add test harness ?

added

…anslate

Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
…t-miopen-conv-layout-translate

# Conflicts:
#	mlir/utils/performance/perfRunner.py
Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
@bogdan-petkovic
bogdan-petkovic merged commit da5407c into develop Sep 22, 2026
8 checks passed
@bogdan-petkovic
bogdan-petkovic deleted the users/bpetkovi/port-miopen-conv-layout-translate branch September 22, 2026 10:16
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.

5 participants