[Refactor][OutputProcessor 2/8]: OmniRequestOutput should inherit RequestOutput and no nested wrap-up (#5146)
Signed-off-by: Boao Shi <aoibosh@connect.hku.hk> Signed-off-by: bowieshi <aoibosh@connect.hku.hk> Signed-off-by: princepride <wangzhipeng628@gmail.com> Signed-off-by: R2-Y <ruiruyang2@gmail.com> Signed-off-by: amy-why-3459 <wuhaiyan17@huawei.com> Signed-off-by: Shi Boao Bowie <aoibosh@connect.hku.hk> Co-authored-by: 汪志鹏 <wangzhipeng628@gmail.com> Co-authored-by: ruirui(rein) yang <73573651+R2-Y@users.noreply.github.com> Co-authored-by: amy-why-3459 <wuhaiyan17@huawei.com> Co-authored-by: Gao Han <hgaoaf@connect.ust.hk> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
89 files changed
+944
-639
No files matched your search
@@ -1468,7 +1468,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
try:
|
||||
async for omni_res in result_generator:
|
||||
final_output_type = omni_res.final_output_type
|
||||
res = omni_res.request_output
|
||||
res = omni_res
|
||||
if final_output_type not in first_iteration_dict:
|
||||
logger.warning(f"final output type: {final_output_type} is not needed by the request")
|
||||
continue
|
||||
@@ -2338,7 +2338,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
|
||||
for omni_outputs in final_outputs:
|
||||
choices_data = []
|
||||
if omni_outputs.request_output is not None and not getattr(omni_outputs.request_output, "finished", False):
|
||||
if not omni_outputs.finished:
|
||||
continue
|
||||
|
||||
# Filter outputs based on requested modalites
|
||||
@@ -2347,7 +2347,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
continue
|
||||
|
||||
if omni_outputs.final_output_type == "text":
|
||||
if omni_outputs.request_output is not None:
|
||||
if omni_outputs.stage_id is not None or omni_outputs.outputs:
|
||||
(
|
||||
choices_data,
|
||||
usage,
|
||||
@@ -2362,7 +2362,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
role,
|
||||
reasoning_parser,
|
||||
)
|
||||
final_res = omni_outputs.request_output
|
||||
final_res = omni_outputs
|
||||
else:
|
||||
# Diffusion pipeline text output (e.g. single-stage
|
||||
# img2text / text2text) — no AR request_output, so build
|
||||
@@ -2463,7 +2463,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
role: str,
|
||||
reasoning_parser: ReasoningParser | None = None,
|
||||
):
|
||||
final_res = omni_outputs.request_output
|
||||
final_res = omni_outputs
|
||||
if self.tool_call_id_type == "kimi_k2":
|
||||
history_tool_call_cnt = get_history_tool_calls_cnt(conversation)
|
||||
else:
|
||||
@@ -2711,7 +2711,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
self, omni_outputs: OmniRequestOutput, role: str, request: ChatCompletionRequest, stream: bool = False
|
||||
) -> list[ChatCompletionResponseChoice] | list[ChatCompletionResponseStreamChoice] | ErrorResponse:
|
||||
choices: list[ChatCompletionResponseChoice] = []
|
||||
final_res = omni_outputs.request_output
|
||||
final_res = omni_outputs
|
||||
# OMNI: Access multimodal_output from CompletionOutput (outputs[0]), not from RequestOutput
|
||||
# Reference: examples/offline_inference/qwen3_omni/end2end.py line 421
|
||||
# The attribute is attached dynamically when stage audio arrives; fall
|
||||
@@ -2834,7 +2834,6 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
from PIL import Image
|
||||
|
||||
choices: list[ChatCompletionResponseChoice] = []
|
||||
final_res = omni_outputs.request_output
|
||||
|
||||
# Handle profiling data
|
||||
stage_durations = omni_outputs.stage_durations
|
||||
@@ -2846,10 +2845,11 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
# First check omni_outputs.images directly (for diffusion mode via from_diffusion)
|
||||
if omni_outputs.images:
|
||||
images = omni_outputs.images
|
||||
# Fall back to request_output for pipeline mode
|
||||
# OMNI: Access multimodal_output from CompletionOutput (outputs[0]), not from RequestOutput
|
||||
elif final_res is not None and final_res.outputs:
|
||||
completion_output = final_res.outputs[0]
|
||||
# Fall back to completion outputs for pipeline mode (multimodal_output
|
||||
# is attached to CompletionOutput by AR stages).
|
||||
elif omni_outputs.outputs:
|
||||
completion_output = omni_outputs.outputs[0]
|
||||
final_res = omni_outputs
|
||||
if hasattr(completion_output, "multimodal_output") and completion_output.multimodal_output:
|
||||
image_data = completion_output.multimodal_output.get("image")
|
||||
if image_data is not None:
|
||||
@@ -3311,12 +3311,12 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
request_id=request_id,
|
||||
)
|
||||
|
||||
images = getattr(result.request_output, "images", [])
|
||||
images = getattr(result, "images", [])
|
||||
stage_durations = result.stage_durations
|
||||
peak_memory_mb = result.peak_memory_mb
|
||||
cot_output = None
|
||||
|
||||
req_out = getattr(result, "request_output", None)
|
||||
req_out = result
|
||||
if req_out:
|
||||
prompt_obj = getattr(req_out, "prompt", None)
|
||||
if isinstance(prompt_obj, dict):
|
||||
@@ -3326,7 +3326,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
if isinstance(ar_text, str) and ar_text.strip():
|
||||
cot_output = ar_text
|
||||
|
||||
req_out = getattr(result, "request_output", None)
|
||||
req_out = result
|
||||
if req_out:
|
||||
prompt_obj = getattr(req_out, "prompt", None)
|
||||
if isinstance(prompt_obj, dict):
|
||||
@@ -3336,7 +3336,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
if isinstance(ar_text, str) and ar_text.strip():
|
||||
cot_output = ar_text
|
||||
|
||||
req_out = getattr(result, "request_output", None)
|
||||
req_out = result
|
||||
if req_out:
|
||||
prompt_obj = getattr(req_out, "prompt", None)
|
||||
if isinstance(prompt_obj, dict):
|
||||
@@ -3368,8 +3368,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
stage_id = getattr(output, "stage_id", None)
|
||||
metrics = getattr(output, "metrics", None) if return_stage_metrics else None
|
||||
if final_output_type == "text" and stage_id == 0:
|
||||
request_output = output.request_output
|
||||
for completion in request_output.outputs:
|
||||
for completion in output.outputs:
|
||||
text = completion.text or ""
|
||||
if not text:
|
||||
continue
|
||||
@@ -3382,7 +3381,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
)
|
||||
yield f"data: {chunk.model_dump_json()}\n\n"
|
||||
elif final_output_type == "image":
|
||||
images = self._flatten_diffusion_images(getattr(output.request_output, "images", []))
|
||||
images = self._flatten_diffusion_images(getattr(output, "images", []))
|
||||
if not images:
|
||||
raise RuntimeError("Streaming image edit produced an empty final image output.")
|
||||
image_data = [
|
||||
@@ -3686,8 +3685,7 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
|
||||
# Image output path (text2img / img2img)
|
||||
final_output_type = getattr(result, "final_output_type", "image")
|
||||
# Handle nested OmniRequestOutput structure where images might be in request_output
|
||||
images = getattr(result.request_output, "images", [])
|
||||
images = getattr(result, "images", [])
|
||||
multimodal_output = getattr(result, "multimodal_output", {}) or {}
|
||||
stage_durations = result.stage_durations
|
||||
peak_memory_mb = result.peak_memory_mb
|
||||
|
||||
Reference in new issue
Block a user