ray_xpu_executor.py 1.31 KB
Newer Older
1
import asyncio
2
from typing import List, Optional
3

4
import vllm.envs as envs
5
6
from vllm.executor.ray_gpu_executor import RayGPUExecutor, RayGPUExecutorAsync
from vllm.executor.xpu_executor import XPUExecutor
7
from vllm.logger import init_logger
8
from vllm.utils import get_vllm_instance_id, make_async
9
10
11
12

logger = init_logger(__name__)


13
class RayXPUExecutor(RayGPUExecutor, XPUExecutor):
14

15
    def _get_env_vars_to_be_updated(self):
16
17
18
19
        # Get the set of GPU IDs used on each node.
        worker_node_and_gpu_ids = self._run_workers("get_node_and_gpu_ids",
                                                    use_dummy_driver=True)

20
        VLLM_INSTANCE_ID = get_vllm_instance_id()
21

22
23
24
25
26
27
28
29
        # Set environment variables for the driver and workers.
        all_args_to_update_environment_variables = [({
            "VLLM_INSTANCE_ID":
            VLLM_INSTANCE_ID,
            "VLLM_TRACE_FUNCTION":
            str(envs.VLLM_TRACE_FUNCTION),
        }, ) for (_, _) in worker_node_and_gpu_ids]
        return all_args_to_update_environment_variables
30
31


32
class RayXPUExecutorAsync(RayXPUExecutor, RayGPUExecutorAsync):
33
34
35
36

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.driver_exec_method = make_async(self.driver_worker.execute_method)
37
        self.pp_locks: Optional[List[asyncio.Lock]] = None