From 89a218d373a47887b77064ae935e3e22f2d875d2 Mon Sep 17 00:00:00 2001 From: Dmitry Nikolaev <139769634+dnikolaev-amd@users.noreply.github.com> Date: Mon, 28 Apr 2025 07:11:42 +0200 Subject: [PATCH 1/6] Cherry-picked commit with merge conflict --- test/jit/test_freezing.py | 7 +++++++ test/nn/test_convolution.py | 3 +++ torch/testing/_internal/common_utils.py | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/test/jit/test_freezing.py b/test/jit/test_freezing.py index 8258124680b47..899ecdf013b3e 100644 --- a/test/jit/test_freezing.py +++ b/test/jit/test_freezing.py @@ -15,9 +15,14 @@ from torch.testing._internal.common_quantization import skipIfNoFBGEMM from torch.testing._internal.common_quantized import override_quantized_engine from torch.testing._internal.common_utils import ( +<<<<<<< HEAD raise_on_run_directly, +======= + NAVI_ARCH, +>>>>>>> 3b9e558b7c ([release/2.6] skip convolution tests on Navi (#2055)) set_default_dtype, skipCUDAMemoryLeakCheckIf, + skipIfRocmArch, skipIfTorchDynamo, TEST_WITH_ROCM, ) @@ -2967,6 +2972,7 @@ def test_conv_to_mkldnn_no_mkldnn(self): self.assertEqual(frozen(inp), mod(inp)) @unittest.skipIf(not (TEST_CUDNN or TEST_WITH_ROCM), "requires CUDNN") + @skipIfRocmArch(NAVI_ARCH) # not supported by MIOPEN on NAVI def test_freeze_conv_relu_fusion(self): with set_default_dtype(torch.float): conv_bias = [True, False] @@ -3029,6 +3035,7 @@ def forward(self, x): self.assertEqual(mod_eager(inp), frozen_mod(inp)) @unittest.skipIf(not (TEST_CUDNN or TEST_WITH_ROCM), "requires CUDNN") + @skipIfRocmArch(NAVI_ARCH) # not supported by MIOPEN on NAVI def test_freeze_conv_relu_fusion_not_forward(self): with set_default_dtype(torch.float): diff --git a/test/nn/test_convolution.py b/test/nn/test_convolution.py index 22555a9b588d6..b79695f142834 100644 --- a/test/nn/test_convolution.py +++ b/test/nn/test_convolution.py @@ -48,10 +48,12 @@ gradgradcheck, instantiate_parametrized_tests, MACOS_VERSION, + NAVI_ARCH, parametrize as parametrize_test, run_tests, set_default_dtype, skipIfNotMiopenSuggestNHWC, + skipIfRocmArch, skipIfRocmVersionLessThan, subtest, TEST_SCIPY, @@ -3883,6 +3885,7 @@ def test_conv2d_no_grad(self, device, dtype): @onlyCUDA @skipCUDAIfNoCudnn + @skipIfRocmArch(NAVI_ARCH) # not supported by MIOPEN on NAVI @dtypes(torch.float, torch.float16) @precisionOverride({torch.half: 0.002, torch.float: 1e-4}) def test_cudnn_convolution_relu(self, device, dtype): diff --git a/torch/testing/_internal/common_utils.py b/torch/testing/_internal/common_utils.py index 58398f5287000..398ec5b5954cf 100644 --- a/torch/testing/_internal/common_utils.py +++ b/torch/testing/_internal/common_utils.py @@ -105,6 +105,7 @@ MI300_ARCH = ("gfx940", "gfx941", "gfx942") NAVI_ARCH = ("gfx1030", "gfx1100", "gfx1101", "gfx1200", "gfx1201") +<<<<<<< HEAD NAVI3_ARCH = ("gfx1100", "gfx1101") NAVI4_ARCH = ("gfx1200", "gfx1201") @@ -115,6 +116,9 @@ def is_navi3_arch(): if gfx_arch in NAVI3_ARCH: return True return False +======= +NAVI4_ARCH = ("gfx1200", "gfx1201") +>>>>>>> 3b9e558b7c ([release/2.6] skip convolution tests on Navi (#2055)) def freeze_rng_state(*args, **kwargs): return torch.testing._utils.freeze_rng_state(*args, **kwargs) @@ -1926,11 +1930,19 @@ def wrapper(*args, **kwargs): return dec_fn(func) return dec_fn +<<<<<<< HEAD def skipIfRocmArch(arch: tuple[str, ...]): def dec_fn(fn): @wraps(fn) def wrap_fn(self, *args, **kwargs): if TEST_WITH_ROCM: +======= +def skipIfRocmArch(arch: Tuple[str, ...]): + def dec_fn(fn): + @wraps(fn) + def wrap_fn(self, *args, **kwargs): + if TEST_WITH_ROCM: # noqa: F821 +>>>>>>> 3b9e558b7c ([release/2.6] skip convolution tests on Navi (#2055)) prop = torch.cuda.get_device_properties(0) if prop.gcnArchName.split(":")[0] in arch: reason = f"skipIfRocm: test skipped on {arch}" From 21fcf5909345fbef3b5f3c7cdd9bf95a1db96e31 Mon Sep 17 00:00:00 2001 From: Artem Kuzmitckii Date: Wed, 24 Sep 2025 10:47:18 +0200 Subject: [PATCH 2/6] Update test_freezing.py Fix merge conflicts --- test/jit/test_freezing.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/jit/test_freezing.py b/test/jit/test_freezing.py index 899ecdf013b3e..1a5dea318b297 100644 --- a/test/jit/test_freezing.py +++ b/test/jit/test_freezing.py @@ -15,11 +15,8 @@ from torch.testing._internal.common_quantization import skipIfNoFBGEMM from torch.testing._internal.common_quantized import override_quantized_engine from torch.testing._internal.common_utils import ( -<<<<<<< HEAD raise_on_run_directly, -======= NAVI_ARCH, ->>>>>>> 3b9e558b7c ([release/2.6] skip convolution tests on Navi (#2055)) set_default_dtype, skipCUDAMemoryLeakCheckIf, skipIfRocmArch, From 3f3b83a1d1f941638ee4f2c8c290b4d583e8d17f Mon Sep 17 00:00:00 2001 From: Artem Kuzmitckii Date: Wed, 24 Sep 2025 10:48:56 +0200 Subject: [PATCH 3/6] Update common_utils.py Fix merge conflicts --- torch/testing/_internal/common_utils.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/torch/testing/_internal/common_utils.py b/torch/testing/_internal/common_utils.py index 398ec5b5954cf..f88c62e9fa71e 100644 --- a/torch/testing/_internal/common_utils.py +++ b/torch/testing/_internal/common_utils.py @@ -105,7 +105,6 @@ MI300_ARCH = ("gfx940", "gfx941", "gfx942") NAVI_ARCH = ("gfx1030", "gfx1100", "gfx1101", "gfx1200", "gfx1201") -<<<<<<< HEAD NAVI3_ARCH = ("gfx1100", "gfx1101") NAVI4_ARCH = ("gfx1200", "gfx1201") @@ -116,9 +115,6 @@ def is_navi3_arch(): if gfx_arch in NAVI3_ARCH: return True return False -======= -NAVI4_ARCH = ("gfx1200", "gfx1201") ->>>>>>> 3b9e558b7c ([release/2.6] skip convolution tests on Navi (#2055)) def freeze_rng_state(*args, **kwargs): return torch.testing._utils.freeze_rng_state(*args, **kwargs) @@ -1930,19 +1926,11 @@ def wrapper(*args, **kwargs): return dec_fn(func) return dec_fn -<<<<<<< HEAD def skipIfRocmArch(arch: tuple[str, ...]): def dec_fn(fn): @wraps(fn) def wrap_fn(self, *args, **kwargs): if TEST_WITH_ROCM: -======= -def skipIfRocmArch(arch: Tuple[str, ...]): - def dec_fn(fn): - @wraps(fn) - def wrap_fn(self, *args, **kwargs): - if TEST_WITH_ROCM: # noqa: F821 ->>>>>>> 3b9e558b7c ([release/2.6] skip convolution tests on Navi (#2055)) prop = torch.cuda.get_device_properties(0) if prop.gcnArchName.split(":")[0] in arch: reason = f"skipIfRocm: test skipped on {arch}" @@ -5772,4 +5760,4 @@ def wrapper(self, *args, **kwargs): setattr(self, member, original_value) return wrapper - return decorator \ No newline at end of file + return decorator From 3676831418901a1ffc9937abab78a5353b699c92 Mon Sep 17 00:00:00 2001 From: Artem Kuzmitckii Date: Wed, 24 Sep 2025 12:08:46 +0200 Subject: [PATCH 4/6] Update test_freezing.py For both tests (nn and jit) we need support of `ConvBinWinogradRxSf2x3g1Fused` kernel in MIOpen which currently doesn't support for NAVI4(gfx12x), but it works for NAVI3(gfx11x), so enable tests for NAVI3 but keep disabled for NAVI4. --- test/jit/test_freezing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jit/test_freezing.py b/test/jit/test_freezing.py index 1a5dea318b297..584af1024e175 100644 --- a/test/jit/test_freezing.py +++ b/test/jit/test_freezing.py @@ -16,7 +16,7 @@ from torch.testing._internal.common_quantized import override_quantized_engine from torch.testing._internal.common_utils import ( raise_on_run_directly, - NAVI_ARCH, + NAVI4_ARCH, set_default_dtype, skipCUDAMemoryLeakCheckIf, skipIfRocmArch, @@ -2969,7 +2969,7 @@ def test_conv_to_mkldnn_no_mkldnn(self): self.assertEqual(frozen(inp), mod(inp)) @unittest.skipIf(not (TEST_CUDNN or TEST_WITH_ROCM), "requires CUDNN") - @skipIfRocmArch(NAVI_ARCH) # not supported by MIOPEN on NAVI + @skipIfRocmArch(NAVI4_ARCH) # not supported by MIOPEN on NAVI4x def test_freeze_conv_relu_fusion(self): with set_default_dtype(torch.float): conv_bias = [True, False] From 172f384d0680631e5fa109fd3e030f84625b2aa1 Mon Sep 17 00:00:00 2001 From: Artem Kuzmitckii Date: Wed, 24 Sep 2025 12:16:02 +0200 Subject: [PATCH 5/6] Update test_convolution.py For both tests (nn and jit) we need support of `ConvBinWinogradRxSf2x3g1Fused` kernel in MIOpen which currently doesn't support for NAVI4(gfx12x), but it works for NAVI3(gfx11x), so enable tests for NAVI3 but keep disabled for NAVI4. --- test/nn/test_convolution.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/nn/test_convolution.py b/test/nn/test_convolution.py index b79695f142834..2685a35ba5873 100644 --- a/test/nn/test_convolution.py +++ b/test/nn/test_convolution.py @@ -48,7 +48,7 @@ gradgradcheck, instantiate_parametrized_tests, MACOS_VERSION, - NAVI_ARCH, + NAVI4_ARCH, parametrize as parametrize_test, run_tests, set_default_dtype, @@ -3885,7 +3885,7 @@ def test_conv2d_no_grad(self, device, dtype): @onlyCUDA @skipCUDAIfNoCudnn - @skipIfRocmArch(NAVI_ARCH) # not supported by MIOPEN on NAVI + @skipIfRocmArch(NAVI4_ARCH) # not supported by MIOPEN on NAVI4x @dtypes(torch.float, torch.float16) @precisionOverride({torch.half: 0.002, torch.float: 1e-4}) def test_cudnn_convolution_relu(self, device, dtype): From cd1d7515b957788d9eb218ff87a9bee5afa2e116 Mon Sep 17 00:00:00 2001 From: Artem Kuzmitckii Date: Wed, 24 Sep 2025 12:26:13 +0200 Subject: [PATCH 6/6] Update test_freezing.py Enable for Navi3x --- test/jit/test_freezing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jit/test_freezing.py b/test/jit/test_freezing.py index 584af1024e175..626b9412a7b4e 100644 --- a/test/jit/test_freezing.py +++ b/test/jit/test_freezing.py @@ -3032,7 +3032,7 @@ def forward(self, x): self.assertEqual(mod_eager(inp), frozen_mod(inp)) @unittest.skipIf(not (TEST_CUDNN or TEST_WITH_ROCM), "requires CUDNN") - @skipIfRocmArch(NAVI_ARCH) # not supported by MIOPEN on NAVI + @skipIfRocmArch(NAVI4_ARCH) # not supported by MIOPEN on NAVI4x def test_freeze_conv_relu_fusion_not_forward(self): with set_default_dtype(torch.float):