[Bugfix] Avoid multimodal cache collisions in multistage image editing (#7817)

Signed-off-by: princepride <wangzhipeng628@gmail.com>
This commit is contained in:
汪志鹏 authored and GitHub committed 2026-09-20 11:27:06 +08:00
1 parent b6b868f3de
commit 8e10c3ee07
2 files changed
+29 -7

No files matched your search

@@ -1,4 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""Regression tests for multistage generation input construction."""
from __future__ import annotations
@@ -94,6 +95,34 @@ def test_build_multistage_generation_inputs_applies_stage_specific_overrides(ser
assert engine.default_sampling_params_list[2].lora_request is None
@pytest.mark.parametrize("extra_body", [{}, {"bot_task": "think"}])
def test_build_multistage_generation_inputs_leaves_mm_uuids_to_content_hash(serving_chat, extra_body):
"""Fixed image UUIDs collide across requests with the same processor kwargs.
Leave UUID generation to vLLM so cache keys depend on image content.
"""
from vllm_omni.entrypoints.openai.serving_chat import OmniOpenAIServingChat
engine = SimpleNamespace(
stage_configs=[
SimpleNamespace(stage_type="llm", is_comprehension=True),
SimpleNamespace(stage_type="diffusion", is_comprehension=False),
],
default_sampling_params_list=[SamplingParams(temperature=0.0), OmniDiffusionSamplingParams()],
)
for images in ([Image.new("RGB", (32, 32), color="red")], [Image.new("RGB", (32, 32), c) for c in ("red", "blue")]):
engine_prompt, _ = OmniOpenAIServingChat._build_multistage_generation_inputs(
serving_chat,
engine=engine,
prompt="edit me",
extra_body=dict(extra_body),
reference_images=images,
gen_params=OmniDiffusionSamplingParams(seed=0),
)
assert engine_prompt["multi_modal_data"]
assert "multi_modal_uuids" not in engine_prompt
def test_prepare_multistage_multimodal_inputs_defers_downstream_modalities(serving_chat):
from vllm_omni.entrypoints.openai.serving_chat import OmniOpenAIServingChat
@@ -3142,13 +3142,6 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
engine_prompt["mm_processor_kwargs"] = mm_processor_kwargs
if engine_prompt_data is not None:
engine_prompt["multi_modal_data"] = engine_prompt_data
# Provide multi_modal_uuids so that newer vLLM versions can
# validate multi_modal_data / multi_modal_uuids consistency.
# Generate one uuid per image when the value is a list (multi-image inputs).
engine_prompt["multi_modal_uuids"] = {
k: [f"img-{k}-{i}" for i in range(len(v))] if isinstance(v, list) else [f"img-{k}-0"]
for k, v in engine_prompt_data.items()
}
comprehension_idx = None
for idx, stage in enumerate(stage_configs):