Skip to content

Commit 3c55969

Browse files
[Fixbug] Fix soc_version for 310p
Signed-off-by: hfadzxy <starmoon_zhang@163.com>
1 parent 2834c14 commit 3c55969

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

vllm_ascend/__init__.py

Lines changed: 33 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,33 @@ 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."
44-
)
35+
try:
36+
import torch_npu # type: ignore
37+
except ImportError:
38+
logger.warning("torch_npu not found. Proceeding with CPU testing.")
4539
else:
46-
from .models import register_model
47-
register_model()
40+
from vllm_ascend import _build_info # type: ignore
41+
ascend_soc_version = getattr(_build_info, "__ascend_soc_version__",
42+
None)
43+
raw = torch_npu.npu.get_soc_version()
44+
soc_version = (
45+
"ASCEND910B1" if raw in ASCEND_A2_SOC_VERSION else
46+
"ASCEND910_9392" if raw in ASCEND_A3_SOC_VERSION else
47+
"ASCEND310P3" if raw in ASCEND_310P_SOC_VERSION else "UNDEFINED")
48+
49+
if soc_version == "UNDEFINED":
50+
raise RuntimeError("Unsupported or undefined Ascend SOC version.")
51+
elif soc_version != _build_info.__soc_version__:
52+
raise RuntimeError(
53+
f"Built for SOC version {_build_info.__soc_version__}, "
54+
f"but running on SOC version {soc_version}. "
55+
f"Please reinstall vllm-ascend with 'export SOC_VERSION={soc_version}' ."
56+
)
57+
elif ascend_soc_version is None:
58+
raise RuntimeError(
59+
"vllm_ascend._build_info is missing '__ascend_soc_version__'. "
60+
f"Please reinstall vllm-ascend with 'export SOC_VERSION={soc_version}' ."
61+
)
62+
63+
from .models import register_model
64+
register_model()

vllm_ascend/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import math
2323
import os
2424
from contextlib import contextmanager, nullcontext
25-
from enum import Enum
2625
from threading import Lock
2726
from typing import TYPE_CHECKING, Any, List, Optional, Tuple, Union
2827

vllm_ascend/worker/model_runner_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
from vllm_ascend.spec_decode.mtp_proposer import MtpProposer
117117
from vllm_ascend.utils import (ACL_FORMAT_FRACTAL_ND, ACL_FORMAT_FRACTAL_NZ,
118118
ProfileExecuteDuration, is_310p,
119-
lmhead_tp_enable)
119+
lmhead_tp_enable, vllm_version_is)
120120
from vllm_ascend.worker.npu_input_batch import CachedRequestState, InputBatch
121121

122122
if TYPE_CHECKING:

0 commit comments

Comments
 (0)