Skip to content

Commit d7fcb01

Browse files
committed
Ray Patch
Signed-off-by: Chenguang Li <757486878@qq.com>
1 parent c18fb09 commit d7fcb01

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

examples/offline_distributed_inference_npu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
llm = LLM(
3333
model="Qwen/Qwen2.5-0.5B-Instruct",
3434
tensor_parallel_size=2,
35-
distributed_executor_backend="mp",
35+
distributed_executor_backend="ray",
3636
trust_remote_code=True,
3737
)
3838

vllm_ascend/platform.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def mem_get_info(cls) -> Tuple[int, int]:
9090
def check_and_update_config(cls, vllm_config: VllmConfig) -> None:
9191
# Register ops when setup.
9292
from vllm_ascend import ops # noqa: F401
93+
# RayWorkerWrapper monkey patch when setup
94+
from vllm_ascend import ray_patch # noqa: F401
9395

9496
parallel_config = vllm_config.parallel_config
9597
if parallel_config.worker_cls == "auto":

vllm_ascend/ray_patch.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import vllm
2+
from vllm.executor.ray_utils import RayWorkerWrapper
3+
import torch_npu # noqa: F401
4+
5+
class NPURayWorkerWrapper(RayWorkerWrapper):
6+
"""Importing torch_npu in other Ray processes through an empty class and a monkey patch.
7+
"""
8+
pass
9+
10+
vllm.executor.ray_utils.RayWorkerWrapper = NPURayWorkerWrapper

0 commit comments

Comments
 (0)