← Back to Pull requests

[MIOpen] Sync hipconv v0.5.1 #16402

Merged
petar-jovanovic merged 38 files (698 lines) on Nov 23, 2026 01:37 UTC
View on GitHub
petar-jovanovic petar-jovanovic commented on Nov 20, 2026 04:30 UTC
Author

JIRA ID : ALMIOPEN-2361

Takes the vendored src/hipconv snapshot from v0.5.0 to v0.5.1-rc1, and makes ConvHipConv
skip 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:

  • Layers whose output is empty, such as a 3x3 filter over an unpadded 1x1 input. MIOpen sizes

  • such an output as 1x1, v0.5.0's ConvParams::unfolded() recomputed it as -1x-1, and
    selection did not check ConvParams::is_valid(). On gfx950, backward-weights selection
    divided by zero, so MIOpen died with SIGFPE in
    miopenConvolutionBackwardWeightsGetWorkSpaceSize. That happened with
    MIOPEN_FIND_MODE=1, in tuning, and in the default find mode for NHWC tensors. Forward and
    backward data got a direct_flex kernel that computes wrong results. get_valid_configs,
    find_config, is_applicable, ConvLaunch::make and launch now reject a layer that
    fails is_valid(), or whose p, q or e is unset or differs from the computed size.
    unfolded() returns such a layer unchanged.
  • gfx950 layers whose tile counts, byte spans or grid size overflow 32 bits, in direct,

  • direct_flex, direct_l1, direct_wgrad, patch_embed, grouped, grouped_wgrad and
    depthwise_wgrad_hankel, and direct_wgrad layers whose kh x kw x C/g exceeds INT_MAX.
  • gfx1250 layers within a few rows or columns of 2^31, with 2^32 or more dW elements, or past

  • HIP's grid limits, in direct_wgrad, grouped, grouped_wgrad, depthwise_1d_toeplitz
    and depthwise_wgrad_hankel.
  • Layers with a tensor of more than 2^38 elements.
  • ConvParams::compute_output_size() now computes in 64 bits, and the new
    expected_output_size() and output_size_matches() expose the check.

    config_version() stays v0.5, so ConvHipConv perf-db records tuned against v0.5.0 still
    match, and the perf-config picker from #14532, trained on v0.5 configs, still applies.

    Solver

    v0.5.1 throws std::invalid_argument in more places. get_workspace_size,
    is_deterministic, get_weighted_throughput_index and the tolerance queries throw for a
    layer that get_valid_configs rejects as invalid. Every function that takes a Device,
    except launch, throws for a CU count outside [1, 1024]; launch returns
    hipErrorInvalidValue. Find catches only miopen::Exception, so such an exception failed
    the whole call with miopenStatusUnknownError instead of skipping ConvHipConv.

    ConvHipConv's IsApplicable, and PerformanceConfigConvHipConv's IsValid and
    InitFromDevice, now log the exception as a warning and treat the problem as not
    applicable. GetWti returns wti_approximate_worst. GetSolution returns a ConvSolution
    with miopenStatusInternalError, which Find skips. GetWorkspaceSize rethrows the
    exception as a miopen::Exception, since a guessed workspace size could undersize the
    caller'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 vendored
    v0.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>

    Diff: 698 lines (+552 / -146) across 38 files Reviewer: JonathanLichtnerAMD Review duration: 4147m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.71) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.71 · 698 lines diff across 38 files
    0.71
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.92 · 5 substantive comment(s)
    0.92
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    87%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.392
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    7 items
    therock-pr-bot[bot] therock-pr-bot[bot] commented on Nov 20, 2026 04:35 UTC
    Bot

    <!-- 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.

    🙋 Wish to Override Policy?

    therock-pr-bot[bot] therock-pr-bot[bot] commented on Nov 20, 2026 04:35 UTC
    Bot

    <!-- therock-pr-bot-fix-policies -->
    🎉 All checks passed! This PR is ready for review.

    JonathanLichtnerAMD JonathanLichtnerAMD commented on code on Nov 21, 2026 03:17 UTC
    Code Review
    projects/miopen/src/solver/conv/conv_hipconv.cpp:1
    @@ -594,9 +615,17 @@ bool ConvHipConv::IsApplicable(const ExecutionContext& ctx, const ProblemDescrip
         // Every kernel that writes 16-bit dw also writes fp32 dw, so find_config() on the fp32-dw
         // params decides applicability; GetConfigs() is needed only under the deterministic
         // attribute.
    -    if(!problem.GetConv().attribute.deterministic)
    -        return hipconv::find_config(*device, ToHipconvParams(problem)).has_value();
    -    return !GetConfigs(*device, problem).empty();
    +    try
    +    {
    +        if(!problem.GetConv().attribute.deterministic)
    +            return hipconv::find_config(*device, ToHipconvParams(problem)).has_value();
    +        return !GetConfigs(*device, problem).empty();
    +    }
    +    catch(const std::exception& ex)

    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.

    JonathanLichtnerAMD JonathanLichtnerAMD approved these changes on Nov 21, 2026 03:17 UTC
    Approved Reviewer

    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.

    petar-jovanovic petar-jovanovic commented on code on Nov 22, 2026 23:21 UTC
    Code Review
    projects/miopen/src/solver/conv/conv_hipconv.cpp:1
    @@ -594,9 +615,17 @@ bool ConvHipConv::IsApplicable(const ExecutionContext& ctx, const ProblemDescrip
         // Every kernel that writes 16-bit dw also writes fp32 dw, so find_config() on the fp32-dw
         // params decides applicability; GetConfigs() is needed only under the deterministic
         // attribute.
    -    if(!problem.GetConv().attribute.deterministic)
    -        return hipconv::find_config(*device, ToHipconvParams(problem)).has_value();
    -    return !GetConfigs(*device, problem).empty();
    +    try
    +    {
    +        if(!problem.GetConv().attribute.deterministic)
    +            return hipconv::find_config(*device, ToHipconvParams(problem)).has_value();
    +        return !GetConfigs(*device, problem).empty();
    +    }
    +    catch(const std::exception& ex)
    assistant-librarian[bot] assistant-librarian[bot] commented on Nov 24, 2026 07:21 UTC
    Bot

    <!-- therock-bump-breadcrumb -->

    TheRock Submodule Bump Activity


    _Newest first_

  • 2026-11-24 — Included in TheRock via ROCm/TheRock#10229. <!-- event-id: 4e97198e3358207ee29aa118ebc09349b0ede829_rocm-libraries_False --> <!-- event-time: 2026-11-24T07:08:27+00:00 -->
  • Assignees
    petar-jovanovic petar-jovanovic
    Labels
    risk: low confidence: 88.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 70.7% (HIGH) · Higher = larger blast radius
    70.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 88.0% · Lower = rushed or shallow review
    88.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.5% · Safe to merge
    8.5%