[Diffusion][HunyuanImage3] Add request paged prefix caching (#7719)
Signed-off-by: zwhzzz0821 <2831474076@qq.com>
This commit is contained in:
1 parent
9a1a05facd
commit
205aa01c7b
49 files changed
+2889
-127
No files matched your search
@@ -9,6 +9,7 @@ import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
from PIL import Image
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.diffusion, pytest.mark.cpu]
|
||||
@@ -311,7 +312,8 @@ def test_trajectory_judge_payload_collapses_six_frames_into_single_storyboard():
|
||||
assert judge_images[0].size == (24, 12)
|
||||
|
||||
|
||||
def test_image_edit_client_uses_openai_image_edit_endpoint(monkeypatch):
|
||||
@pytest.mark.parametrize("num_images", [1, 2])
|
||||
def test_image_edit_client_uses_openai_image_edit_endpoint(monkeypatch, num_images):
|
||||
captured = {}
|
||||
|
||||
class FakeResponse:
|
||||
@@ -344,16 +346,46 @@ def test_image_edit_client_uses_openai_image_edit_endpoint(monkeypatch):
|
||||
output = client.generate_image_edit(
|
||||
model="Qwen/Qwen-Image-Edit",
|
||||
prompt="edit this image",
|
||||
images=image,
|
||||
images=image if num_images == 1 else [image] * num_images,
|
||||
width=512,
|
||||
height=512,
|
||||
guidance_scale=2.5,
|
||||
seed=42,
|
||||
bot_task="think_recaption",
|
||||
sys_type="en_unified",
|
||||
)
|
||||
|
||||
assert output.size == (1, 1)
|
||||
assert captured["url"] == "http://127.0.0.1:8093/v1/images/edits"
|
||||
assert captured["data"]["prompt"] == "edit this image"
|
||||
assert captured["data"]["size"] == "512x512"
|
||||
assert captured["files"][0][0] == "image"
|
||||
assert len(captured["files"]) == num_images
|
||||
assert all(field == ("image" if num_images == 1 else "image[]") for field, _ in captured["files"])
|
||||
assert captured["data"]["guidance_scale"] == "2.5"
|
||||
assert captured["data"]["seed"] == "42"
|
||||
assert captured["data"]["bot_task"] == "think_recaption"
|
||||
assert captured["data"]["sys_type"] == "en_unified"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("status_code", [400, 500])
|
||||
def test_image_edit_client_preserves_server_error_detail(mocker, status_code):
|
||||
response = requests.Response()
|
||||
response.status_code = status_code
|
||||
response._content = b'{"error": "image input limit exceeded"}'
|
||||
post = mocker.patch("benchmarks.accuracy.common.requests.post", return_value=response)
|
||||
client = VllmOmniImageClient(base_url="http://127.0.0.1:8093")
|
||||
|
||||
with pytest.raises(requests.HTTPError, match="image input limit exceeded") as exc:
|
||||
client.generate_image_edit(
|
||||
model="test-model",
|
||||
prompt="edit this image",
|
||||
images=Image.new("RGB", (2, 2)),
|
||||
width=512,
|
||||
height=512,
|
||||
)
|
||||
|
||||
assert exc.value.response is response
|
||||
post.assert_called_once()
|
||||
|
||||
|
||||
def test_text_to_image_client_forwards_output_compression(monkeypatch):
|
||||
|
||||
@@ -6,6 +6,7 @@ import json
|
||||
import os
|
||||
import subprocess
|
||||
import textwrap
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -21,6 +22,76 @@ from vllm_omni.utils.tracking_parser import TrackingArgumentParser
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu, pytest.mark.benchmark]
|
||||
|
||||
|
||||
def test_it2i_dataset_uses_upstream_warmups(monkeypatch, tmp_path):
|
||||
"""Exercise real dataset/benchmark code; replace only the HTTP backend."""
|
||||
from vllm_omni.benchmarks import serve
|
||||
from vllm_omni.benchmarks.patch import patch
|
||||
from vllm_omni.entrypoints.cli.benchmark.serve import OmniBenchmarkServingSubcommand
|
||||
|
||||
dataset_path = Path(__file__).parents[1] / "assets/hunyuan_image3/it2i.jsonl"
|
||||
sample = json.loads(dataset_path.read_text(encoding="utf-8"))
|
||||
parser = argparse.ArgumentParser()
|
||||
OmniBenchmarkServingSubcommand.add_cli_args(parser)
|
||||
args = parser.parse_args(
|
||||
[
|
||||
"--model",
|
||||
"test-model",
|
||||
"--endpoint",
|
||||
"/v1/images/edits",
|
||||
"--dataset-name",
|
||||
"custom_image",
|
||||
"--dataset-path",
|
||||
str(dataset_path),
|
||||
"--skip-tokenizer-init",
|
||||
"--disable-shuffle",
|
||||
"--disable-tqdm",
|
||||
"--num-prompts",
|
||||
"8",
|
||||
"--num-warmups",
|
||||
"2",
|
||||
"--max-concurrency",
|
||||
"1",
|
||||
"--ready-check-timeout-sec",
|
||||
"0",
|
||||
"--percentile-metrics",
|
||||
"e2el",
|
||||
"--extra-body",
|
||||
'{"seed":42,"guidance_scale":2.5,"bot_task":"think_recaption"}',
|
||||
"--save-result",
|
||||
"--result-dir",
|
||||
str(tmp_path),
|
||||
"--result-filename",
|
||||
"result.json",
|
||||
]
|
||||
)
|
||||
requests = []
|
||||
|
||||
async def request_func(request_func_input, session, pbar=None):
|
||||
requests.append(request_func_input)
|
||||
if pbar is not None:
|
||||
pbar.update(1)
|
||||
return patch.MixRequestFuncOutput(
|
||||
success=True,
|
||||
prompt_len=1,
|
||||
output_tokens=1,
|
||||
image_count=1,
|
||||
start_time=time.perf_counter(),
|
||||
latency=99.0 if len(requests) <= 2 else 0.1,
|
||||
)
|
||||
|
||||
monkeypatch.setitem(patch.ASYNC_REQUEST_FUNCS, "/v1/images/edits", request_func)
|
||||
result = serve.main(args)
|
||||
assert len(requests) == 10
|
||||
for request in requests:
|
||||
assert request.prompt == sample["prompt"]
|
||||
assert [image["image_url"]["url"] for image in request.multi_modal_content] == sample["image_files"]
|
||||
assert request.extra_body == args.extra_body
|
||||
assert result["completed"] == 8
|
||||
saved = json.loads((tmp_path / "result.json").read_text())
|
||||
assert saved["completed"] == 8
|
||||
assert saved["mean_e2el_ms"] == pytest.approx(100.0) # Excludes both 99-second warmups.
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"dataset_name",
|
||||
[
|
||||
|
||||
Reference in new issue
Block a user