Unverified Commit 3ae082c3 authored by dongbo910220's avatar dongbo910220 Committed by GitHub
Browse files

[Chore] Separate out optional dependency checks from vllm.utils (#27207)


Signed-off-by: default avatardongbo910220 <1275604947@qq.com>
Signed-off-by: default avatardongbo910220 <32610838+dongbo910220@users.noreply.github.com>
Co-authored-by: default avatarWentao Ye <44945378+yewentao256@users.noreply.github.com>
Co-authored-by: default avatarCyrus Leung <tlleungac@connect.ust.hk>
parent 49c00fe3
...@@ -324,3 +324,39 @@ class LazyLoader(ModuleType): ...@@ -324,3 +324,39 @@ class LazyLoader(ModuleType):
if self._module is None: if self._module is None:
self._module = self._load() self._module = self._load()
return dir(self._module) return dir(self._module)
# Optional dependency detection utilities
@cache
def _has_module(module_name: str) -> bool:
"""Return True if *module_name* can be found in the current environment.
The result is cached so that subsequent queries for the same module incur
no additional overhead.
"""
return importlib.util.find_spec(module_name) is not None
def has_pplx() -> bool:
"""Whether the optional `pplx_kernels` package is available."""
return _has_module("pplx_kernels")
def has_deep_ep() -> bool:
"""Whether the optional `deep_ep` package is available."""
return _has_module("deep_ep")
def has_deep_gemm() -> bool:
"""Whether the optional `deep_gemm` package is available."""
return _has_module("deep_gemm")
def has_triton_kernels() -> bool:
"""Whether the optional `triton_kernels` package is available."""
return _has_module("triton_kernels")
def has_tilelang() -> bool:
"""Whether the optional `tilelang` package is available."""
return _has_module("tilelang")
...@@ -22,7 +22,7 @@ from vllm.forward_context import ( ...@@ -22,7 +22,7 @@ from vllm.forward_context import (
from vllm.logger import init_logger from vllm.logger import init_logger
from vllm.platforms import current_platform from vllm.platforms import current_platform
from vllm.sequence import IntermediateTensors from vllm.sequence import IntermediateTensors
from vllm.utils import has_deep_gemm from vllm.utils.import_utils import has_deep_gemm
from vllm.v1.worker.ubatching import UBatchContext, make_ubatch_contexts from vllm.v1.worker.ubatching import UBatchContext, make_ubatch_contexts
logger = init_logger(__name__) logger = init_logger(__name__)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment