feat: Improve SOC version detection and sleep mode handling in utils.py

This commit is contained in:
2026-02-10 23:12:40 +08:00
parent 6680585975
commit c63f4439c5

View File

@@ -67,8 +67,12 @@ _IS_EAGLE_MODE = None
def is_310p():
global _IS_310P
if _IS_310P is None:
from vllm_npu import _build_info # type: ignore
_IS_310P = _build_info.__soc_version__.lower().startswith("ascend310p")
try:
soc_version = torch_npu.npu.get_soc_version()
# 310P soc_version range: 200-209
_IS_310P = 200 <= soc_version <= 209
except Exception:
_IS_310P = False
return _IS_310P
@@ -93,8 +97,13 @@ def is_enable_nz(dtype: Optional[torch.dtype] = torch.int8,
def sleep_mode_enabled():
global _SLEEP_MODE_ENABLED
if _SLEEP_MODE_ENABLED is None:
# _build_info is a C++ build artifact from vllm-ascend CMake.
# For the plugin, detect at runtime or default to False.
try:
from vllm_npu import _build_info # type: ignore
_SLEEP_MODE_ENABLED = _build_info.__sleep_mode_enabled__
except ImportError:
_SLEEP_MODE_ENABLED = False
return _SLEEP_MODE_ENABLED