Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
60c98e29
Commit
60c98e29
authored
Apr 09, 2026
by
zhangzbb
Browse files
[Tencent FIX BUILD FLOW] stabilize Hygon DCU wheel build and install flow
parent
bcb2ba6c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
261 additions
and
16 deletions
+261
-16
README.md
README.md
+13
-8
requirements/hygon.text
requirements/hygon.text
+48
-0
requirements/rocm.txt
requirements/rocm.txt
+1
-7
setup.py
setup.py
+123
-1
tools/check_hygon_env.py
tools/check_hygon_env.py
+76
-0
No files found.
README.md
View file @
60c98e29
...
...
@@ -65,22 +65,27 @@ pip install setuptools wheel
```
shell
git clone http://10.16.6.30/dcutoolkit/deeplearing/vllm.git
# 根据需要的分支进行切换
```
安装依赖:
```
shell
pip
install
-r
requirements/rocm.txt
```
-
提供2种源码编译方式(进入vllm目录):
```
1. 编译whl包并安装
python setup.py bdist_wheel
1. 编译whl包并安装(推荐)
python tools/check_hygon_env.py
VLLM_USE_HYGON=1 python setup.py bdist_wheel
cd dist
pip install vllm*
python tools/check_hygon_env.py
2. 源码编译安装
python3 setup.py install (若调试,可使用python3 setup.py develop)
VLLM_USE_HYGON=1
python3 setup.py install (若调试,可使用
VLLM_USE_HYGON=1
python3 setup.py develop)
```
若需要添加git号,设置环境变量: export ADD_GIT_VERSION=1
> 注意:
> - 海光 DCU 环境必须设置 `VLLM_USE_HYGON=1`。
> - 构建时会自动将海光定制包(如 `torch`、`triton`、`flash_attn`)改写为当前环境中的精确 `+das.*` 版本,避免 pip 在安装时替换为不兼容的 PyPI 版本。
> - `hygon.txt` 只对高风险包做最小锁定:`numpy==1.26.4` 以及海光定制包,其余 Python 依赖保持正常解析。
> - 海光路径会将 `fastapi[standard]`、`mistral_common[image]` 这类容易触发深度回溯的 extras 依赖替换为镜像中已验证的显式依赖版本。
> - 可使用 `python tools/check_hygon_env.py` 在构建前和安装后校验关键包版本
### 运行基础环境准备
1、使用上面基于光源pytorch2.9.0基础镜像环境
...
...
requirements/hygon.text
0 → 100644
View file @
60c98e29
# Hygon DCU dependencies (based on ROCm/HIP)
# Use VLLM_USE_HYGON=1 to enable this file during build.
#
# Keep the lock set minimal:
# - pin numpy explicitly to avoid ABI-breaking upgrades
# - keep Hygon custom packages on base versions here, then rewrite them
# to exact +das.* installed versions during bdist_wheel
-r common.txt
# Pin numpy to 1.26.x: compatible with both custom torch ABI and
# modern PyPI packages (pandas, opencv, etc.)
numpy == 1.26.4
# Replace heavy extras dependency chains with the explicit versions
# already validated in the Hygon Docker image.
fastapi == 0.135.3
uvicorn == 0.42.0
python-multipart == 0.0.22
watchfiles == 1.1.1
mistral_common == 1.11.0
numba == 0.61.2 # Required for N-gram speculative decoding
# Dependencies for Hygon DCU
datasets
ray[cgraph]>=2.48.0 # Ray Compiled Graph, required for pipeline parallelism in V1.
peft
pytest-asyncio
tensorizer==2.10.1
packaging>=24.2
setuptools>=77.0.3,<80.0.0
setuptools-scm>=8
runai-model-streamer[s3,gcs]==0.15.3
timm>=1.0.17
grpcio-tools>=1.76.0
numa
quart
fastrlock==0.8.3
# Hygon DCU hardware-bound packages (base versions)
torch == 2.9.0
triton == 3.3.0
flash_attn == 2.6.1
flash_mla == 1.2.0
lightop == 0.6.0
lmslim == 0.3.1
requirements/rocm.txt
View file @
60c98e29
...
...
@@ -19,14 +19,8 @@ grpcio-tools>=1.76.0
numa
# pytrie
cmake==3.29
#
cmake==3.29
quart
fastrlock==0.8.3
# cupy==12.3.0
torch == 2.9.0
triton == 3.3.0
flash_attn == 2.8.3
flash_mla == 1.0.0
lightop == 0.6.0
lmslim == 0.3.1
setup.py
View file @
60c98e29
...
...
@@ -1046,6 +1046,117 @@ def get_vllm_version() -> str:
return
version
def
_pin_hygon_local_versions
(
requirements
:
list
[
str
])
->
list
[
str
]:
"""Pin packages with +das.* local versions to their exact installed
versions, and deduplicate requirements (later entries win)."""
import
importlib.metadata
# First pass: pin +das versions
pinned
=
[]
for
req
in
requirements
:
match
=
re
.
match
(
r
'^([a-zA-Z0-9_-]+)\s*=='
,
req
)
if
match
:
pkg_name
=
match
.
group
(
1
)
try
:
installed_ver
=
importlib
.
metadata
.
version
(
pkg_name
)
if
"+das"
in
installed_ver
:
pinned
.
append
(
f
"
{
pkg_name
}
==
{
installed_ver
}
"
)
continue
except
importlib
.
metadata
.
PackageNotFoundError
:
pass
pinned
.
append
(
req
)
# Second pass: deduplicate by package name (later entries win)
seen
=
{}
for
req
in
pinned
:
match
=
re
.
match
(
r
'^([a-zA-Z0-9_-]+)'
,
req
)
if
match
:
pkg_name
=
match
.
group
(
1
).
lower
().
replace
(
"-"
,
"_"
)
seen
[
pkg_name
]
=
req
else
:
seen
[
req
]
=
req
return
list
(
seen
.
values
())
def
_validate_hygon_build_env
()
->
None
:
"""Fail fast with actionable errors for the Hygon build env."""
import
importlib.metadata
exact_versions
=
{
"numpy"
:
"1.26.4"
,
}
das_versions
=
{
"torch"
:
"2.9.0"
,
"triton"
:
"3.3.0"
,
"flash_attn"
:
"2.6.1"
,
"flash_mla"
:
"1.2.0"
,
"lightop"
:
"0.6.0"
,
"lmslim"
:
"0.3.1"
,
}
errors
:
list
[
str
]
=
[]
for
pkg_name
,
expected_version
in
exact_versions
.
items
():
try
:
installed_ver
=
importlib
.
metadata
.
version
(
pkg_name
)
except
importlib
.
metadata
.
PackageNotFoundError
:
errors
.
append
(
f
"- Missing required package `
{
pkg_name
}
`. Expected "
f
"`
{
expected_version
}
`."
)
continue
if
installed_ver
!=
expected_version
:
errors
.
append
(
f
"- `
{
pkg_name
}
` version mismatch: expected "
f
"`
{
expected_version
}
`, got `
{
installed_ver
}
`."
)
for
pkg_name
,
expected_base
in
das_versions
.
items
():
try
:
installed_ver
=
importlib
.
metadata
.
version
(
pkg_name
)
except
importlib
.
metadata
.
PackageNotFoundError
:
errors
.
append
(
f
"- Missing required package `
{
pkg_name
}
`. Expected a "
f
"Hygon build based on `
{
expected_base
}
`."
)
continue
if
not
installed_ver
.
startswith
(
expected_base
):
errors
.
append
(
f
"- `
{
pkg_name
}
` version mismatch: expected base "
f
"`
{
expected_base
}
`, got `
{
installed_ver
}
`."
)
if
"+das"
not
in
installed_ver
:
errors
.
append
(
f
"- `
{
pkg_name
}
` is not a Hygon custom build: "
f
"`
{
installed_ver
}
`."
)
if
errors
:
joined
=
"
\n
"
.
join
(
errors
)
raise
RuntimeError
(
"Hygon build environment validation failed.
\n
"
"Please fix the following packages before running "
"`VLLM_USE_HYGON=1 python setup.py bdist_wheel`:
\n
"
f
"
{
joined
}
"
)
def
_rewrite_hygon_requirements
(
requirements
:
list
[
str
])
->
list
[
str
]:
"""Replace heavy extras chains with explicit Hygon-validated packages."""
replaced_packages
=
{
"fastapi"
,
"mistral_common"
,
"opencv_python_headless"
,
}
rewritten
:
list
[
str
]
=
[]
for
req
in
requirements
:
match
=
re
.
match
(
r
'^([a-zA-Z0-9_-]+)'
,
req
)
if
match
:
pkg_name
=
match
.
group
(
1
).
lower
().
replace
(
"-"
,
"_"
)
if
pkg_name
in
replaced_packages
:
continue
rewritten
.
append
(
req
)
return
rewritten
def
get_requirements
()
->
list
[
str
]:
"""Get Python package dependencies from requirements.txt."""
...
...
@@ -1080,6 +1191,12 @@ def get_requirements() -> list[str]:
modified_requirements
.
append
(
req
)
requirements
=
modified_requirements
elif
_is_hip
():
if
os
.
environ
.
get
(
"VLLM_USE_HYGON"
,
""
).
strip
().
lower
()
in
(
"1"
,
"true"
):
_validate_hygon_build_env
()
requirements
=
_read_requirements
(
"hygon.txt"
)
requirements
=
_rewrite_hygon_requirements
(
requirements
)
requirements
=
_pin_hygon_local_versions
(
requirements
)
else
:
requirements
=
_read_requirements
(
"rocm.txt"
)
elif
_is_tpu
():
requirements
=
_read_requirements
(
"tpu.txt"
)
...
...
@@ -1206,3 +1323,8 @@ setup(
cmdclass
=
cmdclass
,
package_data
=
package_data
,
)
if
"bdist_wheel"
in
sys
.
argv
:
egg_info_dir
=
ROOT_DIR
/
"vllm.egg-info"
if
egg_info_dir
.
exists
():
shutil
.
rmtree
(
egg_info_dir
)
logger
.
info
(
"Cleaned up %s"
,
egg_info_dir
)
tools/check_hygon_env.py
0 → 100644
View file @
60c98e29
#!/usr/bin/env python3
"""Validate the Hygon DCU Python environment."""
from
__future__
import
annotations
import
sys
from
importlib
import
metadata
EXACT_VERSIONS
=
{
"numpy"
:
"1.26.4"
,
}
DAS_VERSIONS
=
{
"torch"
:
"2.9.0"
,
"triton"
:
"3.3.0"
,
"flash_attn"
:
"2.6.1"
,
"flash_mla"
:
"1.2.0"
,
"lightop"
:
"0.6.0"
,
"lmslim"
:
"0.3.1"
,
}
def
main
()
->
int
:
errors
:
list
[
str
]
=
[]
print
(
"Checking Hygon DCU Python environment..."
)
for
pkg_name
,
expected_version
in
EXACT_VERSIONS
.
items
():
try
:
installed_ver
=
metadata
.
version
(
pkg_name
)
print
(
f
"
{
pkg_name
}
:
{
installed_ver
}
"
)
except
metadata
.
PackageNotFoundError
:
errors
.
append
(
f
"- Missing `
{
pkg_name
}
` (expected `
{
expected_version
}
`)."
)
continue
if
installed_ver
!=
expected_version
:
errors
.
append
(
f
"- `
{
pkg_name
}
` mismatch: expected `
{
expected_version
}
`, "
f
"got `
{
installed_ver
}
`."
)
for
pkg_name
,
expected_base
in
DAS_VERSIONS
.
items
():
try
:
installed_ver
=
metadata
.
version
(
pkg_name
)
print
(
f
"
{
pkg_name
}
:
{
installed_ver
}
"
)
except
metadata
.
PackageNotFoundError
:
errors
.
append
(
f
"- Missing `
{
pkg_name
}
` (expected Hygon build based on "
f
"`
{
expected_base
}
`)."
)
continue
if
not
installed_ver
.
startswith
(
expected_base
):
errors
.
append
(
f
"- `
{
pkg_name
}
` mismatch: expected base `
{
expected_base
}
`, "
f
"got `
{
installed_ver
}
`."
)
if
"+das"
not
in
installed_ver
:
errors
.
append
(
f
"- `
{
pkg_name
}
` is not a Hygon custom build: "
f
"`
{
installed_ver
}
`."
)
if
errors
:
print
(
"
\n
Environment check failed:"
)
for
error
in
errors
:
print
(
error
)
return
1
print
(
"
\n
Environment check passed."
)
return
0
if
__name__
==
"__main__"
:
raise
SystemExit
(
main
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment