[Feature] Add fault tolerance framework (simplified) for DP+EP external LB deployments (#44428)
Signed-off-by: fangyuchu <fangyuchu@qq.com> Signed-off-by: a798347923 <2645302020@qq.com> Signed-off-by: TianZhuo <2770730562@qq.com> Signed-off-by: a798347923 <39047817+a798347923@users.noreply.github.com> Signed-off-by: 205150940 <112750056+205150940@users.noreply.github.com> Signed-off-by: w00689259 <wangzhuo66@huawei.com> Signed-off-by: zWaNg3 <37772915+zWaNg3@users.noreply.github.com> Signed-off-by: zWaNg3 <389750525@qq.com> Signed-off-by: yzchang-plus <1078477584@qq.com> Signed-off-by: Jade Zheng <zheng.shoujian@outlook.com> Co-authored-by: zWaNg3 <37772915+zWaNg3@users.noreply.github.com> Co-authored-by: a798347923 <2645302020@qq.com> Co-authored-by: TianZhuo <2770730562@qq.com> Co-authored-by: 205150940 <112750056+205150940@users.noreply.github.com> Co-authored-by: a798347923 <39047817+a798347923@users.noreply.github.com> Co-authored-by: w00689259 <wangzhuo66@huawei.com> Co-authored-by: zWaNg3 <389750525@qq.com> Co-authored-by: yzchang-plus <1078477584@qq.com> Co-authored-by: Jade Zheng <zheng.shoujian@outlook.com>
This commit is contained in:
co-authored by
zWaNg3
a798347923
TianZhuo
205150940
a798347923
w00689259
zWaNg3
yzchang-plus
Jade Zheng
parent
33ef67e9fb
commit
0b0bd2b5f6
@@ -16,6 +16,7 @@ from multiprocessing.queues import Queue
|
||||
from threading import Thread
|
||||
from typing import Any, TypeAlias, TypeVar
|
||||
|
||||
import msgspec
|
||||
import msgspec.msgpack
|
||||
import zmq
|
||||
import zmq.asyncio
|
||||
@@ -35,6 +36,7 @@ from vllm.utils.network_utils import (
|
||||
)
|
||||
from vllm.v1.engine import (
|
||||
EEP_NOTIFICATION_CALL_ID,
|
||||
FT_STATUS_CALL_ID,
|
||||
EEPNotificationType,
|
||||
EngineCoreOutputs,
|
||||
EngineCoreReadyResponse,
|
||||
@@ -56,6 +58,11 @@ from vllm.v1.engine.utils import (
|
||||
launch_core_engines,
|
||||
)
|
||||
from vllm.v1.executor import Executor
|
||||
from vllm.v1.fault_tolerance.engine_core_sentinel import FT_UTILITY_METHOD
|
||||
from vllm.v1.fault_tolerance.utils import (
|
||||
FaultToleranceRequest,
|
||||
FaultToleranceResult,
|
||||
)
|
||||
from vllm.v1.pool.late_interaction import get_late_interaction_engine_index
|
||||
from vllm.v1.serial_utils import MsgpackDecoder, MsgpackEncoder, bytestr
|
||||
|
||||
@@ -272,6 +279,14 @@ class EngineCoreClient(ABC):
|
||||
) -> list[_R]:
|
||||
raise NotImplementedError
|
||||
|
||||
async def handle_fault(
|
||||
self, fault_tolerance_request: FaultToleranceRequest
|
||||
) -> FaultToleranceResult:
|
||||
raise NotImplementedError
|
||||
|
||||
async def get_status(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class InprocClient(EngineCoreClient):
|
||||
"""
|
||||
@@ -971,6 +986,14 @@ class AsyncMPClient(MPClient):
|
||||
self.client_count = client_count
|
||||
self.client_index = client_index
|
||||
self.outputs_queue = asyncio.Queue[EngineCoreOutputs | Exception]()
|
||||
|
||||
# locally-cached engine status
|
||||
self._engine_status: dict[int, dict] = {}
|
||||
if self.vllm_config.parallel_config.enable_fault_tolerance:
|
||||
self._engine_status = {
|
||||
rank: {"id": rank, "status": "healthy"}
|
||||
for rank in self.engine_ranks_managed
|
||||
}
|
||||
try:
|
||||
# If we are running in an asyncio event loop, start the queue task.
|
||||
# Otherwise, it will be started lazily. If it is not started here,
|
||||
@@ -994,7 +1017,7 @@ class AsyncMPClient(MPClient):
|
||||
output_handler: (
|
||||
Callable[[AsyncMPClient, EngineCoreOutputs], Awaitable[None]] | None
|
||||
) = getattr(self.__class__, "process_engine_outputs", None)
|
||||
_self_ref = weakref.ref(self) if output_handler else None
|
||||
_self_ref = weakref.ref(self)
|
||||
output_socket = resources.output_socket
|
||||
assert output_socket is not None
|
||||
|
||||
@@ -1025,6 +1048,14 @@ class AsyncMPClient(MPClient):
|
||||
asyncio.create_task(
|
||||
notification_callback_handler(_self, notification_data)
|
||||
)
|
||||
elif outputs.utility_output.call_id == FT_STATUS_CALL_ID:
|
||||
_self = _self_ref()
|
||||
if not _self:
|
||||
return
|
||||
if outputs.utility_output.result is not None:
|
||||
_self._engine_status[outputs.engine_index] = (
|
||||
outputs.utility_output.result.result
|
||||
)
|
||||
else:
|
||||
_process_utility_output(
|
||||
outputs.utility_output, utility_results
|
||||
@@ -1196,6 +1227,25 @@ class AsyncMPClient(MPClient):
|
||||
"collective_rpc", method, timeout, args, kwargs
|
||||
)
|
||||
|
||||
async def handle_fault(
|
||||
self, ft_request: FaultToleranceRequest
|
||||
) -> FaultToleranceResult:
|
||||
res = await self.call_utility_async(FT_UTILITY_METHOD, ft_request)
|
||||
result = msgspec.convert(res, FaultToleranceResult)
|
||||
if not result.success:
|
||||
status = self._engine_status.get(self.engine_ranks_managed[0])
|
||||
if status is not None:
|
||||
status["last_ft_request_id"] = result.request_id
|
||||
status["ft_error"] = result.reason
|
||||
return result
|
||||
|
||||
async def get_status(self):
|
||||
return {
|
||||
"schema_version": 1,
|
||||
"total_engines": len(self.engine_ranks_managed),
|
||||
"engines": list(self._engine_status.values()),
|
||||
}
|
||||
|
||||
|
||||
class DPAsyncMPClient(AsyncMPClient):
|
||||
"""Asyncio-compatible client for multi-proc, multi-engine (data parallel)
|
||||
|
||||
Reference in New Issue
Block a user