2026-05-08 14:12:23 +08:00
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
2026-08-17 11:21:28 +08:00
|
|
|
|
Online serving tests for ``Qwen/Qwen-Image-Edit-2511`` (image-to-image via chat completions).
|
2026-05-08 14:12:23 +08:00
|
|
|
|
|
2026-08-17 11:21:28 +08:00
|
|
|
|
- ``test_single_image_to_image_001``: one reference image, fixed 512×512.
|
|
|
|
|
|
- ``test_multi_images_to_image_001``: two reference images, fixed 512×512.
|
|
|
|
|
|
- ``test_different_sizes_001``: ``slow`` — mixed input resolutions; ``extra_body`` uses
|
|
|
|
|
|
per-output ``width``/``height`` lists; the test client sends one scalar-size request
|
|
|
|
|
|
per list index in parallel and merges images (see ``OpenAIClientHandler.send_diffusion_request``).
|
2026-05-08 14:12:23 +08:00
|
|
|
|
|
2026-08-17 11:21:28 +08:00
|
|
|
|
``_get_diffusion_feature_cases`` registers a single ``default`` ``OmniServerParams`` row.
|
2026-05-08 14:12:23 +08:00
|
|
|
|
|
|
|
|
|
|
From ``tests/``::
|
|
|
|
|
|
|
2026-08-17 11:21:28 +08:00
|
|
|
|
pytest -s -v e2e/online_serving/test_qwen_image_edit.py -m "slow and diffusion" --run-level=full_model
|
2026-05-08 14:12:23 +08:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
from tests.helpers.mark import hardware_marks
|
|
|
|
|
|
from tests.helpers.media import generate_synthetic_image
|
|
|
|
|
|
from tests.helpers.runtime import (
|
|
|
|
|
|
OmniServer,
|
|
|
|
|
|
OmniServerParams,
|
|
|
|
|
|
OpenAIClientHandler,
|
|
|
|
|
|
dummy_messages_from_mix_data,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-08-17 11:21:28 +08:00
|
|
|
|
MODEL = "Qwen/Qwen-Image-Edit-2511"
|
2026-05-08 14:12:23 +08:00
|
|
|
|
EDIT_PROMPT = "Transform this modern, geometrist image into a Vincent van Gogh style impressionist painting."
|
|
|
|
|
|
MULTI_EDIT_PROMPT = (
|
|
|
|
|
|
"Transform the first image into a Dadaism collage art. "
|
|
|
|
|
|
"Transform the second image into a Vincent van Gogh style painting. "
|
|
|
|
|
|
"Then juxtapose the two transformed images into a single artwork for visual contrast."
|
|
|
|
|
|
)
|
|
|
|
|
|
NEGATIVE_PROMPT = "blurry, low quality, modern, geometrist"
|
|
|
|
|
|
SINGLE_CARD_FEATURE_MARKS = hardware_marks(res={"cuda": "H100"})
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-08-17 11:21:28 +08:00
|
|
|
|
def _get_diffusion_feature_cases(model: str = MODEL):
|
2026-05-08 14:12:23 +08:00
|
|
|
|
"""Return one ``default`` ``OmniServerParams`` row for ``model`` (no extra ``server_args``)."""
|
|
|
|
|
|
return [
|
|
|
|
|
|
pytest.param(
|
|
|
|
|
|
OmniServerParams(
|
|
|
|
|
|
model=model,
|
|
|
|
|
|
),
|
|
|
|
|
|
id="default",
|
|
|
|
|
|
marks=SINGLE_CARD_FEATURE_MARKS,
|
|
|
|
|
|
),
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-08-15 12:01:20 +08:00
|
|
|
|
@pytest.mark.slow
|
2026-05-08 14:12:23 +08:00
|
|
|
|
@pytest.mark.diffusion
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"omni_server",
|
2026-08-17 11:21:28 +08:00
|
|
|
|
_get_diffusion_feature_cases(),
|
2026-05-08 14:12:23 +08:00
|
|
|
|
indirect=True,
|
|
|
|
|
|
)
|
|
|
|
|
|
def test_single_image_to_image_001(omni_server: OmniServer, openai_client: OpenAIClientHandler):
|
2026-08-17 11:21:28 +08:00
|
|
|
|
"""Single-reference edit smoke for ``Qwen/Qwen-Image-Edit-2511`` (CFG when negative prompt + ``true_cfg_scale`` > 1)."""
|
2026-05-08 14:12:23 +08:00
|
|
|
|
image_data_url = f"data:image/jpeg;base64,{generate_synthetic_image(512, 512)['base64']}"
|
|
|
|
|
|
|
|
|
|
|
|
messages = dummy_messages_from_mix_data(image_data_url=image_data_url, content_text=EDIT_PROMPT)
|
|
|
|
|
|
|
|
|
|
|
|
# CFG parallel is only activated when a negative prompt and true_cfg_scale > 1.0 are both present
|
|
|
|
|
|
request_config = {
|
|
|
|
|
|
"model": omni_server.model,
|
|
|
|
|
|
"messages": messages,
|
|
|
|
|
|
"extra_body": {
|
|
|
|
|
|
"height": 512,
|
|
|
|
|
|
"width": 512,
|
|
|
|
|
|
"num_inference_steps": 2,
|
|
|
|
|
|
"negative_prompt": NEGATIVE_PROMPT,
|
|
|
|
|
|
"true_cfg_scale": 4.0,
|
|
|
|
|
|
"seed": 42,
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
openai_client.send_diffusion_request(request_config)
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-08-15 12:01:20 +08:00
|
|
|
|
@pytest.mark.slow
|
2026-05-08 14:12:23 +08:00
|
|
|
|
@pytest.mark.diffusion
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"omni_server",
|
2026-08-17 11:21:28 +08:00
|
|
|
|
_get_diffusion_feature_cases(),
|
2026-05-08 14:12:23 +08:00
|
|
|
|
indirect=True,
|
|
|
|
|
|
)
|
|
|
|
|
|
def test_multi_images_to_image_001(omni_server: OmniServer, openai_client: OpenAIClientHandler):
|
2026-05-28 18:33:31 +08:00
|
|
|
|
"""Two-reference edit smoke for ``Qwen/Qwen-Image-Edit-2511``."""
|
2026-05-08 14:12:23 +08:00
|
|
|
|
|
|
|
|
|
|
image_data_url_list = [f"data:image/jpeg;base64,{generate_synthetic_image(512, 512)['base64']}" for _ in range(2)]
|
|
|
|
|
|
|
|
|
|
|
|
messages = dummy_messages_from_mix_data(image_data_url=image_data_url_list, content_text=MULTI_EDIT_PROMPT)
|
|
|
|
|
|
|
|
|
|
|
|
# CFG parallel is only activated when a negative prompt and true_cfg_scale > 1.0 are both present
|
|
|
|
|
|
request_config = {
|
|
|
|
|
|
"model": omni_server.model,
|
|
|
|
|
|
"messages": messages,
|
|
|
|
|
|
"extra_body": {
|
|
|
|
|
|
"height": 512,
|
|
|
|
|
|
"width": 512,
|
|
|
|
|
|
"num_inference_steps": 2,
|
|
|
|
|
|
"negative_prompt": NEGATIVE_PROMPT,
|
|
|
|
|
|
"true_cfg_scale": 4.0,
|
|
|
|
|
|
"seed": 42,
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
openai_client.send_diffusion_request(request_config)
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-08-15 12:01:20 +08:00
|
|
|
|
@pytest.mark.slow
|
2026-05-08 14:12:23 +08:00
|
|
|
|
@pytest.mark.diffusion
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
|
"omni_server",
|
2026-08-17 11:21:28 +08:00
|
|
|
|
_get_diffusion_feature_cases(),
|
2026-05-08 14:12:23 +08:00
|
|
|
|
indirect=True,
|
|
|
|
|
|
)
|
|
|
|
|
|
def test_different_sizes_001(omni_server: OmniServer, openai_client: OpenAIClientHandler):
|
|
|
|
|
|
"""Multi-reference edit with distinct input resolutions; per-output ``width``/``height`` as lists (client splits into concurrent scalar-size calls)."""
|
|
|
|
|
|
image_data_url_list = [
|
|
|
|
|
|
f"data:image/jpeg;base64,{generate_synthetic_image(512, 512)['base64']}",
|
|
|
|
|
|
f"data:image/jpeg;base64,{generate_synthetic_image(384, 256)['base64']}",
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
messages = dummy_messages_from_mix_data(image_data_url=image_data_url_list, content_text=MULTI_EDIT_PROMPT)
|
|
|
|
|
|
|
|
|
|
|
|
# List height/width: client sends 512×512 and 768×512 in parallel, merges to two images; assertions use lists.
|
|
|
|
|
|
request_config = {
|
|
|
|
|
|
"model": omni_server.model,
|
|
|
|
|
|
"messages": messages,
|
|
|
|
|
|
"extra_body": {
|
|
|
|
|
|
"height": [512, 768],
|
|
|
|
|
|
"width": [512, 512],
|
|
|
|
|
|
"num_inference_steps": 2,
|
|
|
|
|
|
"negative_prompt": NEGATIVE_PROMPT,
|
|
|
|
|
|
"true_cfg_scale": 4.0,
|
|
|
|
|
|
"seed": 42,
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
openai_client.send_diffusion_request(request_config)
|