Skip to content

[ROCm] Use MIOpen immediate mode for convs first seen in graph capture - #201481

Closed
pablo-garay wants to merge 1 commit into
pytorch:mainfrom
ROCm:jeffdaily/miopen-conv-capture-safe
Closed

pablo-garay wants to merge 1 commit into
pytorch:mainfrom
ROCm:jeffdaily/miopen-conv-capture-safe

Conversation

@pablo-garay

@pablo-garay pablo-garay commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue or supporting maintainer

Fixes #188338
Supported by @jeffdaily

BC-breaking?

No.

Summary (human written only)

MIOpen convolutions fail hipGraph capture when the shape was not seen before capture. This uses MIOpen immediate mode for those convolutions during capture.

Agent details (if applicable)

Problem: a MIOpen convolution whose shape is first seen inside torch.cuda.graph capture fails with hipErrorStreamCaptureInvalidated, regardless of cudnn.benchmark / cudnn.deterministic.

Cause: on a benchmark-cache miss, findAlgorithm in Conv_miopen.cpp calls miopenFind*Algorithm, which launches timing runs of candidate kernels on the capturing stream.

Change: forward, backward-data and backward-weight take the existing immediate-mode path (GetSolution + *Immediate, no launches) when the stream is capturing and the shape is not in the benchmark cache. Warmed shapes keep their Find result under capture; the capture-time choice is not cached, so eager is unchanged. Returning DEFAULT_ALGO early from the deterministic && !benchmark branch was measured and rejected: MIOpen then fails eager convs with "No invoker was registered ... Was find executed?".

Test plan (MI300X gfx942 and R9700 gfx1201, MIOpen 3.6.1), done with Claude: new test_conv_cuda_graph_new_shape fails without the fix and passes with it; python test/nn/test_convolution.py -v -k cuda passes (gfx1201: only the pre-existing test_cudnn_not_mutate_stride_cuda failure, which also fails without the patch). A wider matrix (conv1d/2d/transpose x fp32/fp16/bf16 x benchmark x deterministic, the issue reproducer, and captured training steps) captures at a new shape and matches eager to within 1 ulp.

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

