[Misc] Support more collective_rpc return types (#21845)
Signed-off-by: Nick Hill <nhill@redhat.com>
This commit is contained in:
@@ -123,6 +123,13 @@ class EngineCoreOutput(
|
||||
return self.finish_reason is not None
|
||||
|
||||
|
||||
class UtilityResult:
|
||||
"""Wrapper for special handling when serializing/deserializing."""
|
||||
|
||||
def __init__(self, r: Any = None):
|
||||
self.result = r
|
||||
|
||||
|
||||
class UtilityOutput(
|
||||
msgspec.Struct,
|
||||
array_like=True, # type: ignore[call-arg]
|
||||
@@ -132,7 +139,7 @@ class UtilityOutput(
|
||||
|
||||
# Non-None implies the call failed, result should be None.
|
||||
failure_message: Optional[str] = None
|
||||
result: Any = None
|
||||
result: Optional[UtilityResult] = None
|
||||
|
||||
|
||||
class EngineCoreOutputs(
|
||||
|
||||
@@ -36,7 +36,7 @@ from vllm.v1.core.sched.scheduler import Scheduler as V1Scheduler
|
||||
from vllm.v1.engine import (EngineCoreOutputs, EngineCoreRequest,
|
||||
EngineCoreRequestType,
|
||||
ReconfigureDistributedRequest, ReconfigureRankType,
|
||||
UtilityOutput)
|
||||
UtilityOutput, UtilityResult)
|
||||
from vllm.v1.engine.mm_input_cache import MirroredProcessingCache
|
||||
from vllm.v1.engine.utils import EngineHandshakeMetadata, EngineZmqAddresses
|
||||
from vllm.v1.executor.abstract import Executor
|
||||
@@ -715,8 +715,8 @@ class EngineCoreProc(EngineCore):
|
||||
output = UtilityOutput(call_id)
|
||||
try:
|
||||
method = getattr(self, method_name)
|
||||
output.result = method(
|
||||
*self._convert_msgspec_args(method, args))
|
||||
result = method(*self._convert_msgspec_args(method, args))
|
||||
output.result = UtilityResult(result)
|
||||
except BaseException as e:
|
||||
logger.exception("Invocation of %s method failed", method_name)
|
||||
output.failure_message = (f"Call to {method_name} method"
|
||||
|
||||
@@ -552,7 +552,8 @@ def _process_utility_output(output: UtilityOutput,
|
||||
if output.failure_message is not None:
|
||||
future.set_exception(Exception(output.failure_message))
|
||||
else:
|
||||
future.set_result(output.result)
|
||||
assert output.result is not None
|
||||
future.set_result(output.result.result)
|
||||
|
||||
|
||||
class SyncMPClient(MPClient):
|
||||
|
||||
Reference in New Issue
Block a user