From 2007611e38105f36896910c19c8debef7b3ffd75 Mon Sep 17 00:00:00 2001 From: iupaikov-amd Date: Wed, 6 Nov 2024 17:34:09 +0100 Subject: [PATCH 1/3] Skipped some inductor tests for no hipcc rocm environments --- test/inductor/test_torchinductor.py | 6 ++++++ torch/testing/_internal/common_utils.py | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/inductor/test_torchinductor.py b/test/inductor/test_torchinductor.py index 6f6fd1987ebe1..10007559e36a5 100644 --- a/test/inductor/test_torchinductor.py +++ b/test/inductor/test_torchinductor.py @@ -85,6 +85,7 @@ subtest, TEST_WITH_ASAN, TEST_WITH_ROCM, + HAS_HIPCC, ) from torch.utils import _pytree as pytree from torch.utils._python_dispatch import TorchDispatchMode @@ -93,6 +94,8 @@ DO_PERF_TEST = os.environ.get("DO_PERF_TEST") == "1" +ROCM_WHEELS_ENV = TEST_WITH_ROCM and not HAS_HIPCC + if IS_WINDOWS and IS_CI: sys.stderr.write( "Windows CI does not have necessary dependencies for test_torchinductor yet\n" @@ -751,6 +754,7 @@ def fn(a, b): ) @skipCUDAIf(not SM80OrLater, "Requires sm80") + @skipCUDAIf(ROCM_WHEELS_ENV, "ROCm requires hipcc compiler") def test_eager_aoti_cache_hit(self): ns = "aten" op_name = "abs" @@ -803,6 +807,7 @@ def test_eager_aoti_cache_hit(self): self.assertEqual(ref_value, res_value) @skipCUDAIf(not SM80OrLater, "Requires sm80") + @skipCUDAIf(ROCM_WHEELS_ENV, "ROCm requires hipcc compiler") def test_aoti_compile_with_persistent_cache(self): def fn(a): return torch.abs(a) @@ -6661,6 +6666,7 @@ def fn(x): self.common(fn, [torch.randn(64, 64)]) + @unittest.skipIf(ROCM_WHEELS_ENV, "ROCm requires hipcc compiler") def test_new_cpp_build_logical(self): from torch._inductor.codecache import validate_new_cpp_commands diff --git a/torch/testing/_internal/common_utils.py b/torch/testing/_internal/common_utils.py index 66af12cd60215..d33c9775b6115 100644 --- a/torch/testing/_internal/common_utils.py +++ b/torch/testing/_internal/common_utils.py @@ -94,6 +94,7 @@ from torch.testing._comparison import not_close_error_metas from torch.testing._internal.common_dtype import get_all_dtypes from torch.utils._import_utils import _check_module_exists +from torch.utils.cpp_extension import ROCM_HOME import torch.utils._pytree as pytree try: @@ -102,9 +103,10 @@ except ImportError: has_pytest = False - NAVI_ARCH = ("gfx1030", "gfx1100", "gfx1101") +HAS_HIPCC = torch.version.hip is not None and ROCM_HOME is not None + def freeze_rng_state(*args, **kwargs): return torch.testing._utils.freeze_rng_state(*args, **kwargs) From 861f9246970096f83cb6049e9f04ff19ecb89f96 Mon Sep 17 00:00:00 2001 From: iupaikov-amd Date: Wed, 13 Nov 2024 18:48:38 +0100 Subject: [PATCH 2/3] Skipped some inductor tests for no hipcc rocm environments --- torch/testing/_internal/common_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torch/testing/_internal/common_utils.py b/torch/testing/_internal/common_utils.py index d33c9775b6115..b601e289950b4 100644 --- a/torch/testing/_internal/common_utils.py +++ b/torch/testing/_internal/common_utils.py @@ -105,7 +105,7 @@ NAVI_ARCH = ("gfx1030", "gfx1100", "gfx1101") -HAS_HIPCC = torch.version.hip is not None and ROCM_HOME is not None +HAS_HIPCC = torch.version.hip is not None and ROCM_HOME is not None and shutil.which('hipcc') is not None def freeze_rng_state(*args, **kwargs): return torch.testing._utils.freeze_rng_state(*args, **kwargs) From 14009c21463535a5e99f04d7de3040aa34bb0dfe Mon Sep 17 00:00:00 2001 From: iupaikov-amd Date: Wed, 13 Nov 2024 20:10:34 +0100 Subject: [PATCH 3/3] Simplified the skip check --- test/inductor/test_torchinductor.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/inductor/test_torchinductor.py b/test/inductor/test_torchinductor.py index 10007559e36a5..28d50d2eb7139 100644 --- a/test/inductor/test_torchinductor.py +++ b/test/inductor/test_torchinductor.py @@ -94,8 +94,6 @@ DO_PERF_TEST = os.environ.get("DO_PERF_TEST") == "1" -ROCM_WHEELS_ENV = TEST_WITH_ROCM and not HAS_HIPCC - if IS_WINDOWS and IS_CI: sys.stderr.write( "Windows CI does not have necessary dependencies for test_torchinductor yet\n" @@ -754,7 +752,7 @@ def fn(a, b): ) @skipCUDAIf(not SM80OrLater, "Requires sm80") - @skipCUDAIf(ROCM_WHEELS_ENV, "ROCm requires hipcc compiler") + @skipCUDAIf(TEST_WITH_ROCM and not HAS_HIPCC, "ROCm requires hipcc compiler") def test_eager_aoti_cache_hit(self): ns = "aten" op_name = "abs" @@ -807,7 +805,7 @@ def test_eager_aoti_cache_hit(self): self.assertEqual(ref_value, res_value) @skipCUDAIf(not SM80OrLater, "Requires sm80") - @skipCUDAIf(ROCM_WHEELS_ENV, "ROCm requires hipcc compiler") + @skipCUDAIf(TEST_WITH_ROCM and not HAS_HIPCC, "ROCm requires hipcc compiler") def test_aoti_compile_with_persistent_cache(self): def fn(a): return torch.abs(a) @@ -6666,7 +6664,7 @@ def fn(x): self.common(fn, [torch.randn(64, 64)]) - @unittest.skipIf(ROCM_WHEELS_ENV, "ROCm requires hipcc compiler") + @unittest.skipIf(TEST_WITH_ROCM and not HAS_HIPCC, "ROCm requires hipcc compiler") def test_new_cpp_build_logical(self): from torch._inductor.codecache import validate_new_cpp_commands