[ROCm] Defer tilelang import through its import from vllm.tilelang_utils import tilelang and relaxed has_tilelang (#51159)

Signed-off-by: Felix Marty <Felix.Marty@amd.com>
Co-authored-by: Andreas Karatzas <akaratza@amd.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
fxmarty-amd
2026-08-13 13:12:40 -05:00
committed by GitHub
co-authored by Andreas Karatzas mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent e6b2a8ad5e
commit c5b7c069a4
8 changed files with 313 additions and 52 deletions
+22 -2
View File
@@ -412,6 +412,21 @@ def _has_module(module_name: str) -> bool:
return True
@cache
def _has_module_spec(module_name: str) -> bool:
"""Return True if *module_name* is installed, without importing it.
Unlike [`_has_module`][vllm.utils.import_utils._has_module], this only
resolves the import spec. It therefore does not pay the import cost of
heavyweight modules, at the price of not verifying that native
dependencies (shared libraries, etc.) are satisfied. The result is cached.
"""
try:
return importlib.util.find_spec(module_name) is not None
except Exception:
return False
def has_deep_ep() -> bool:
"""Whether the optional `deep_ep` package is available."""
return _has_module("deep_ep")
@@ -504,8 +519,13 @@ def has_triton_kernels() -> bool:
@cache
def has_tilelang() -> bool:
"""Whether the optional `tilelang` package is available."""
if not _has_module("tilelang"):
"""Whether the optional `tilelang` package is available.
Only the import spec is checked: importing `tilelang` is expensive, so
callers must import it lazily at their point of use rather than relying
on this function to have imported it already.
"""
if not _has_module_spec("tilelang"):
return False
# ROCm-only guard, imported lazily to avoid loading rocm on CUDA.
from vllm.platforms import current_platform