[MIOpen] Sync hipconv v0.5.1 #16402
<!-- therock-pr-bot-policy-check -->
✅ All Checks Passed — Ready for Review
| Check | Status | Details |
|---|:---:|---|
| 📝 PR Description | ✅ Pass | — |
| ⛔ Forbidden Files | ✅ Pass | — |
| 🧪 Unit Test | ⚠️ Warning | Error: Source/code files changed without an accompanying unit test.<br>Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).<br>Current: code file(s) changed: projects/miopen/src/hipconv/include/hipconv/conv_params.hpp, projects/miopen/src/hipconv/include/hipconv/device.hpp, projects/miopen/src/hipconv/include/hipconv/hipconv.hpp, projects/miopen/src/hipconv/src/arch/cdna4/depthwise/depthwise_1d_toeplitz/kernel.h, projects/miopen/src/hipconv/src/arch/cdna4/depthwise/depthwise_wgrad_hankel/kernel.h (+30 more); no test file found |
| 🔎 pre-commit | ✅ Pass | — |
| 🚫 Draft PR | 🔜 To Be Enabled | — |
| 🚩 Feature Flag | 🔜 To Be Enabled | — |
| 📊 Code Coverage | 🔜 To Be Enabled | — |
| 🤖 therock-pr-bot | ✅ Pass | — |
🎉 All checks passed! This PR is ready for review.
📖 Need help? See the Policy FAQ for details on every check and how to fix failures.
<!-- therock-pr-bot-fix-policies -->
🎉 All checks passed! This PR is ready for review.
Inconsistent handling of miopen::Exception
catch(const std::exception&) also catches miopen::Exception. A MIOPEN_THROW reached through GetConfigs (for example "unsupported data type", line 130) used to propagate and is now swallowed as "not applicable". The same applies in InitFromDevice, IsValid and GetWti. GetWorkspaceSize and GetSolution instead rethrow miopen::Exception explicitly, so the two groups differ. Either catch only std::invalid_argument (what the hipconv v0.5.1 changelog says it throws), which also removes the duplicated catch(Exception){throw;} blocks, or add a comment saying the swallowing is intended.
Summary
The solver-side exception handling in conv_hipconv.cpp looks correct. On gfx950 (MI355X) I reproduced the original crash on the base commit: a bf16 bwd-weights convolution with a 3x3 filter over an unpadded 1x1 input (NHWC, -n 1 -c 64 -k 64) dies with SIGFPE (rc=136), both with MIOPEN_FIND_MODE=1 and in default mode. On this PR's head the same command exits 0 and picks ConvDirectNaiveConvWrw.
One comment, on the exception-handling policy (inline).
One optional suggestion: the fix itself is in the vendored hipconv, and this PR has no MIOpen-side test. If hipconv's own suite already covers the is_valid() rejection, a link in the PR description would be enough. Otherwise a small gtest using the unit_conv_solver*.hpp fixtures could pin the two behaviors this PR changes in MIOpen: an empty-output layer is not applicable and Find completes, and a hipconv exception makes Find skip ConvHipConv and not return miopenStatusUnknownError.
I did not read the vendored kernel hunks beyond sampling direct/kernel.hpp. I took the overflow and grid-limit guards from the upstream changelog.
This review was AI-assisted. The inline comment is static; the SIGFPE reproduction ran on a gfx950 MI355X.
<!-- therock-bump-breadcrumb -->
TheRock Submodule Bump Activity
_Newest first_
JonathanLichtnerAMD
petar-jovanovic
JIRA ID : ALMIOPEN-2361
Takes the vendored
src/hipconvsnapshot from v0.5.0 to v0.5.1-rc1, and makes ConvHipConvskip a problem when hipconv throws, instead of failing the whole Find. Per-version detail is
in the shipped
src/hipconv/CHANGELOG.md.Kernels
v0.5.1 adds no kernels or configs. It makes hipconv reject layers that v0.5.0 matched to a
kernel that crashed, wrote wrong output or failed to launch:
such an output as 1x1, v0.5.0's
ConvParams::unfolded()recomputed it as -1x-1, andselection did not check
ConvParams::is_valid(). On gfx950, backward-weights selectiondivided by zero, so MIOpen died with SIGFPE in
miopenConvolutionBackwardWeightsGetWorkSpaceSize. That happened withMIOPEN_FIND_MODE=1, in tuning, and in the default find mode for NHWC tensors. Forward andbackward data got a
direct_flexkernel that computes wrong results.get_valid_configs,find_config,is_applicable,ConvLaunch::makeandlaunchnow reject a layer thatfails
is_valid(), or whose p, q or e is unset or differs from the computed size.unfolded()returns such a layer unchanged.direct,direct_flex,direct_l1,direct_wgrad,patch_embed,grouped,grouped_wgradanddepthwise_wgrad_hankel, anddirect_wgradlayers whose kh x kw x C/g exceeds INT_MAX.HIP's grid limits, in
direct_wgrad,grouped,grouped_wgrad,depthwise_1d_toeplitzand
depthwise_wgrad_hankel.ConvParams::compute_output_size()now computes in 64 bits, and the newexpected_output_size()andoutput_size_matches()expose the check.config_version()staysv0.5, so ConvHipConv perf-db records tuned against v0.5.0 stillmatch, and the perf-config picker from #14532, trained on v0.5 configs, still applies.
Solver
v0.5.1 throws
std::invalid_argumentin more places.get_workspace_size,is_deterministic,get_weighted_throughput_indexand the tolerance queries throw for alayer that
get_valid_configsrejects as invalid. Every function that takes aDevice,except
launch, throws for a CU count outside [1, 1024];launchreturnshipErrorInvalidValue. Find catches onlymiopen::Exception, so such an exception failedthe whole call with
miopenStatusUnknownErrorinstead of skipping ConvHipConv.ConvHipConv's
IsApplicable, andPerformanceConfigConvHipConv'sIsValidandInitFromDevice, now log the exception as a warning and treat the problem as notapplicable.
GetWtireturnswti_approximate_worst.GetSolutionreturns aConvSolutionwith
miopenStatusInternalError, which Find skips.GetWorkspaceSizerethrows theexception as a
miopen::Exception, since a guessed workspace size could undersize thecaller's buffer.
Build
No change. The snapshot adds one header,
src/arch/cdna5/grid_limits.h.Tests
No test changes.
Related
Supersedes #15856 (closed), which added
ConvParams::is_valid()checks to the vendoredv0.5.0 as a stopgap.
Downstream patches
None. Every vendored source file matches EMU v0.5.1-rc1 (201c04f6).
Co-authored-by: Andrew Lavin <andrew.lavin@amd.com>