Skip to content

Commit c9b3e03

Browse files
authored
[0.7.3] Use env for soc during compilation (#606)
### What this PR does / why we need it? Sometimes SOC can not be correctly detected by npu-smi, it is better to use env, which can be set by users. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Tested by installing, compiling and UT. Signed-off-by: Shuqiao Li <celestialli@outlook.com>
1 parent d60f8d9 commit c9b3e03

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

setup.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,22 @@ def configure(self, ext: CMakeExtension) -> None:
157157
# else specify pybind11 path installed from source code on CI container
158158
raise RuntimeError(f"CMake configuration failed: {e}")
159159

160-
# try retrive soc version from npu-smi
161-
soc_command = [
162-
"bash",
163-
"-c",
164-
"npu-smi info | grep OK | awk '{print $3}' | head -n 1",
165-
]
166-
try:
167-
soc_version = subprocess.check_output(soc_command,
168-
text=True).strip()
169-
soc_version = soc_version.split("-")[0]
170-
soc_version = "Ascend" + soc_version
171-
except subprocess.CalledProcessError as e:
172-
raise RuntimeError(f"Retrive Soc version failed: {e}")
160+
if envs.SOC_VERSION is None:
161+
# try retrive soc version from npu-smi
162+
soc_command = [
163+
"bash",
164+
"-c",
165+
"npu-smi info | grep OK | awk '{print $3}' | head -n 1",
166+
]
167+
try:
168+
soc_version = subprocess.check_output(soc_command,
169+
text=True).strip()
170+
soc_version = soc_version.split("-")[0]
171+
soc_version = "Ascend" + soc_version
172+
except subprocess.CalledProcessError as e:
173+
raise RuntimeError(f"Retrive Soc version failed: {e}")
174+
else:
175+
soc_version = envs.SOC_VERSION
173176

174177
# add SOC_VERSION
175178
cmake_args += [f"-DSOC_VERSION={soc_version}"]

vllm_ascend/envs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
"CXX_COMPILER":
3232
lambda: os.getenv("CXX_COMPILER", None),
3333
"C_COMPILER":
34-
lambda: os.getenv("C_COMPILER", None)
34+
lambda: os.getenv("C_COMPILER", None),
35+
"SOC_VERSION":
36+
lambda: os.getenv("SOC_VERSION", None),
3537
}
3638

3739

0 commit comments

Comments
 (0)