[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:
co-authored by
Andreas Karatzas
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent
e6b2a8ad5e
commit
c5b7c069a4
@@ -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
|
||||
|
||||
@@ -30,6 +30,7 @@ from contextlib import suppress
|
||||
from typing import Any, Literal, cast
|
||||
|
||||
from vllm.logger import init_logger
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.triton_utils.importing import HAS_TRITON
|
||||
|
||||
logger = init_logger(__name__)
|
||||
@@ -74,7 +75,12 @@ def activate(*, mode: JitMonitorMode = "warn", verbose: bool = False) -> None:
|
||||
_setup_triton_autotuning_print()
|
||||
_setup_triton_jit_hook()
|
||||
_setup_cutedsl_jit_hook()
|
||||
_setup_tilelang_jit_hook()
|
||||
|
||||
# Refer to #51159. tilelang ships broken symbols
|
||||
# on rocm.
|
||||
# TODO: Remove the guard once tilelang upstream is fixed.
|
||||
if not current_platform.is_rocm():
|
||||
_setup_tilelang_jit_hook()
|
||||
|
||||
logger.info(
|
||||
"Kernel JIT monitor activated; monitored JIT compilations during "
|
||||
|
||||
Reference in New Issue
Block a user