diff --git a/vllm_npu/utils.py b/vllm_npu/utils.py index f4150e8..8ffc139 100644 --- a/vllm_npu/utils.py +++ b/vllm_npu/utils.py @@ -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: - from vllm_npu import _build_info # type: ignore - _SLEEP_MODE_ENABLED = _build_info.__sleep_mode_enabled__ + # _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