[Core][Frontend] Support request-level batching for diffusion pipelines (#4079)

Signed-off-by: jader <yjader@foxmail.com>
Co-authored-by: Samit <285365963@qq.com>
This commit is contained in:
JiangJie ZhangandSamit authored and GitHub committed 2026-06-29 18:09:19 +02:00
1 parent 504698dec8
commit c45ac74d43
123 files changed
+4160 -2233

No files matched your search

@@ -34,19 +34,19 @@ def _make_i2v_pipeline(*, expand_timesteps: bool) -> Wan22I2VPipeline:
def test_i2v_preprocess_requires_image_and_resizes_to_480p_aspect() -> None:
preprocess = get_wan22_i2v_pre_process_func(SimpleNamespace())
request = SimpleNamespace(
prompts=[{"prompt": "p", "multi_modal_data": {"image": Image.new("RGB", (320, 160), "red")}}],
prompt={"prompt": "p", "multi_modal_data": {"image": Image.new("RGB", (320, 160), "red")}},
sampling_params=SimpleNamespace(height=None, width=None),
)
result = preprocess(request)
prompt = result.prompts[0]
prompt = result.prompt
assert result.sampling_params.height == 432
assert result.sampling_params.width == 880
assert prompt["multi_modal_data"]["image"].size == (880, 432)
missing_image = SimpleNamespace(
prompts=[{"prompt": "p", "multi_modal_data": {}}],
prompt={"prompt": "p", "multi_modal_data": {}},
sampling_params=SimpleNamespace(height=None, width=None),
)
with pytest.raises(ValueError, match="No image is provided"):
@@ -100,7 +100,10 @@ def test_i2v_diffuse_selects_stage_guidance_and_expands_timesteps() -> None:
timestep_dtype = calls[0]["timestep_values"].dtype
torch.testing.assert_close(calls[0]["timestep_values"][0, :4], torch.zeros(4, dtype=timestep_dtype))
torch.testing.assert_close(calls[0]["timestep_values"][0, 4:], torch.full((4,), 900, dtype=timestep_dtype))
torch.testing.assert_close(calls[0]["hidden_states"][:, :, 0], torch.ones(1, 4, 4, 4))
torch.testing.assert_close(
calls[0]["hidden_states"][:, :, 0],
torch.ones_like(calls[0]["hidden_states"][:, :, 0]),
)
torch.testing.assert_close(result, torch.full_like(latents, 2.0))
@@ -9,6 +9,7 @@ import torch
from torch import nn
from vllm_omni.diffusion.models.wan2_2.pipeline_wan2_2 import Wan22Pipeline
from vllm_omni.diffusion.worker.request_batch import DiffusionRequestBatch
pytestmark = [pytest.mark.core_model, pytest.mark.cpu, pytest.mark.diffusion]
@@ -77,8 +78,9 @@ def test_forward_delegates_denoising_to_diffuse(monkeypatch) -> None:
pipeline.diffuse = _fake_diffuse # type: ignore[method-assign]
req = SimpleNamespace(
prompts=["prompt"],
mock_req = SimpleNamespace(
prompt="prompt",
request_id="test-req",
sampling_params=SimpleNamespace(
height=None,
width=None,
@@ -96,8 +98,9 @@ def test_forward_delegates_denoising_to_diffuse(monkeypatch) -> None:
extra_args={},
),
)
batch = DiffusionRequestBatch(requests=[mock_req])
output = pipeline.forward(req, prompt_embeds=prompt_embeds, output_type="latent", guidance_scale=1.0)
output = pipeline.forward(batch, prompt_embeds=prompt_embeds, output_type="latent", guidance_scale=1.0)
assert torch.equal(output.output, torch.ones((1, 4, 1, 8, 8)))
assert torch.equal(captured["timesteps"], pipeline.scheduler.timesteps)
@@ -38,21 +38,19 @@ def test_vace_preprocess_collects_reference_video_and_mask_inputs() -> None:
frame = Image.new("RGB", (64, 64), "black")
mask = Image.new("L", (64, 64), 255)
request = SimpleNamespace(
prompts=[
{
"prompt": "p",
"multi_modal_data": {
"image": ref,
"video": [frame],
"mask": mask,
},
}
],
prompt={
"prompt": "p",
"multi_modal_data": {
"image": ref,
"video": [frame],
"mask": mask,
},
},
sampling_params=SimpleNamespace(height=None, width=None),
)
result = preprocess(request)
additional_info = result.prompts[0]["additional_information"]
additional_info = result.prompt["additional_information"]
assert result.sampling_params.height == 432
assert result.sampling_params.width == 880