A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 07:15 UTC
[Misc] refactor: simplify EngineCoreClient.make_async_mp_client in AsyncLLM (#18817)
Signed-off-by: googs1025 <googs1025@gmail.com>
CYJiang committed
Jun 5, 2025 at 06:37 UTC
23027e2daff4e0ef81baf4403b3d9eb452491b38
2 files changed
+22
-17
vllm/v1/engine/async_llm.py
+3
-11
@@ -28,8 +28,7 @@ from vllm.transformers_utils.tokenizer_group import init_tokenizer_from_configs
28
from vllm.usage.usage_lib import UsageContext
29
from vllm.utils import Device, cdiv
30
from vllm.v1.engine import EngineCoreRequest
31
-from vllm.v1.engine.core_client import (AsyncMPClient, DPAsyncMPClient,
32
- RayDPClient)
31
+from vllm.v1.engine.core_client import EngineCoreClient
32
from vllm.v1.engine.exceptions import EngineDeadError, EngineGenerateError
33
from vllm.v1.engine.output_processor import (OutputProcessor,
34
RequestOutputCollector)
@@ -121,15 +120,8 @@ class AsyncLLM(EngineClient):
120
log_stats=self.log_stats)
121
122
# EngineCore (starts the engine in background process).
124
- core_client_class: type[AsyncMPClient]
125
- if vllm_config.parallel_config.data_parallel_size == 1:
126
- core_client_class = AsyncMPClient
127
- elif vllm_config.parallel_config.data_parallel_backend == "ray":
128
- core_client_class = RayDPClient
129
- else:
130
- core_client_class = DPAsyncMPClient
131
-
132
- self.engine_core = core_client_class(
123
+
124
+ self.engine_core = EngineCoreClient.make_async_mp_client(
125
vllm_config=vllm_config,
126
executor_class=executor_class,
127
log_stats=self.log_stats,
vllm/v1/engine/core_client.py
+19
-6
@@ -68,18 +68,31 @@ class EngineCoreClient(ABC):
68
"is not currently supported.")
69
70
if multiprocess_mode and asyncio_mode:
71
- if vllm_config.parallel_config.data_parallel_size > 1:
72
- if vllm_config.parallel_config.data_parallel_backend == "ray":
73
- return RayDPClient(vllm_config, executor_class, log_stats)
74
- return DPAsyncMPClient(vllm_config, executor_class, log_stats)
75
-
76
- return AsyncMPClient(vllm_config, executor_class, log_stats)
71
+ return EngineCoreClient.make_async_mp_client(
72
+ vllm_config, executor_class, log_stats)
73
74
if multiprocess_mode and not asyncio_mode:
75
return SyncMPClient(vllm_config, executor_class, log_stats)
76
77
return InprocClient(vllm_config, executor_class, log_stats)
78
79
+ @staticmethod
80
+ def make_async_mp_client(
81
+ vllm_config: VllmConfig,
82
+ executor_class: type[Executor],
83
+ log_stats: bool,
84
+ client_addresses: Optional[dict[str, str]] = None,
85
+ client_index: int = 0,
86
+ ) -> "MPClient":
87
+ if vllm_config.parallel_config.data_parallel_size > 1:
88
+ if vllm_config.parallel_config.data_parallel_backend == "ray":
89
+ return RayDPClient(vllm_config, executor_class, log_stats,
90
+ client_addresses, client_index)
91
+ return DPAsyncMPClient(vllm_config, executor_class, log_stats,
92
+ client_addresses, client_index)
93
+ return AsyncMPClient(vllm_config, executor_class, log_stats,
94
+ client_addresses, client_index)
95
+
96
@abstractmethod
97
def shutdown(self):
98
...