This is an automated email from the ASF dual-hosted git repository.
tlopex pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new def37e30bd [Tests] Skip test modules cleanly when optional deps are
missing (#19704)
def37e30bd is described below
commit def37e30bd4785114ce3ffa6e059da1c36bf2656
Author: Shushi Hong <[email protected]>
AuthorDate: Wed Jun 10 01:20:50 2026 -0400
[Tests] Skip test modules cleanly when optional deps are missing (#19704)
Validating the apache-tvm wheel in a minimal environment (no torch,
scipy, cloudpickle, or tornado installed) produced 33 pytest collection
errors from module-level imports of optional packages. Add
pytest.importorskip guards so these modules are reported as skipped
instead of erroring during collection.
Indirect import chains guarded:
- tvm.topi.testing imports scipy
- tvm.s_tir.meta_schedule.testing.local_rpc (tvm.rpc.tracker) requires
tornado
- tvm.s_tir.dlight.benchmark imports cloudpickle
Also remove a stray pre-license-header `import pytest` in
test_runtime_builtin_paged_attention_kv_cache_flashinfer.py.
---
pyproject.toml | 3 +++
python/tvm/contrib/hexagon/pytest_plugin.py | 11 ++++++++---
python/tvm/contrib/hexagon/session.py | 2 +-
tests/python/codegen/test_target_codegen_blob.py | 3 +++
tests/python/contrib/test_android/test_meta_schedule.py | 2 ++
tests/python/contrib/test_cblas.py | 2 ++
tests/python/contrib/test_hexagon/conftest.py | 12 +++++++-----
.../python/contrib/test_hexagon/test_benchmark_maxpool2d.py | 2 ++
tests/python/contrib/test_hexagon/test_meta_schedule.py | 2 ++
tests/python/contrib/test_hexagon/test_relax_integration.py | 2 ++
tests/python/contrib/test_hexagon/test_take.py | 4 ++++
tests/python/nightly/test_nnapi/test_network.py | 5 ++++-
tests/python/relax/backend/adreno/test_texture_network.py | 5 ++++-
.../relax/nvshmem/test_runtime_builtin_kv_cache_transfer.py | 3 +++
tests/python/relax/test_codegen_cublas.py | 3 +++
tests/python/relax/test_codegen_cudnn.py | 3 +++
tests/python/relax/test_codegen_cutlass.py | 3 +++
tests/python/relax/test_codegen_hipblas.py | 3 +++
tests/python/relax/test_e2e_op_dynamic.py | 3 +++
tests/python/relax/test_frontend_from_exported_program.py | 5 ++++-
tests/python/relax/test_frontend_from_fx.py | 3 ++-
tests/python/relax/test_frontend_onnx.py | 6 +++++-
tests/python/relax/test_frontend_onnx_backend.py | 4 ++++
tests/python/relax/test_meta_schedule_relax_integration.py | 2 ++
tests/python/relax/test_op_image.py | 3 +++
tests/python/relax/test_op_vision.py | 3 +++
.../test_runtime_builtin_paged_attention_kv_cache_cpu.py | 3 +++
...st_runtime_builtin_paged_attention_kv_cache_flashinfer.py | 3 +--
tests/python/relax/test_transform_bundle_model_params.py | 4 ++++
tests/python/relax/test_transform_lift_transform_params.py | 3 +++
tests/python/relax/test_vm_build.py | 7 +++++++
tests/python/runtime/test_runtime_module_load.py | 4 ++++
tests/python/runtime/test_runtime_rpc.py | 2 ++
tests/python/s_tir/dlight/test_benchmark.py | 2 ++
.../python/s_tir/meta_schedule/test_meta_schedule_builder.py | 1 +
.../s_tir/meta_schedule/test_meta_schedule_cost_model.py | 11 +++++++++++
.../python/s_tir/meta_schedule/test_meta_schedule_runner.py | 2 ++
.../s_tir/meta_schedule/test_meta_schedule_tune_tir.py | 2 ++
tests/python/support/test_popen_pool.py | 2 ++
tests/python/tirx-base/test_tir_intrin.py | 6 +++++-
tests/python/tirx/test_bench_utils.py | 2 ++
.../{test_expr_functor.py => test_tirx_expr_functor.py} | 0
42 files changed, 136 insertions(+), 17 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index cb3a3189d8..d38b41670d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -53,6 +53,7 @@ dependencies = [
]
[project.optional-dependencies]
+torch = ["torch"]
importer-onnx = ["onnx", "onnxoptimizer", "onnxruntime"]
importer-pytorch = ["torch", "torchvision"]
importer-tflite = ["tflite"]
@@ -67,6 +68,7 @@ Repository = "https://github.com/apache/tvm"
"Bug Tracker" = "https://github.com/apache/tvm/issues"
[dependency-groups]
+torch = ["torch"]
test = [
"pytest",
"pytest-xdist",
@@ -76,6 +78,7 @@ test = [
"pytest-timeout",
"pytest-rerunfailures",
"pytest-repeat",
+ { include-group = "torch" },
]
lint = ["ruff", "pre-commit"]
dev = [{ include-group = "test" }, { include-group = "lint" }]
diff --git a/python/tvm/contrib/hexagon/pytest_plugin.py
b/python/tvm/contrib/hexagon/pytest_plugin.py
index 41a93d5ed2..4419ed4494 100644
--- a/python/tvm/contrib/hexagon/pytest_plugin.py
+++ b/python/tvm/contrib/hexagon/pytest_plugin.py
@@ -25,7 +25,8 @@ import random
import pytest
import tvm
-import tvm.rpc.tracker
+import tvm.rpc
+import tvm.testing
from tvm.contrib.hexagon.build import HexagonLauncher, HexagonLauncherRPC
from tvm.contrib.hexagon.session import Session
from tvm.contrib.hexagon.tools import HEXAGON_SIMULATOR_NAME
@@ -138,8 +139,12 @@ def _tracker_info() -> str | int:
else:
# No tracker is provided to the tests, so we should start one
- # for the tests to use.
- tracker = tvm.rpc.tracker.Tracker("127.0.0.1", get_free_port())
+ # for the tests to use. Import tvm.rpc.tracker lazily since it
+ # requires the optional tornado package.
+ pytest.importorskip("tornado", reason="tvm.rpc.tracker requires
tornado")
+ from tvm.rpc.tracker import Tracker
+
+ tracker = Tracker("127.0.0.1", get_free_port())
try:
yield (tracker.host, tracker.port)
finally:
diff --git a/python/tvm/contrib/hexagon/session.py
b/python/tvm/contrib/hexagon/session.py
index 9f9d7d746c..8bdaf33da0 100644
--- a/python/tvm/contrib/hexagon/session.py
+++ b/python/tvm/contrib/hexagon/session.py
@@ -202,7 +202,7 @@ class Session:
return
self._rpc.get_function("tvm.hexagon.load_module")(str(remote_file_path))
def get_executor_from_factory(
- self, module: runtime.executable | str, hexagon_arch: str = "v68"
+ self, module: runtime.Executable | str, hexagon_arch: str = "v68"
):
"""Create a local GraphModule which consumes a remote libmod.
diff --git a/tests/python/codegen/test_target_codegen_blob.py
b/tests/python/codegen/test_target_codegen_blob.py
index 8b4104fa10..f481142e19 100644
--- a/tests/python/codegen/test_target_codegen_blob.py
+++ b/tests/python/codegen/test_target_codegen_blob.py
@@ -19,6 +19,7 @@
import ctypes
import numpy as np
+import pytest
import tvm
import tvm.testing
@@ -29,6 +30,8 @@ from tvm.support import cc, popen_pool, tar, utils
@tvm.testing.uses_gpu
def test_cuda_multi_lib():
+ pytest.importorskip("cloudpickle")
+
# test combining two system lib together
# each contains a fatbin component in cuda
dev = tvm.cuda(0)
diff --git a/tests/python/contrib/test_android/test_meta_schedule.py
b/tests/python/contrib/test_android/test_meta_schedule.py
index 9ce37cee21..63d7ef9bc8 100644
--- a/tests/python/contrib/test_android/test_meta_schedule.py
+++ b/tests/python/contrib/test_android/test_meta_schedule.py
@@ -23,6 +23,8 @@ import tempfile
import numpy as np
import pytest
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.testing
import tvm.topi.testing
from tvm.s_tir import meta_schedule as ms
diff --git a/tests/python/contrib/test_cblas.py
b/tests/python/contrib/test_cblas.py
index 4431742cbd..2f07d9405c 100644
--- a/tests/python/contrib/test_cblas.py
+++ b/tests/python/contrib/test_cblas.py
@@ -19,6 +19,8 @@
import numpy as np
import pytest
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm
import tvm.testing
import tvm.topi.testing
diff --git a/tests/python/contrib/test_hexagon/conftest.py
b/tests/python/contrib/test_hexagon/conftest.py
index a159a7d05b..f187cc1c39 100644
--- a/tests/python/contrib/test_hexagon/conftest.py
+++ b/tests/python/contrib/test_hexagon/conftest.py
@@ -18,8 +18,10 @@
"""Hexagon testing fixtures used to deduce testing argument
values from testing parameters"""
-# Disabling invalid-name check as the name is expected to be exactly this by
pytest
-# pylint: disable=invalid-name
-pytest_plugins = [
- "tvm.contrib.hexagon.pytest_plugin",
-]
+# pytest 9 no longer supports declaring ``pytest_plugins`` in a
+# non-rootdir conftest, so re-export the plugin's hooks and fixtures
+# here instead. The explicit import covers the underscore-prefixed
+# fixture that the wildcard import skips.
+# ruff: noqa: F401, F403
+from tvm.contrib.hexagon.pytest_plugin import *
+from tvm.contrib.hexagon.pytest_plugin import _tracker_info
diff --git a/tests/python/contrib/test_hexagon/test_benchmark_maxpool2d.py
b/tests/python/contrib/test_hexagon/test_benchmark_maxpool2d.py
index 475b624bd5..5431c0ae69 100644
--- a/tests/python/contrib/test_hexagon/test_benchmark_maxpool2d.py
+++ b/tests/python/contrib/test_hexagon/test_benchmark_maxpool2d.py
@@ -49,6 +49,8 @@ import os
import numpy as np
import pytest
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.testing
from tvm import te, tirx, topi
from tvm.contrib.hexagon import allocate_hexagon_array
diff --git a/tests/python/contrib/test_hexagon/test_meta_schedule.py
b/tests/python/contrib/test_hexagon/test_meta_schedule.py
index 4a3ecc8141..0d0c01bcb6 100644
--- a/tests/python/contrib/test_hexagon/test_meta_schedule.py
+++ b/tests/python/contrib/test_hexagon/test_meta_schedule.py
@@ -22,6 +22,8 @@ import tempfile
import numpy as np
import pytest
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.testing
import tvm.topi.testing
from tvm import te
diff --git a/tests/python/contrib/test_hexagon/test_relax_integration.py
b/tests/python/contrib/test_hexagon/test_relax_integration.py
index 806ba58c59..40421abd3b 100644
--- a/tests/python/contrib/test_hexagon/test_relax_integration.py
+++ b/tests/python/contrib/test_hexagon/test_relax_integration.py
@@ -20,6 +20,8 @@
import numpy as np
import pytest
+pytest.importorskip("onnx") # tvm.relax.frontend.onnx imports onnx
+
import tvm.testing
from tvm import relax, runtime
from tvm.contrib.hexagon.session import Session
diff --git a/tests/python/contrib/test_hexagon/test_take.py
b/tests/python/contrib/test_hexagon/test_take.py
index 4d54c89ce7..8acbf53126 100644
--- a/tests/python/contrib/test_hexagon/test_take.py
+++ b/tests/python/contrib/test_hexagon/test_take.py
@@ -16,7 +16,11 @@
# under the License.
# pylint: disable=missing-docstring, invalid-name, unused-argument,
not-callable
import numpy as np
+import pytest
import tvm_ffi
+
+pytest.importorskip("scipy")
+
from scipy import special
import tvm
diff --git a/tests/python/nightly/test_nnapi/test_network.py
b/tests/python/nightly/test_nnapi/test_network.py
index dcee4e161b..bbfc01067f 100644
--- a/tests/python/nightly/test_nnapi/test_network.py
+++ b/tests/python/nightly/test_nnapi/test_network.py
@@ -17,9 +17,12 @@
"""NNAPI network tests."""
import numpy as np
-import onnx
import pytest
+pytest.importorskip("onnx")
+
+import onnx
+
import tvm
from test_nnapi.conftest import remote
from test_nnapi.infrastructure import build_and_run # , build_and_run_vm
diff --git a/tests/python/relax/backend/adreno/test_texture_network.py
b/tests/python/relax/backend/adreno/test_texture_network.py
index 7690629b57..4af6e01b9b 100644
--- a/tests/python/relax/backend/adreno/test_texture_network.py
+++ b/tests/python/relax/backend/adreno/test_texture_network.py
@@ -20,8 +20,11 @@ import copy
import json
import numpy as np
-import onnx
import pytest
+
+pytest.importorskip("onnx")
+
+import onnx
from utils import verify_results
import tvm
diff --git
a/tests/python/relax/nvshmem/test_runtime_builtin_kv_cache_transfer.py
b/tests/python/relax/nvshmem/test_runtime_builtin_kv_cache_transfer.py
index 473e10753f..dbece4f48e 100644
--- a/tests/python/relax/nvshmem/test_runtime_builtin_kv_cache_transfer.py
+++ b/tests/python/relax/nvshmem/test_runtime_builtin_kv_cache_transfer.py
@@ -21,6 +21,9 @@ from typing import Optional, Union
import numpy as np
import pytest
+
+pytest.importorskip("scipy")
+
import scipy.special
import torch
import tvm_ffi
diff --git a/tests/python/relax/test_codegen_cublas.py
b/tests/python/relax/test_codegen_cublas.py
index 4cd9d4a029..76e7024829 100644
--- a/tests/python/relax/test_codegen_cublas.py
+++ b/tests/python/relax/test_codegen_cublas.py
@@ -20,6 +20,9 @@ import pytest
import tvm
import tvm.testing
+
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.topi.testing
from tvm import relax
from tvm.relax.backend.cuda.cublas import partition_for_cublas
diff --git a/tests/python/relax/test_codegen_cudnn.py
b/tests/python/relax/test_codegen_cudnn.py
index e5c28a76e9..bd8749dc6b 100644
--- a/tests/python/relax/test_codegen_cudnn.py
+++ b/tests/python/relax/test_codegen_cudnn.py
@@ -20,6 +20,9 @@ import pytest
import tvm
import tvm.testing
+
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.topi.testing
from tvm import relax
from tvm.contrib.pickle_memoize import memoize
diff --git a/tests/python/relax/test_codegen_cutlass.py
b/tests/python/relax/test_codegen_cutlass.py
index 9922248890..af4f0805e3 100644
--- a/tests/python/relax/test_codegen_cutlass.py
+++ b/tests/python/relax/test_codegen_cutlass.py
@@ -20,6 +20,9 @@ import pytest
import tvm
import tvm.testing
+
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.topi.testing
from tvm import relax
from tvm.contrib.cutlass.build import is_shape_valid_for_cutlass_matmul
diff --git a/tests/python/relax/test_codegen_hipblas.py
b/tests/python/relax/test_codegen_hipblas.py
index c6dd7222be..1567009946 100644
--- a/tests/python/relax/test_codegen_hipblas.py
+++ b/tests/python/relax/test_codegen_hipblas.py
@@ -19,6 +19,9 @@ import pytest
import tvm
import tvm.testing
+
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.topi.testing
from tvm import relax
from tvm.relax.backend.rocm.hipblas import partition_for_hipblas
diff --git a/tests/python/relax/test_e2e_op_dynamic.py
b/tests/python/relax/test_e2e_op_dynamic.py
index e728ce355c..25ebbea2c2 100644
--- a/tests/python/relax/test_e2e_op_dynamic.py
+++ b/tests/python/relax/test_e2e_op_dynamic.py
@@ -20,6 +20,9 @@ import pytest
import tvm
import tvm.testing
+
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.topi.testing
from tvm import relax
from tvm.relax.transform import LegalizeOps
diff --git a/tests/python/relax/test_frontend_from_exported_program.py
b/tests/python/relax/test_frontend_from_exported_program.py
index fa2d793f29..a7848b3d2d 100644
--- a/tests/python/relax/test_frontend_from_exported_program.py
+++ b/tests/python/relax/test_frontend_from_exported_program.py
@@ -20,7 +20,6 @@ import operator
import numpy as np
import pytest
import torch
-import torchvision
from torch import nn
from torch.export import export
from torch.nn import Module
@@ -9017,6 +9016,8 @@ def test_grid_sample():
def test_torchvision_roi_align():
+ torchvision = pytest.importorskip("torchvision")
+
class ROIAlign(Module):
def forward(self, input, rois):
return torchvision.ops.roi_align(
@@ -9057,6 +9058,8 @@ def test_torchvision_roi_align():
def test_torchvision_roi_align_aligned():
+ torchvision = pytest.importorskip("torchvision")
+
class ROIAlign(Module):
def forward(self, input, rois):
return torchvision.ops.roi_align(
diff --git a/tests/python/relax/test_frontend_from_fx.py
b/tests/python/relax/test_frontend_from_fx.py
index 94cdf43773..a5f799e6d6 100644
--- a/tests/python/relax/test_frontend_from_fx.py
+++ b/tests/python/relax/test_frontend_from_fx.py
@@ -22,7 +22,6 @@ import operator
import pytest
import torch
import torch.nn.functional as F
-import torchvision
from torch import fx
from torch.nn import Module
@@ -1821,6 +1820,8 @@ def test_embedding():
def test_stochastic_depth():
+ torchvision = pytest.importorskip("torchvision")
+
input_info = [([1, 3, 10, 10], "float32")]
class StochasticDepth1(Module):
diff --git a/tests/python/relax/test_frontend_onnx.py
b/tests/python/relax/test_frontend_onnx.py
index 471186589e..8d8c1bc54b 100644
--- a/tests/python/relax/test_frontend_onnx.py
+++ b/tests/python/relax/test_frontend_onnx.py
@@ -25,9 +25,13 @@ This file is a test script to test Relax ONNX frontend
coverage.
from typing import Literal
import numpy as np
+import pytest
+
+pytest.importorskip("onnx")
+pytest.importorskip("onnxruntime")
+
import onnx
import onnxruntime
-import pytest
import tvm_ffi
from onnx import ModelProto, TensorProto, helper, numpy_helper
diff --git a/tests/python/relax/test_frontend_onnx_backend.py
b/tests/python/relax/test_frontend_onnx_backend.py
index ad3d490df7..9f9ec8779c 100644
--- a/tests/python/relax/test_frontend_onnx_backend.py
+++ b/tests/python/relax/test_frontend_onnx_backend.py
@@ -30,6 +30,10 @@ semantic verification.
"""
import numpy as np
+import pytest
+
+pytest.importorskip("onnx")
+
import onnx
import onnx.backend.test
from onnx.backend.base import Backend, BackendRep
diff --git a/tests/python/relax/test_meta_schedule_relax_integration.py
b/tests/python/relax/test_meta_schedule_relax_integration.py
index 13d4496fb1..e2d80f7f49 100644
--- a/tests/python/relax/test_meta_schedule_relax_integration.py
+++ b/tests/python/relax/test_meta_schedule_relax_integration.py
@@ -89,6 +89,8 @@ def test_compile_relax_with_database():
same keys (by running LegalizeOps + FuseOps + FuseTIR before applying the
database), so the scheduled kernels are actually picked up.
"""
+ pytest.importorskip("cloudpickle") # needed by meta_schedule popen workers
+
target = tvm.target.Target({"kind": "llvm", "num-cores": 1})
# Prepare the fused module whose TIR keys will populate the database.
diff --git a/tests/python/relax/test_op_image.py
b/tests/python/relax/test_op_image.py
index 3009b9414a..870d48a229 100644
--- a/tests/python/relax/test_op_image.py
+++ b/tests/python/relax/test_op_image.py
@@ -19,6 +19,9 @@ import pytest
import tvm
import tvm.testing
+
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.topi.testing
from tvm import TVMError, relax, tirx
from tvm.ir import Op, VDevice
diff --git a/tests/python/relax/test_op_vision.py
b/tests/python/relax/test_op_vision.py
index 167ccdf45a..fb6f3bc1d1 100644
--- a/tests/python/relax/test_op_vision.py
+++ b/tests/python/relax/test_op_vision.py
@@ -20,6 +20,9 @@ import pytest
import tvm
import tvm.testing
+
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.topi.testing
from tvm import TVMError, relax, tirx
from tvm.ir import Op
diff --git
a/tests/python/relax/test_runtime_builtin_paged_attention_kv_cache_cpu.py
b/tests/python/relax/test_runtime_builtin_paged_attention_kv_cache_cpu.py
index c4d99afeea..57f4061d96 100644
--- a/tests/python/relax/test_runtime_builtin_paged_attention_kv_cache_cpu.py
+++ b/tests/python/relax/test_runtime_builtin_paged_attention_kv_cache_cpu.py
@@ -20,6 +20,9 @@ import itertools
import numpy as np
import pytest
+
+pytest.importorskip("scipy")
+
import scipy.special
import tvm_ffi
from tvm_ffi import Shape
diff --git
a/tests/python/relax/test_runtime_builtin_paged_attention_kv_cache_flashinfer.py
b/tests/python/relax/test_runtime_builtin_paged_attention_kv_cache_flashinfer.py
index d5ad9619ce..3a4454e7c9 100644
---
a/tests/python/relax/test_runtime_builtin_paged_attention_kv_cache_flashinfer.py
+++
b/tests/python/relax/test_runtime_builtin_paged_attention_kv_cache_flashinfer.py
@@ -1,5 +1,3 @@
-import pytest
-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -17,6 +15,7 @@ import pytest
# specific language governing permissions and limitations
# under the License.
# ruff: noqa: E741
+import pytest
import torch
import tvm_ffi
from tvm_ffi import Shape
diff --git a/tests/python/relax/test_transform_bundle_model_params.py
b/tests/python/relax/test_transform_bundle_model_params.py
index 1fa9ecff56..f57e0941cd 100644
--- a/tests/python/relax/test_transform_bundle_model_params.py
+++ b/tests/python/relax/test_transform_bundle_model_params.py
@@ -16,6 +16,10 @@
# under the License.
# ruff: noqa: F401
+import pytest
+
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm
import tvm.testing
import tvm.topi.testing
diff --git a/tests/python/relax/test_transform_lift_transform_params.py
b/tests/python/relax/test_transform_lift_transform_params.py
index 8de008f002..199cf9ab27 100644
--- a/tests/python/relax/test_transform_lift_transform_params.py
+++ b/tests/python/relax/test_transform_lift_transform_params.py
@@ -21,6 +21,9 @@ import pytest
import tvm
import tvm.testing
+
+pytest.importorskip("scipy") # tvm.topi.testing imports scipy
+
import tvm.topi.testing
from tvm import relax
from tvm.script import ir as I
diff --git a/tests/python/relax/test_vm_build.py
b/tests/python/relax/test_vm_build.py
index 7c445911ff..e591eb6fd3 100644
--- a/tests/python/relax/test_vm_build.py
+++ b/tests/python/relax/test_vm_build.py
@@ -987,6 +987,8 @@ class TestVMSetInput:
def test_multi_systemlib(exec_mode):
+ pytest.importorskip("cloudpickle") # needed by popen_pool.PopenWorker
+
@tvm.script.ir_module
class ModA:
I.module_attrs({"system_lib_prefix": "libA_"})
@@ -1192,6 +1194,7 @@ def test_save_function_kwargs(exec_mode):
def test_save_function_kwargs_rpc(exec_mode):
+ pytest.importorskip("cloudpickle") # needed by the popen RPC server
run_on_rpc(TestVMSetInput, save_function_kwargs_trial, exec_mode)
@@ -1211,6 +1214,7 @@ def test_save_function_time_evaluator(exec_mode):
def test_save_function_time_evaluator_rpc(exec_mode):
+ pytest.importorskip("cloudpickle") # needed by the popen RPC server
run_on_rpc(TestVMSetInput, save_function_time_evaluator_trial, exec_mode)
@@ -1225,6 +1229,7 @@ def test_set_input_stateless_failure(exec_mode):
def test_set_input_stateless_failure_rpc(exec_mode):
+ pytest.importorskip("cloudpickle") # needed by the popen RPC server
with pytest.raises(RuntimeError):
run_on_rpc(TestVMSetInput, set_input_attempt_stateless, exec_mode)
@@ -1237,6 +1242,7 @@ def test_set_input_invoke_failure(exec_mode):
def test_set_input_invoke_failure_rpc(exec_mode):
+ pytest.importorskip("cloudpickle") # needed by the popen RPC server
with pytest.raises(RuntimeError):
run_on_rpc(TestVMSetInput, set_input_attempt_invoke, exec_mode)
@@ -1249,6 +1255,7 @@ def test_set_input_get_failure(exec_mode):
def test_set_input_get_failure_rpc(exec_mode):
+ pytest.importorskip("cloudpickle") # needed by the popen RPC server
with pytest.raises(RuntimeError):
run_on_rpc(TestVMSetInput, set_input_attempt_get, exec_mode)
diff --git a/tests/python/runtime/test_runtime_module_load.py
b/tests/python/runtime/test_runtime_module_load.py
index 3983717e6e..6a1eaa8e7e 100644
--- a/tests/python/runtime/test_runtime_module_load.py
+++ b/tests/python/runtime/test_runtime_module_load.py
@@ -98,6 +98,8 @@ def test_dso_module_load(target):
@tvm.testing.requires_gpu
def test_device_module_dump():
+ pytest.importorskip("cloudpickle") # needed by popen_pool.PopenWorker
+
# graph
n = tvm.runtime.convert(1024)
A = te.placeholder((n,), name="A")
@@ -155,6 +157,8 @@ def test_device_module_dump():
@tvm.testing.requires_llvm
def test_combine_module_llvm():
"""Test combine multiple module into one shared lib."""
+ pytest.importorskip("cloudpickle") # needed by popen_pool.PopenWorker
+
# graph
nn = 12
n = tvm.runtime.convert(nn)
diff --git a/tests/python/runtime/test_runtime_rpc.py
b/tests/python/runtime/test_runtime_rpc.py
index 5dbcddea89..2db325b135 100644
--- a/tests/python/runtime/test_runtime_rpc.py
+++ b/tests/python/runtime/test_runtime_rpc.py
@@ -28,6 +28,8 @@ import numpy as np
import pytest
import tvm_ffi
+pytest.importorskip("tornado") # tvm.rpc.proxy and tvm.rpc.tracker require
tornado
+
import tvm
import tvm.testing
from tvm import rpc, te
diff --git a/tests/python/s_tir/dlight/test_benchmark.py
b/tests/python/s_tir/dlight/test_benchmark.py
index 7a83bd47e9..32ff973359 100644
--- a/tests/python/s_tir/dlight/test_benchmark.py
+++ b/tests/python/s_tir/dlight/test_benchmark.py
@@ -21,6 +21,8 @@ import tempfile
import pytest
+pytest.importorskip("cloudpickle") # tvm.s_tir.dlight.benchmark imports
cloudpickle
+
import tvm.testing
from tvm.s_tir import meta_schedule as ms
from tvm.s_tir.dlight.benchmark import (
diff --git a/tests/python/s_tir/meta_schedule/test_meta_schedule_builder.py
b/tests/python/s_tir/meta_schedule/test_meta_schedule_builder.py
index abdaf6d39e..516f836de9 100644
--- a/tests/python/s_tir/meta_schedule/test_meta_schedule_builder.py
+++ b/tests/python/s_tir/meta_schedule/test_meta_schedule_builder.py
@@ -225,6 +225,7 @@ def test_meta_schedule_error_handle_time_out():
def test_meta_schedule_missing_build_func():
+ pytest.importorskip("cloudpickle")
with pytest.raises(ValueError):
LocalBuilder(f_build="wrong-name")
diff --git a/tests/python/s_tir/meta_schedule/test_meta_schedule_cost_model.py
b/tests/python/s_tir/meta_schedule/test_meta_schedule_cost_model.py
index bbcee5c462..1e209cacbc 100644
--- a/tests/python/s_tir/meta_schedule/test_meta_schedule_cost_model.py
+++ b/tests/python/s_tir/meta_schedule/test_meta_schedule_cost_model.py
@@ -21,8 +21,10 @@ import shutil
import tempfile
import unittest
from functools import partial
+from importlib.util import find_spec
import numpy as np
+import pytest
import tvm
import tvm.testing
@@ -36,6 +38,10 @@ from tvm.s_tir.meta_schedule.tune_context import TuneContext
from tvm.s_tir.schedule.schedule import Schedule
from tvm.script import tirx as T
+requires_xgboost = pytest.mark.skipif(
+ find_spec("xgboost") is None, reason="xgboost is not installed"
+)
+
# pylint:
disable=invalid-name,no-member,line-too-long,too-many-nested-blocks,missing-docstring
@tvm.script.ir_module
@@ -140,6 +146,7 @@ def _dummy_result(num_samples: int = 4, max_run_sec: int =
10):
return RunnerResult(list(np.random.rand(num_samples) * max_run_sec +
1e-6), None)
+@requires_xgboost
def test_meta_schedule_xgb_model():
extractor = RandomFeatureExtractor()
model = XGBModel(extractor=extractor, num_warmup_samples=2)
@@ -153,6 +160,7 @@ def test_meta_schedule_xgb_model():
model.predict(TuneContext(), [_dummy_candidate() for i in
range(predict_sample_count)])
+@requires_xgboost
def test_meta_schedule_xgb_model_no_feature():
model = XGBModel(num_warmup_samples=0)
tune_ctx = TuneContext(
@@ -166,6 +174,7 @@ def test_meta_schedule_xgb_model_no_feature():
model.predict(tune_ctx, [candidate])
+@requires_xgboost
def test_meta_schedule_xgb_model_reload():
extractor = RandomFeatureExtractor()
model = XGBModel(extractor=extractor, num_warmup_samples=10)
@@ -209,6 +218,7 @@ def test_meta_schedule_xgb_model_reload():
assert (f1 == f2).all()
+@requires_xgboost
def test_meta_schedule_xgb_model_reupdate():
extractor = RandomFeatureExtractor()
model = XGBModel(extractor=extractor, num_warmup_samples=2)
@@ -232,6 +242,7 @@ def test_meta_schedule_xgb_model_reupdate():
model.predict(TuneContext(), [_dummy_candidate() for i in
range(predict_sample_count)])
+@requires_xgboost
def test_meta_schedule_xgb_model_callback_as_function():
# pylint: disable=import-outside-toplevel
from itertools import chain as itertools_chain
diff --git a/tests/python/s_tir/meta_schedule/test_meta_schedule_runner.py
b/tests/python/s_tir/meta_schedule/test_meta_schedule_runner.py
index b23c603a4b..65c2909481 100644
--- a/tests/python/s_tir/meta_schedule/test_meta_schedule_runner.py
+++ b/tests/python/s_tir/meta_schedule/test_meta_schedule_runner.py
@@ -26,6 +26,8 @@ import numpy as np
import pytest
from tvm_ffi import register_global_func
+pytest.importorskip("tornado") # tvm.rpc.tracker (LocalRPC) requires tornado
+
import tvm
import tvm.testing
from tvm.ir.utils import derived_object
diff --git a/tests/python/s_tir/meta_schedule/test_meta_schedule_tune_tir.py
b/tests/python/s_tir/meta_schedule/test_meta_schedule_tune_tir.py
index 8430072223..a3bce951e2 100644
--- a/tests/python/s_tir/meta_schedule/test_meta_schedule_tune_tir.py
+++ b/tests/python/s_tir/meta_schedule/test_meta_schedule_tune_tir.py
@@ -21,6 +21,8 @@ import tempfile
import numpy as np
import pytest
+pytest.importorskip("tornado") # tvm.rpc.tracker (LocalRPC) requires tornado
+
import tvm
import tvm.testing
from tvm.ir.utils import derived_object
diff --git a/tests/python/support/test_popen_pool.py
b/tests/python/support/test_popen_pool.py
index 479af49949..d60ba22109 100644
--- a/tests/python/support/test_popen_pool.py
+++ b/tests/python/support/test_popen_pool.py
@@ -23,6 +23,8 @@ import time
import psutil
import pytest
+pytest.importorskip("cloudpickle") # PopenWorker.send requires cloudpickle
+
from tvm.support.popen_pool import PopenPoolExecutor, PopenWorker
from tvm.testing import (
identity_after,
diff --git a/tests/python/tirx-base/test_tir_intrin.py
b/tests/python/tirx-base/test_tir_intrin.py
index 4d185ac03f..c0915f61e4 100644
--- a/tests/python/tirx-base/test_tir_intrin.py
+++ b/tests/python/tirx-base/test_tir_intrin.py
@@ -14,11 +14,15 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-# ruff: noqa: E712, F401, F821
+# ruff: noqa: E712, F401
import ctypes
import math
import numpy as np
+import pytest
+
+pytest.importorskip("scipy")
+
import scipy
import tvm
diff --git a/tests/python/tirx/test_bench_utils.py
b/tests/python/tirx/test_bench_utils.py
index 75fbaccb7f..9e56d46623 100644
--- a/tests/python/tirx/test_bench_utils.py
+++ b/tests/python/tirx/test_bench_utils.py
@@ -19,6 +19,8 @@
import pytest
import torch
+pytest.importorskip("triton") # tvm.tirx.bench imports triton.profiler
+
import tvm.testing
from tvm.tirx.bench import _compute_group_count, _parse_proton_tree, bench,
tensor_bytes
diff --git a/tests/python/tirx/transform/test_expr_functor.py
b/tests/python/tirx/transform/test_tirx_expr_functor.py
similarity index 100%
rename from tests/python/tirx/transform/test_expr_functor.py
rename to tests/python/tirx/transform/test_tirx_expr_functor.py