A MIOpen convolution whose shape is first seen inside `torch.cuda.graph` capture fails with `hipErrorStreamCaptureInvalidated`, with `cudnn.benchmark` on or off and with `cudnn.deterministic` set (pytorch#188338). On a benchmark-cache miss, `findAlgorithm` in `Conv_miopen.cpp` calls `miopenFind*Algorithm`, which launches timing runs of candidate kernels on the capturing stream. Shapes already run in eager are found in the cache and capture fine.

The forward, backward-data and backward-weight paths now take MIOpen's immediate mode (`miopenConvolution*GetSolution` plus `miopenConvolution*Immediate`, which picks a solution without launching anything) when the stream is capturing and the shape is not in the benchmark cache, in addition to when `torch.backends.miopen.immediate` is set. A shape warmed in eager keeps its Find result under capture, so captured graphs match eager numerics and speed; the capture-time choice is not inserted into the cache, so a later eager call still runs Find. Eager behaviour is unchanged.

Alternatives considered: returning `DEFAULT_ALGO` from the `deterministic && !benchmark` branch (which currently falls through to Find) only helps users who set `cudnn.deterministic`; `MIOPEN_FIND_MODE=FAST` is a process-wide setting and still fails with `cudnn.benchmark=True`; using immediate mode for every non-benchmark call would change eager algorithm choice for all ROCm users. This mirrors cuDNN, where the non-benchmark path uses heuristics that do not launch.

Test Plan:
Validated on MI300X (gfx942) and Radeon AI PRO R9700 (gfx1201), MIOpen 3.6.1, HIP 7.16. The new test fails without the fix (capture invalidated) and passes with it, three runs each with a fresh MIOpen user find-db:

```
python test/nn/test_convolution.py -v -k test_conv_cuda_graph_new_shape
python test/nn/test_convolution.py -v -k cuda
```

The `-k cuda` subset passes on gfx942 (638 run); on gfx1201 the only failure is `test_cudnn_not_mutate_stride_cuda`, which fails identically without this change. A wider script covering conv1d/conv2d/conv_transpose1d/conv_transpose2d in fp32/fp16/bf16 with `cudnn.benchmark` and `cudnn.deterministic` on and off, the reproducer from the issue, and a captured SGD training step all capture at a new shape and match eager to within one ulp (immediate mode and Find can choose different solvers).

Authored with Claude.
@pytorch-bot pytorch-bot Bot added the module: rocm AMD GPU support for Pytorch label Oct 19, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/201481

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (28 Unrelated Failures)

As of commit d523816 with merge base ad0210d (image):

NEW FAILURES SUPPRESSED BY AI (non-blocking) - The following jobs failed, but the AI CI Advisor judged the failures not to be evidence against this change:

  • pull / linux-jammy-py3.14-clang21 / test (dynamo_wrapped, 2, 7, lf-l-x86iavx512-8-64) (gh)
    test/test_reductions.py::TestReductionsCPU::test_quantile_partial_selection_cpu_float32

    AI verdict: AI verdict: not related

    The suspect commit only changes ROCm MIOpen convolution code (Conv_miopen.cpp) and adds a CUDA-graph convolution test. The failure is a CPU dynamo_wrapped quantile test that breaks while Dynamo traces np.quantile with fake tensors. The two don't connect, and the merge base was already failing other dynamo_wrapped numpy-interop tests the same way.

    Full reasoning on HUD →

  • pull / linux-jammy-py3.14t-clang21 / test (dynamo_wrapped, 4, 8, lf-l-x86iavx512-16-128) (gh)
    test/test_reductions.py::TestReductionsCPU::test_quantile_partial_selection_cpu_float32

    AI verdict: AI verdict: not related

    The suspect commit only touches ROCm-only MIOpen convolution code (Conv_miopen.cpp) and a CUDA/ROCm conv test, so it cannot affect a CPU dynamo test of quantile. The same test (the float64 variant, with the same dynamo fake-tensor quantile failure mode) already fails consistently at the merge base on all three runs.

    Full reasoning on HUD →

  • trunk / dynamo-unittest / dynamo-test (3.11) / test (dynamo_wrapped, 4, 7, mt-l-x86iavx512-8-64) (gh)
    test/test_reductions.py::TestReductionsCPU::test_quantile_partial_selection_cpu_float32

    AI verdict: AI verdict: not related

    The suspect only changes ROCm MIOpen convolution code (Conv_miopen.cpp, which isn't compiled into the CPU dynamo build) and adds a GPU conv test. The failing test, test_quantile_partial_selection, was already failing on the merge base (float64 variant, shard 1, in several runs), and shard 4 of this job was red at the merge base too.

    Full reasoning on HUD →

  • trunk / dynamo-unittest / dynamo-test (3.12) / test (dynamo_wrapped, 2, 7, mt-l-x86iavx512-8-64) (gh)
    test/test_reductions.py::TestReductionsCPU::test_quantile_partial_selection_cpu_float32

    AI verdict: AI verdict: not related

    The suspect commit only changes the ROCm MIOpen convolution path (Conv_miopen.cpp) and adds a CUDA-graph conv test, so it cannot affect a dynamo-wrapped CPU quantile test. The same test (its float64 variant) was already failing consistently at the merge base, across several trunk runs before this commit.

    Full reasoning on HUD →

  • trunk / dynamo-unittest / dynamo-test (3.13) / test (dynamo_wrapped, 1, 7, mt-l-x86iavx512-8-64) (gh)
    test/test_reductions.py::TestReductionsCPU::test_quantile_partial_selection_cpu_float32

    AI verdict: AI verdict: not related

    The failure is a Dynamo fake-tensor error in CPU torch.quantile (expand: attempting to expand a dimension of length 2 -> 1!) in test_quantile_partial_selection. The same test already fails consistently at the merge base (as the float64 variant, on shard 3). The suspect commit only changes ROCm MIOpen convolution C++ code and adds a test in test/nn/test_convolution.py, so nothing in it can reach this test.

    Full reasoning on HUD →

  • trunk / dynamo-unittest / dynamo-test (3.15) / test (dynamo_wrapped, 1, 7, mt-l-x86iavx512-8-64) (gh)
    test/test_reductions.py::TestReductionsCPU::test_quantile_partial_selection_cpu_float32

    AI verdict: AI verdict: not related

    The suspect only changes the ROCm MIOpen convolution path (Conv_miopen.cpp) and adds a GPU conv test. The failure is a Dynamo fake-tensor expand error in the CPU test test_quantile_partial_selection. Across several runs at the merge base, the float64 variant of the same test already fails consistently on a different shard, so the failure was there before this commit.

    Full reasoning on HUD →

  • trunk / macos-py3-arm64 / test (default, 1, 3, macos-m1-stable) (gh)
    test/test_precompile.py::TestPrecompileDynamoCapture::test_an_installed_artifact_can_opt_into_serve_time_compiles_caching_precompile_False

    AI verdict: AI verdict: not related

    The suspect commit only changes ROCm MIOpen convolution C++ code (Conv_miopen.cpp, which is not compiled on macOS) and adds a test to test/nn/test_convolution.py. The macOS failure is a Python-level PrecompileError raised in torch/_precompile.py inside a test_precompile.py test, and a sibling test in the same file was already failing consistently at the merge base.

    Full reasoning on HUD →

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@jithunnair-amd jithunnair-amd added ciflow/trunk Trigger trunk jobs on your pull request ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/rocm-mi200 Trigger "default" config CI on ROCm MI200 labels Oct 19, 2026
@jeffdaily
jeffdaily marked this pull request as ready for review October 27, 2026 06:36
@jeffdaily jeffdaily added the release notes: rocm mandatorylabel label Oct 27, 2026
@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Oct 27, 2026
@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 28 checks: pull / linux-jammy-py3.14-clang21 / test (dynamo_wrapped, 3, 7, lf-l-x86iavx512-8-64), pull / linux-jammy-py3.14-clang21 / test (dynamo_wrapped, 2, 7, lf-l-x86iavx512-8-64), pull / linux-jammy-py3.14t-clang21 / test (dynamo_wrapped, 5, 8, lf-l-x86iavx512-16-128), pull / linux-jammy-py3.11-clang21 / test (dynamo_wrapped, 1, 6, lf-l-x86iavx512-8-64), pull / linux-jammy-py3.14t-clang21 / test (dynamo_wrapped, 4, 8, lf-l-x86iavx512-16-128), trunk / dynamo-unittest / dynamo-test (3.12) / test (dynamo_wrapped, 2, 7, mt-l-x86iavx512-8-64), trunk / dynamo-unittest / dynamo-test (3.12) / test (dynamo_wrapped, 3, 7, mt-l-x86iavx512-8-64), trunk / dynamo-unittest / dynamo-test (3.15) / test (dynamo_wrapped, 2, 7, mt-l-x86iavx512-8-64), trunk / dynamo-unittest / dynamo-test (3.15) / test (dynamo_wrapped, 1, 7, mt-l-x86iavx512-8-64), trunk / dynamo-unittest / dynamo-test (3.11) / test (dynamo_wrapped, 1, 7, mt-l-x86iavx512-8-64), trunk / dynamo-unittest / dynamo-test (3.13) / test (dynamo_wrapped, 2, 7, mt-l-x86iavx512-8-64), trunk / dynamo-unittest / dynamo-test (3.13) / test (dynamo_wrapped, 1, 7, mt-l-x86iavx512-8-64), trunk / dynamo-unittest / dynamo-test (3.11) / test (dynamo_wrapped, 4, 7, mt-l-x86iavx512-8-64), trunk / macos-py3-arm64 / test (mps, 1, 1, macos-m2-15), trunk / macos-py3-arm64 / test (default, 1, 3, macos-m1-stable), trunk / linux-noble-rocm-py3.11-mi350 / test (default, 3, 8, linux.rocm.gpu.mi350.dpx.1, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (default, 5, 8, linux.rocm.gpu.mi350.dpx.1, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (inductor, 1, 2, linux.rocm.gpu.mi350.dpx.1, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (default, 7, 8, linux.rocm.gpu.mi350.dpx.1, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (default, 4, 8, linux.rocm.gpu.mi350.dpx.1, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (distributed, 1, 3, linux.rocm.gpu.mi350.dpx.2, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (inductor-flydsl, 1, 1, linux.rocm.gpu.mi350.dpx.1, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (distributed, 3, 3, linux.rocm.gpu.mi350.dpx.2, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (default, 8, 8, linux.rocm.gpu.mi350.dpx.1, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (default, 6, 8, linux.rocm.gpu.mi350.dpx.1, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (default, 1, 8, linux.rocm.gpu.mi350.dpx.1, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (distributed, 2, 3, linux.rocm.gpu.mi350.dpx.2, unstable), trunk / linux-noble-rocm-py3.11-mi350 / test (inductor, 2, 2, linux.rocm.gpu.mi350.dpx.1, unstable)

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit that referenced this pull request Oct 29, 2026
## Linked issue or supporting maintainer

Follow-up to #201481 (author has write access).

## BC-breaking?

No

## Summary (human written only)

Test-only follow-up to #201481: pin the new graph-capture conv test to deterministic MIOpen solvers so it stops failing on the ROCm preview image. Details below.

## Agent details (if applicable)

`test_conv_cuda_graph_new_shape` (from #201481) fails on the rocm-preview mi350 job for its transposed fp16 variants. Only `grad_weight` differs, and it is not the capture: replaying the same graph twice gives different results, and so do two eager calls. From ROCm 10.2 (MIOpen 3.6.2), MIOpen's default config for these small fp16 weight-gradient convs is the global split-K variant of `ConvAsmImplicitGemmGTCDynamicWrwXdlopsNHWC`, whose reduction order is not fixed; ROCm 10.1 picked a non-split config of the same solver, which happened to be exact. The test compares two runs of a conv it never asked to be deterministic, at the fp16 default tolerance.

Passing `deterministic=True` to `cudnn.flags` makes MIOpen use a deterministic solver (CK `ConvHipImplicitGemmGroupWrwXdlops`), so replay, eager immediate and eager Find agree bit for bit. The capture failure #201481 fixes does not depend on deterministic, so the test still catches it. Loosening the tolerance instead would need about atol 0.2 for fp16 `grad_weight`.

Test Plan: on MI355X (gfx950), at the same commit, ROCm 10.2.0a20261014 and 10.3.0a20261027 fail 3 of 12 variants before this change and pass 12/12 after (3 runs each); ROCm 10.1 passes both before and after; against a torch without #201481 the changed test fails with the capture error.
```
python test/nn/test_convolution.py -k test_conv_cuda_graph_new_shape -v
```

Authored with Claude.

Pull Request resolved: #202451
Approved by: https://github.com/jbschlosser
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
)

## Linked issue or supporting maintainer

Follow-up to pytorch#201481 (author has write access).

## BC-breaking?

No

## Summary (human written only)

Test-only follow-up to pytorch#201481: pin the new graph-capture conv test to deterministic MIOpen solvers so it stops failing on the ROCm preview image. Details below.

## Agent details (if applicable)

`test_conv_cuda_graph_new_shape` (from pytorch#201481) fails on the rocm-preview mi350 job for its transposed fp16 variants. Only `grad_weight` differs, and it is not the capture: replaying the same graph twice gives different results, and so do two eager calls. From ROCm 10.2 (MIOpen 3.6.2), MIOpen's default config for these small fp16 weight-gradient convs is the global split-K variant of `ConvAsmImplicitGemmGTCDynamicWrwXdlopsNHWC`, whose reduction order is not fixed; ROCm 10.1 picked a non-split config of the same solver, which happened to be exact. The test compares two runs of a conv it never asked to be deterministic, at the fp16 default tolerance.

Passing `deterministic=True` to `cudnn.flags` makes MIOpen use a deterministic solver (CK `ConvHipImplicitGemmGroupWrwXdlops`), so replay, eager immediate and eager Find agree bit for bit. The capture failure pytorch#201481 fixes does not depend on deterministic, so the test still catches it. Loosening the tolerance instead would need about atol 0.2 for fp16 `grad_weight`.

Test Plan: on MI355X (gfx950), at the same commit, ROCm 10.2.0a20261014 and 10.3.0a20261027 fail 3 of 12 variants before this change and pass 12/12 after (3 runs each); ROCm 10.1 passes both before and after; against a torch without pytorch#201481 the changed test fails with the capture error.
```
python test/nn/test_convolution.py -k test_conv_cuda_graph_new_shape -v
```

Authored with Claude.

Pull Request resolved: pytorch#202451
Approved by: https://github.com/jbschlosser
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
)

## Linked issue or supporting maintainer

Follow-up to pytorch#201481 (author has write access).

## BC-breaking?

No

## Summary (human written only)

Test-only follow-up to pytorch#201481: pin the new graph-capture conv test to deterministic MIOpen solvers so it stops failing on the ROCm preview image. Details below.

## Agent details (if applicable)

`test_conv_cuda_graph_new_shape` (from pytorch#201481) fails on the rocm-preview mi350 job for its transposed fp16 variants. Only `grad_weight` differs, and it is not the capture: replaying the same graph twice gives different results, and so do two eager calls. From ROCm 10.2 (MIOpen 3.6.2), MIOpen's default config for these small fp16 weight-gradient convs is the global split-K variant of `ConvAsmImplicitGemmGTCDynamicWrwXdlopsNHWC`, whose reduction order is not fixed; ROCm 10.1 picked a non-split config of the same solver, which happened to be exact. The test compares two runs of a conv it never asked to be deterministic, at the fp16 default tolerance.

Passing `deterministic=True` to `cudnn.flags` makes MIOpen use a deterministic solver (CK `ConvHipImplicitGemmGroupWrwXdlops`), so replay, eager immediate and eager Find agree bit for bit. The capture failure pytorch#201481 fixes does not depend on deterministic, so the test still catches it. Loosening the tolerance instead would need about atol 0.2 for fp16 `grad_weight`.

Test Plan: on MI355X (gfx950), at the same commit, ROCm 10.2.0a20261014 and 10.3.0a20261027 fail 3 of 12 variants before this change and pass 12/12 after (3 runs each); ROCm 10.1 passes both before and after; against a torch without pytorch#201481 the changed test fails with the capture error.
```
python test/nn/test_convolution.py -k test_conv_cuda_graph_new_shape -v
```

Authored with Claude.

Pull Request resolved: pytorch#202451
Approved by: https://github.com/jbschlosser

This branch was previously deployed

1 inactive deployment
bedrock — d5238165 Deployed Oct 27, 2026 by jeffdaily via analyze #15211
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot ciflow/rocm-mi200 Trigger "default" config CI on ROCm MI200 ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/trunk Trigger trunk jobs on your pull request Merged module: rocm AMD GPU support for Pytorch open source release notes: rocm mandatorylabel triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ROCm]: CUDAGraph safe Convolutional Kernel e.g. F.conv_transpose1d

5 participants