From 91e8412b685b5c93bc31fff09677362a6ce2302e Mon Sep 17 00:00:00 2001 From: Alexander Peskov Date: Tue, 19 Mar 2024 08:28:56 +0000 Subject: [PATCH 1/5] [TEST] Mark RELAX GPU tests with pytest.mark.gpu Missed pytest.mark.gpu prevents tests from launch in CI. Signed-off-by: Alexander Peskov --- tests/python/relax/test_codegen_cublas.py | 9 +-------- tests/python/relax/test_codegen_cudnn.py | 9 +-------- tests/python/relax/test_codegen_cutlass.py | 9 +-------- tests/python/relax/test_codegen_tensorrt.py | 13 +++++++++++-- tests/python/relax/test_contrib_vllm.py | 2 +- tests/python/relax/test_transform_codegen_pass.py | 8 +++++--- 6 files changed, 20 insertions(+), 30 deletions(-) diff --git a/tests/python/relax/test_codegen_cublas.py b/tests/python/relax/test_codegen_cublas.py index 4f357626b804..ed35a652f680 100644 --- a/tests/python/relax/test_codegen_cublas.py +++ b/tests/python/relax/test_codegen_cublas.py @@ -36,14 +36,7 @@ def reset_seed(): np.random.seed(0) -has_cublas = tvm.get_global_func("relax.ext.cublas", True) - -cublas_enabled = pytest.mark.skipif( - not has_cublas, - reason="CUBLAS not enabled.", -) - -pytestmark = [cublas_enabled] +# pytestmark = tvm.testing.requires_cublas.marks() def build_and_run(mod, inputs_np, target, legalize=False, cuda_graph=False): diff --git a/tests/python/relax/test_codegen_cudnn.py b/tests/python/relax/test_codegen_cudnn.py index c91355923298..f34270587812 100644 --- a/tests/python/relax/test_codegen_cudnn.py +++ b/tests/python/relax/test_codegen_cudnn.py @@ -34,14 +34,7 @@ def reset_seed(): np.random.seed(0) -has_cudnn = tvm.get_global_func("relax.ext.cudnn", True) - -cudnn_enabled = pytest.mark.skipif( - not has_cudnn, - reason="cuDNN not enabled.", -) - -pytestmark = [cudnn_enabled] +pytestmark = tvm.testing.requires_cudnn.marks() _activation_table = { diff --git a/tests/python/relax/test_codegen_cutlass.py b/tests/python/relax/test_codegen_cutlass.py index fced7a84a832..57f47ca6e6c0 100644 --- a/tests/python/relax/test_codegen_cutlass.py +++ b/tests/python/relax/test_codegen_cutlass.py @@ -75,14 +75,7 @@ def main( return conv2 -has_cutlass = tvm.get_global_func("relax.ext.cutlass", True) - -cutlass_enabled = pytest.mark.skipif( - not has_cutlass, - reason="CUTLASS not enabled.", -) - -pytestmark = [cutlass_enabled] +pytestmark = tvm.testing.requires_cutlass.marks() def build_and_run(mod, inputs_np, target, legalize=True, cuda_graph=False): diff --git a/tests/python/relax/test_codegen_tensorrt.py b/tests/python/relax/test_codegen_tensorrt.py index 23dc7d887f4c..009bb24c63b8 100644 --- a/tests/python/relax/test_codegen_tensorrt.py +++ b/tests/python/relax/test_codegen_tensorrt.py @@ -43,13 +43,22 @@ def main( has_tensorrt = tvm.get_global_func("relax.ext.tensorrt", True) +env_checker_runtime = tvm.get_global_func("relax.is_tensorrt_runtime_enabled", True) -tensorrt_enabled = pytest.mark.skipif( +requires_tensorrt_codegen = pytest.mark.skipif( not has_tensorrt, reason="TENSORRT not enabled.", ) -pytestmark = [tensorrt_enabled] +requires_tensorrt_runtime = pytest.mark.skipif( + not env_checker_runtime or not env_checker_runtime(), + reason="TensorRT runtime not available", +) + +pytestmark = [ + requires_tensorrt_codegen, + requires_tensorrt_runtime, +] + tvm.testing.requires_cuda.marks() def build_and_run(mod, inputs_np, target, legalize=False): diff --git a/tests/python/relax/test_contrib_vllm.py b/tests/python/relax/test_contrib_vllm.py index dd2149e572cf..f3c4839133e3 100644 --- a/tests/python/relax/test_contrib_vllm.py +++ b/tests/python/relax/test_contrib_vllm.py @@ -32,7 +32,7 @@ reason="VLLM not enabled.", ) -pytestmark = [vllm_enabled] +pytestmark = [vllm_enabled] + tvm.testing.requires_cuda.marks() def build_and_run(mod, inputs_np, target, legalize=True): diff --git a/tests/python/relax/test_transform_codegen_pass.py b/tests/python/relax/test_transform_codegen_pass.py index 560bd3bc0b53..fd0065eeafa4 100644 --- a/tests/python/relax/test_transform_codegen_pass.py +++ b/tests/python/relax/test_transform_codegen_pass.py @@ -30,17 +30,17 @@ env_checker_codegen = tvm.get_global_func("relax.ext.tensorrt", True) env_checker_runtime = tvm.get_global_func("relax.is_tensorrt_runtime_enabled", True) -has_tensorrt_codegen = pytest.mark.skipif( +requires_tensorrt_codegen = pytest.mark.skipif( not env_checker_codegen, reason="TensorRT codegen not available", ) -has_tensorrt_runtime = pytest.mark.skipif( +requires_tensorrt_runtime = pytest.mark.skipif( not env_checker_runtime or not env_checker_runtime(), reason="TensorRT runtime not available", ) # Global variable in pytest that applies markers to all tests. -pytestmark = [has_tensorrt_codegen, has_tensorrt_runtime] +pytestmark = [requires_tensorrt_codegen] + tvm.testing.requires_cuda.marks() # Target gpu target_str = "nvidia/nvidia-t4" @@ -117,6 +117,7 @@ def setup_test(): @tvm.testing.requires_gpu +@requires_tensorrt_runtime def test_tensorrt_only(entry_func_name): mod, inputs, expected = setup_test() @@ -146,6 +147,7 @@ def test_tensorrt_only(entry_func_name): @tvm.testing.requires_gpu +@requires_tensorrt_runtime def test_mix_use_tensorrt_and_tvm(): mod, inputs, expected = setup_test() From 3629e232b284c353f59da3ea746ef9650f43a773 Mon Sep 17 00:00:00 2001 From: Alexander Peskov Date: Fri, 19 Apr 2024 09:10:25 +0000 Subject: [PATCH 2/5] fix Signed-off-by: Alexander Peskov --- tests/python/relax/test_codegen_cublas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/relax/test_codegen_cublas.py b/tests/python/relax/test_codegen_cublas.py index ed35a652f680..075f6180e06b 100644 --- a/tests/python/relax/test_codegen_cublas.py +++ b/tests/python/relax/test_codegen_cublas.py @@ -36,7 +36,7 @@ def reset_seed(): np.random.seed(0) -# pytestmark = tvm.testing.requires_cublas.marks() +pytestmark = tvm.testing.requires_cublas.marks() def build_and_run(mod, inputs_np, target, legalize=False, cuda_graph=False): From 580ee72c6b68283f491381ebcf42c16167a8b1a4 Mon Sep 17 00:00:00 2001 From: Alexander Peskov Date: Fri, 19 Apr 2024 14:58:15 +0000 Subject: [PATCH 3/5] Check fp8 compute capability Signed-off-by: Alexander Peskov --- tests/python/relax/test_codegen_cublas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/relax/test_codegen_cublas.py b/tests/python/relax/test_codegen_cublas.py index 075f6180e06b..7230c9a144a2 100644 --- a/tests/python/relax/test_codegen_cublas.py +++ b/tests/python/relax/test_codegen_cublas.py @@ -223,7 +223,7 @@ def test_matmul_igemm_offload( tvm.testing.assert_allclose(out, ref, rtol=1e-2, atol=1e-2) - +@tvm.testing.requires_cuda_compute_version(9) @pytest.mark.skipif(ml_dtypes is None, reason="requires ml_dtypes to be installed") @pytest.mark.parametrize( "x_shape, y_shape, transpose_y, out_dtype", From f8fb3121ad9e790ef8191bf6eff78e61323e9a17 Mon Sep 17 00:00:00 2001 From: Alexander Peskov Date: Fri, 19 Apr 2024 15:09:31 +0000 Subject: [PATCH 4/5] fix func signature Signed-off-by: Alexander Peskov --- tests/python/relax/test_transform_codegen_pass.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/relax/test_transform_codegen_pass.py b/tests/python/relax/test_transform_codegen_pass.py index fd0065eeafa4..6e78a67fd085 100644 --- a/tests/python/relax/test_transform_codegen_pass.py +++ b/tests/python/relax/test_transform_codegen_pass.py @@ -369,7 +369,7 @@ def test_no_op_for_call_to_tir(): @tvm.script.ir_module class Before: @R.function - def main(x: R.Tensor): + def main(x: R.Tensor([4], "int64")): R.func_attr({"relax.force_pure": True}) _ = Before.shape_func(x) return x From f13c87908e9a7067726cd932fb51701df2e6c90c Mon Sep 17 00:00:00 2001 From: Alexander Peskov Date: Fri, 19 Apr 2024 23:23:39 +0000 Subject: [PATCH 5/5] lint Signed-off-by: Alexander Peskov --- tests/python/relax/test_codegen_cublas.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/python/relax/test_codegen_cublas.py b/tests/python/relax/test_codegen_cublas.py index 7230c9a144a2..ea0861467faa 100644 --- a/tests/python/relax/test_codegen_cublas.py +++ b/tests/python/relax/test_codegen_cublas.py @@ -223,6 +223,7 @@ def test_matmul_igemm_offload( tvm.testing.assert_allclose(out, ref, rtol=1e-2, atol=1e-2) + @tvm.testing.requires_cuda_compute_version(9) @pytest.mark.skipif(ml_dtypes is None, reason="requires ml_dtypes to be installed") @pytest.mark.parametrize(