[Frontend] Add midway prompt update for streaming video generation (#4652)
Signed-off-by: Huang, Zeyu <11222265+fhfuih@users.noreply.github.com>
This commit is contained in:
1 parent
1f01d05603
commit
eaf90d8eff
28 files changed
+2615
-133
No files matched your search
@@ -55,6 +55,7 @@ from vllm_omni.engine.messages import (
|
||||
CollectiveRPCResultMessage,
|
||||
EngineQueueMessage,
|
||||
ErrorMessage,
|
||||
InteractionMessage,
|
||||
StageSubmissionMessage,
|
||||
)
|
||||
from vllm_omni.engine.orchestrator import Orchestrator
|
||||
@@ -71,7 +72,7 @@ from vllm_omni.entrypoints.utils import (
|
||||
load_and_resolve_stage_configs,
|
||||
parse_stage_overrides,
|
||||
)
|
||||
from vllm_omni.inputs.data import OmniSamplingParams
|
||||
from vllm_omni.inputs.data import OmniInteractionPrompt, OmniSamplingParams
|
||||
from vllm_omni.metrics.prometheus import OmniRequestCounter
|
||||
|
||||
logger = init_logger(__name__)
|
||||
@@ -1703,6 +1704,30 @@ class AsyncOmniEngine:
|
||||
"""Async abort API."""
|
||||
self.abort(request_ids)
|
||||
|
||||
def submit_interaction(
|
||||
self,
|
||||
request_id: str,
|
||||
interaction: OmniInteractionPrompt,
|
||||
) -> None:
|
||||
"""Send an interaction control message to the Orchestrator."""
|
||||
if self.request_queue is None:
|
||||
raise RuntimeError("request_queue is not initialized")
|
||||
|
||||
self.request_queue.sync_q.put_nowait(
|
||||
InteractionMessage(
|
||||
request_id=request_id,
|
||||
interaction=interaction,
|
||||
)
|
||||
)
|
||||
|
||||
async def submit_interaction_async(
|
||||
self,
|
||||
request_id: str,
|
||||
interaction: OmniInteractionPrompt,
|
||||
) -> None:
|
||||
"""Async interaction API."""
|
||||
self.submit_interaction(request_id, interaction)
|
||||
|
||||
def collective_rpc(
|
||||
self,
|
||||
method: str,
|
||||
|
||||
@@ -6,7 +6,7 @@ import msgspec
|
||||
from vllm.inputs import PromptType
|
||||
from vllm.v1.engine import EngineCoreRequest
|
||||
|
||||
from vllm_omni.inputs.data import OmniSamplingParams
|
||||
from vllm_omni.inputs.data import OmniInteractionPrompt, OmniSamplingParams
|
||||
from vllm_omni.metrics.stats import StageRequestStats as StageRequestMetrics
|
||||
from vllm_omni.outputs import OmniRequestOutput
|
||||
|
||||
@@ -44,6 +44,12 @@ class AbortRequestMessage(EngineQueueMessage, kw_only=True):
|
||||
request_ids: list[str]
|
||||
|
||||
|
||||
class InteractionMessage(EngineQueueMessage, kw_only=True):
|
||||
type: Literal["interaction"] = "interaction"
|
||||
request_id: str
|
||||
interaction: OmniInteractionPrompt
|
||||
|
||||
|
||||
class CollectiveRPCRequestMessage(EngineQueueMessage, kw_only=True):
|
||||
type: Literal["collective_rpc"] = "collective_rpc"
|
||||
rpc_id: str
|
||||
@@ -78,6 +84,7 @@ class ErrorMessage(EngineQueueMessage, kw_only=True):
|
||||
fatal: bool = False
|
||||
request_id: str | None = None
|
||||
stage_id: int | None = None
|
||||
event_id: str | None = None # for interactions on diffusion generation requests
|
||||
|
||||
|
||||
class OutputMessage(EngineQueueMessage, kw_only=True):
|
||||
|
||||
@@ -40,6 +40,7 @@ from vllm_omni.engine.messages import (
|
||||
CollectiveRPCResultMessage,
|
||||
EngineQueueMessage,
|
||||
ErrorMessage,
|
||||
InteractionMessage,
|
||||
OutputMessage,
|
||||
RegisterRemoteReplicaMessage,
|
||||
ShutdownRequestMessage,
|
||||
@@ -577,6 +578,8 @@ class Orchestrator:
|
||||
self.duplex_control_plane.dispatch(msg)
|
||||
elif msg_type == "abort":
|
||||
await self._handle_abort(msg)
|
||||
elif msg_type == "interaction":
|
||||
await self._handle_interaction(msg)
|
||||
elif msg_type == "collective_rpc":
|
||||
await self._handle_collective_rpc(msg)
|
||||
elif isinstance(msg, RegisterRemoteReplicaMessage):
|
||||
@@ -768,6 +771,44 @@ class Orchestrator:
|
||||
)
|
||||
logger.info("[Orchestrator] Aborted request(s) %s", request_ids)
|
||||
|
||||
async def _handle_interaction(self, msg: InteractionMessage) -> None:
|
||||
"""Handle a midway interaction for an active streaming diffusion request."""
|
||||
stage_id = 0
|
||||
request_id = msg.request_id
|
||||
event_id = msg.interaction.get("event_id")
|
||||
req_state = self.request_states.get(request_id)
|
||||
if req_state is None:
|
||||
logger.info("[Orchestrator] Dropping interaction for inactive req %s", request_id)
|
||||
await self.output_async_queue.put(
|
||||
ErrorMessage(
|
||||
error=f"No active request for interaction: {request_id}",
|
||||
fatal=False,
|
||||
request_id=request_id,
|
||||
event_id=event_id,
|
||||
stage_id=stage_id,
|
||||
)
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
await self.stage_pools[stage_id].submit_interaction(request_id, msg.interaction)
|
||||
except Exception as exc:
|
||||
logger.info(
|
||||
"[Orchestrator] Failed interaction for req %s: %s",
|
||||
request_id,
|
||||
exc,
|
||||
exc_info=True,
|
||||
)
|
||||
await self.output_async_queue.put(
|
||||
ErrorMessage(
|
||||
error=f"Failed interaction for request {request_id}: {exc}",
|
||||
fatal=False,
|
||||
request_id=request_id,
|
||||
event_id=event_id,
|
||||
stage_id=stage_id,
|
||||
)
|
||||
)
|
||||
|
||||
async def _abort_request_ids(self, request_ids: list[str]) -> None:
|
||||
"""Forward abort requests to all stage pools."""
|
||||
if not request_ids:
|
||||
|
||||
@@ -8,7 +8,12 @@ from typing import TYPE_CHECKING, Any, Protocol
|
||||
if TYPE_CHECKING:
|
||||
from vllm.v1.engine import EngineCoreOutput, EngineCoreOutputs, EngineCoreRequest
|
||||
|
||||
from vllm_omni.inputs.data import OmniDiffusionSamplingParams, OmniPromptType, OmniTokensPrompt
|
||||
from vllm_omni.inputs.data import (
|
||||
OmniDiffusionSamplingParams,
|
||||
OmniInteractionPrompt,
|
||||
OmniPromptType,
|
||||
OmniTokensPrompt,
|
||||
)
|
||||
from vllm_omni.outputs import OmniRequestOutput
|
||||
|
||||
from vllm_omni.inputs.data import OmniSamplingParams
|
||||
@@ -101,3 +106,10 @@ class StagePoolDiffusionClient(StagePoolClient, Protocol):
|
||||
) -> None: ...
|
||||
|
||||
def get_diffusion_output_nowait(self) -> OmniRequestOutput | None: ...
|
||||
|
||||
async def submit_interaction_async(
|
||||
self,
|
||||
request_id: str,
|
||||
interaction: OmniInteractionPrompt,
|
||||
timeout: float | None = None,
|
||||
) -> Any: ...
|
||||
@@ -24,7 +24,7 @@ from vllm_omni.engine.stage_client import (
|
||||
StagePoolDiffusionClient,
|
||||
StagePoolLLMClient,
|
||||
)
|
||||
from vllm_omni.inputs.data import OmniDiffusionSamplingParams
|
||||
from vllm_omni.inputs.data import OmniDiffusionSamplingParams, OmniInteractionPrompt
|
||||
from vllm_omni.metrics import (
|
||||
count_audio_frames,
|
||||
count_image_pixels,
|
||||
@@ -1048,6 +1048,24 @@ class StagePool:
|
||||
raise
|
||||
return replica_id
|
||||
|
||||
async def submit_interaction(
|
||||
self,
|
||||
request_id: str,
|
||||
interaction: OmniInteractionPrompt,
|
||||
) -> int:
|
||||
"""Submit a midway interaction to an active diffusion (typically video generation) request."""
|
||||
replica_id = self.get_bound_replica_id(request_id)
|
||||
if replica_id is None or self.clients[replica_id] is None:
|
||||
replica_id = await self._pick_or_select(request_id)
|
||||
|
||||
client = self._diffusion_client(replica_id)
|
||||
result = await client.submit_interaction_async(request_id, interaction)
|
||||
# Interaction may raise error if underlying check against ODConfig fails.
|
||||
if isinstance(result, dict) and result.get("error"):
|
||||
reason = result.get("reason") or "Unknown interaction RPC error"
|
||||
raise ValueError(str(reason))
|
||||
return replica_id
|
||||
|
||||
async def _pick_or_select(
|
||||
self,
|
||||
request_id: str,
|
||||
|
||||
Reference in new issue
Block a user