Skip to content

Commit bbe7ccd

Browse files
authored
[MISC] Add patch module (#526)
This PR added patch module for vllm 1. platform patch: the patch will be registered when load the platform 2. worker patch: the patch will be registered when worker is started. The detail is: 1. patch_common: patch for main and 0.8.4 version 4. patch_main: patch for main verison 5. patch_0_8_4: patch for 0.8.4 version
1 parent 434749d commit bbe7ccd

File tree

16 files changed

+185
-3
lines changed

16 files changed

+185
-3
lines changed

docs/source/faqs.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,31 @@ Find more details [<u>here</u>](https://github.com/vllm-project/vllm-ascend/issu
7272

7373
### 6. How to solve the problem of "Failed to infer device type" or "libatb.so: cannot open shared object file"?
7474

75-
Basicly, the reason is that the NNAL environment is not sourced. Please try `source /usr/local/Ascend/nnal/atb/set_env.sh` to solve the problem.
75+
Basically, the reason is that the NPU environment is not configured correctly. You can:
76+
1. try `source /usr/local/Ascend/nnal/atb/set_env.sh` to enable NNAL package.
77+
2. try `source /usr/local/Ascend/ascend-toolkit/set_env.sh` to enable CANN package.
78+
3. try `npu-smi info` to check whether the NPU is working.
79+
80+
If all above steps are not working, you can try the following code with python to check whether there is any error:
81+
82+
```
83+
import torch
84+
import torch_npu
85+
import vllm
86+
```
87+
88+
If all above steps are not working, feel free to submit a GitHub issue.
7689

7790
### 7. Does vllm-ascend support Atlas 300I Duo?
7891

7992
No, vllm-ascend now only supports Atlas A2 series. We are working on it.
8093

8194
### 8. How does vllm-ascend perform?
8295

83-
Currently, only some models are imporved. Such as `Qwen2 VL`, `Deepseek V3`. Others are not good enough. In the future, we will support graph mode and custom ops to improve the performance of vllm-ascend. And when the official release of vllm-ascend is released, you can install `mindie-turbo` with `vllm-ascend` to speed up the inference as well.
96+
Currently, only some models are improved. Such as `Qwen2 VL`, `Deepseek V3`. Others are not good enough. In the future, we will support graph mode and custom ops to improve the performance of vllm-ascend. And when the official release of vllm-ascend is released, you can install `mindie-turbo` with `vllm-ascend` to speed up the inference as well.
8497

8598
### 9. How vllm-ascend work with vllm?
86-
vllm-ascend is a plugin for vllm. Basicly, the version of vllm-ascend is the same as the version of vllm. For example, if you use vllm 0.7.3, you should use vllm-ascend 0.7.3 as well. For main branch, we will make sure `vllm-ascend` and `vllm` are compatible by each commit.
99+
vllm-ascend is a plugin for vllm. Basically, the version of vllm-ascend is the same as the version of vllm. For example, if you use vllm 0.7.3, you should use vllm-ascend 0.7.3 as well. For main branch, we will make sure `vllm-ascend` and `vllm` are compatible by each commit.
87100

88101
### 10. Does vllm-ascend support Prefill Disaggregation feature?
89102

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ requires = [
44
"cmake>=3.26",
55
"decorator",
66
"numpy<2.0.0",
7+
"packaging",
78
"pip",
89
"pybind11",
910
"pyyaml",

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
cmake>=3.26
33
decorator
44
numpy<2.0.0
5+
packaging
56
pybind11
67
pyyaml
78
scipy

vllm_ascend/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
def register():
2020
"""Register the NPU platform."""
21+
# Adapt the global patch here.
22+
from vllm_ascend.utils import adapt_patch
23+
adapt_patch(is_global_patch=True)
24+
2125
return "vllm_ascend.platform.NPUPlatform"
2226

2327

vllm_ascend/patch/__init__.py

Whitespace-only changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
3+
# This file is a part of the vllm-ascend project.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import vllm
18+
from packaging.version import Version
19+
20+
# Import common patches for all versions
21+
from vllm_ascend.patch.platform import patch_common # noqa: F401
22+
23+
# Import specific patches for different versions
24+
if Version(vllm.__version__) == Version("0.8.4"):
25+
from vllm_ascend.patch.platform import patch_0_8_4 # noqa: F401
26+
else:
27+
from vllm_ascend.patch.platform import patch_main # noqa: F401
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
3+
# This file is a part of the vllm-ascend project.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
3+
# This file is a part of the vllm-ascend project.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
3+
# This file is a part of the vllm-ascend project.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#

vllm_ascend/patch/worker/__init__.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
3+
# This file is a part of the vllm-ascend project.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
import vllm
18+
from packaging.version import Version
19+
20+
# Import common patches for all versions
21+
from vllm_ascend.patch.worker import patch_common # noqa: F401
22+
23+
# Import specific patches for different versions
24+
if Version(vllm.__version__) == Version("0.8.4"):
25+
from vllm_ascend.patch.worker import patch_0_8_4 # noqa: F401
26+
else:
27+
from vllm_ascend.patch.worker import patch_main # noqa: F401

0 commit comments

Comments
 (0)