Skip to content

Commit 577ac6b

Browse files
[Fixbug] Fix soc_version for 310p
Signed-off-by: hfadzxy <starmoon_zhang@163.com>
1 parent 7e818e9 commit 577ac6b

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

vllm_ascend/__init__.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
# This file is a part of the vllm-ascend project.
1616
#
1717

18+
import logging
19+
20+
logger = logging.getLogger(__name__)
21+
1822
# Supported SOC_VERSION codes
1923
ASCEND_A2_SOC_VERSION = range(220, 226)
2024
ASCEND_A3_SOC_VERSION = range(250, 256)
@@ -28,20 +32,31 @@ def register():
2832

2933

3034
def register_model():
31-
import torch_npu # type: ignore
32-
33-
from vllm_ascend import _build_info # type: ignore
34-
raw = torch_npu.npu.get_soc_version()
35-
soc_version = (
36-
"ASCEND910B1" if raw in ASCEND_A2_SOC_VERSION else
37-
"ASCEND910_9392" if raw in ASCEND_A3_SOC_VERSION else
38-
"ASCEND310P3" if raw in ASCEND_310P_SOC_VERSION else "UNDEFINED")
39-
if soc_version == "UNDEFINED":
40-
raise RuntimeError("Unsupported or undefined Ascend SOC version.")
41-
elif soc_version != _build_info.__soc_version__:
42-
raise RuntimeError(
43-
f"Built for SOC version {_build_info.__soc_version__}, but need running on default {soc_version}. Please reinstall vllm-ascend with the default SOC_VERSION."
35+
try:
36+
import torch_npu # type: ignore
37+
38+
from vllm_ascend import _build_info # type: ignore
39+
40+
if torch_npu.npu.is_available():
41+
raw = torch_npu.npu.get_soc_version()
42+
soc_version = ("ASCEND910B1" if raw in ASCEND_A2_SOC_VERSION else
43+
"ASCEND910_9392"
44+
if raw in ASCEND_A3_SOC_VERSION else "ASCEND310P3"
45+
if raw in ASCEND_310P_SOC_VERSION else "UNDEFINED")
46+
if soc_version == "UNDEFINED":
47+
raise RuntimeError(
48+
"Unsupported or undefined Ascend SOC version.")
49+
elif soc_version != _build_info.__soc_version__:
50+
raise RuntimeError(
51+
f"Built for SOC version {_build_info.__soc_version__}, "
52+
f"but need running on default {soc_version}. "
53+
"Please reinstall vllm-ascend with the default SOC_VERSION."
54+
)
55+
56+
except Exception as e:
57+
logger.warning(
58+
f"SOC version check failed: {e}. Proceeding with model registration."
4459
)
45-
else:
46-
from .models import register_model
47-
register_model()
60+
61+
from .models import register_model
62+
register_model()

0 commit comments

Comments
 (0)