Skip to content

Commit

Permalink
Ray Patch
Browse files Browse the repository at this point in the history
Signed-off-by: Chenguang Li <757486878@qq.com>
  • Loading branch information
noemotiovon committed Feb 19, 2025
1 parent c18fb09 commit d7fcb01
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/offline_distributed_inference_npu.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
llm = LLM(
model="Qwen/Qwen2.5-0.5B-Instruct",
tensor_parallel_size=2,
distributed_executor_backend="mp",
distributed_executor_backend="ray",
trust_remote_code=True,
)

Expand Down
2 changes: 2 additions & 0 deletions vllm_ascend/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def mem_get_info(cls) -> Tuple[int, int]:
def check_and_update_config(cls, vllm_config: VllmConfig) -> None:
# Register ops when setup.
from vllm_ascend import ops # noqa: F401
# RayWorkerWrapper monkey patch when setup
from vllm_ascend import ray_patch # noqa: F401

parallel_config = vllm_config.parallel_config
if parallel_config.worker_cls == "auto":
Expand Down
10 changes: 10 additions & 0 deletions vllm_ascend/ray_patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import vllm
from vllm.executor.ray_utils import RayWorkerWrapper
import torch_npu # noqa: F401

class NPURayWorkerWrapper(RayWorkerWrapper):
"""Importing torch_npu in other Ray processes through an empty class and a monkey patch.
"""
pass

vllm.executor.ray_utils.RayWorkerWrapper = NPURayWorkerWrapper

0 comments on commit d7fcb01

Please sign in to comment.