Skip to content

DynUNet: opt-in, ROCm-only GEMM decomposition for decoder ConvTranspose3d upsamples#2

Open
nilapate wants to merge 2 commits into
amd-integrationfrom
nilapate/spleen_deepedit_opt
Open

DynUNet: opt-in, ROCm-only GEMM decomposition for decoder ConvTranspose3d upsamples#2
nilapate wants to merge 2 commits into
amd-integrationfrom
nilapate/spleen_deepedit_opt

Conversation

@nilapate

@nilapate nilapate commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Description

When kernel_size == stride, a transposed conv admits an exact pixel-shuffle GEMM decomposition (single matmul), which runs faster on MI300X. New use_gemm_transpose flag (default False) threads from DynUNet to the upsample blocks; activates only when set and on ROCm. NVIDIA/CPU and all existing bundles are unchanged.

Change type and validation

  • Non-breaking change.
  • New tests added to cover the changes.
  • Quick tests passed locally (targeted GEMM tests → 6 passed).
  • In-line docstrings updated.

nilapate added 2 commits July 3, 2026 11:03
Add use_gemm_transpose param to DynUNet -> UnetUpBlock. When set (and on ROCm),
decoder ConvTranspose3d upsamples with kernel_size == stride use an exact
pixel-shuffle GEMM decomposition instead of the slow MIOpen/CK transpose kernel.

- UnetUpBlock: gate = use_gemm_transpose and torch.version.hip is not None, computed
  once in __init__ (trace-time constant, no graph break under torch.compile).
  _transp_conv_gemm falls through to stock transp_conv for any shape violating the
  decomposition preconditions (k != s, dilation, output_padding, groups != 1,
  non-5D input, or an ADN sublayer on the transpose conv).
- DynUNet: thread use_gemm_transpose (default False) through get_upsamples /
  get_module_list to the upsample blocks only; downsamples never see it.

Default False -> every other DynUNet bundle is byte-for-byte unchanged. Activated
per-model via the bundle's inference_rocm.json overlay.

Verified: GEMM path == stock transpose conv to 8.8e-6 max abs (fp32); anchored Dice
gate PASS all 9 rungs (spleen_deepedit bf16 CT_GEMM dice=0.9997).

Signed-off-by: Patel, Nilaykumar K <nilapate@amd.com>
Add TestUpBlockGemmTranspose (block level) and TestDynUNetGemmTranspose
(network level) covering the opt-in use_gemm_transpose path: decomposition
== stock ConvTranspose3d, k!=s fall-through, forward equivalence with shared
weights, ROCm-only runtime gate, and flag threading to all upsample blocks.

Signed-off-by: Patel, Nilaykumar K <nilapate@amd.com>


class TestUpBlockGemmTranspose(unittest.TestCase):
"""AMD MI300X: the opt-in pixel-shuffle GEMM decomposition of the decoder

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If this is not specific to MI300X, I would recommend you just mention AMD Instinct.



class TestDynUNetGemmTranspose(unittest.TestCase):
"""AMD MI300X: use_gemm_transpose must thread from DynUNet down to every

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same here

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.

2 participants