fix(diffusion): enforce strict input_reference validation for T2V (#14825)
Co-authored-by: Xiaoyu Zhang <35585791+BBuf@users.noreply.github.com>
This commit is contained in:
@@ -330,6 +330,13 @@ class SamplingParams:
|
||||
f"Served model with task type '{pipeline_config.task_type.name}' requires an 'image_path' input, but none was provided"
|
||||
)
|
||||
|
||||
if not pipeline_config.task_type.accepts_image_input():
|
||||
# does not support image input
|
||||
if self.image_path is not None:
|
||||
raise ValueError(
|
||||
f"input_reference is not supported for {pipeline_config.task_type.name} models."
|
||||
)
|
||||
|
||||
def _adjust(
|
||||
self,
|
||||
server_args,
|
||||
|
||||
@@ -140,7 +140,6 @@ async def _dispatch_job_async(job_id: str, batch: Req) -> None:
|
||||
|
||||
|
||||
# TODO: support image to video generation
|
||||
# TODO: this is currently not used
|
||||
@router.post("", response_model=VideoResponse)
|
||||
async def create_video(
|
||||
request: Request,
|
||||
@@ -261,7 +260,11 @@ async def create_video(
|
||||
|
||||
logger.debug(f"Server received from create_video endpoint: req={req}")
|
||||
|
||||
sampling_params = _build_video_sampling_params(request_id, req)
|
||||
try:
|
||||
sampling_params = _build_video_sampling_params(request_id, req)
|
||||
except (ValueError, TypeError) as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
|
||||
job = _video_job_from_sampling(request_id, req, sampling_params)
|
||||
await VIDEO_STORE.upsert(request_id, job)
|
||||
|
||||
|
||||
@@ -711,6 +711,37 @@ Consider updating perf_baselines.json with the snippets below:
|
||||
|
||||
logger.info("[Models API] All /v1/models tests passed for %s", case.id)
|
||||
|
||||
def _test_t2v_rejects_input_reference(
|
||||
self, ctx: ServerContext, case: DiffusionTestCase
|
||||
) -> None:
|
||||
if case.server_args.modality != "video":
|
||||
return
|
||||
|
||||
base_url = f"http://localhost:{ctx.port}"
|
||||
resp = requests.get(f"{base_url}/v1/models")
|
||||
assert resp.status_code == 200, f"/v1/models failed: {resp.text}"
|
||||
data = resp.json().get("data", [])
|
||||
if not data:
|
||||
pytest.fail("/v1/models returned empty model list")
|
||||
|
||||
task_type = data[0].get("task_type")
|
||||
if task_type != "T2V":
|
||||
return
|
||||
|
||||
prompt = case.sampling_params.prompt or "test"
|
||||
payload = {"prompt": prompt, "input_reference": "dummy"}
|
||||
if case.sampling_params.output_size:
|
||||
payload["size"] = case.sampling_params.output_size
|
||||
|
||||
resp = requests.post(f"{base_url}/v1/videos", json=payload)
|
||||
assert (
|
||||
resp.status_code == 400
|
||||
), f"Expected 400 for T2V input_reference, got {resp.status_code}: {resp.text}"
|
||||
detail = resp.json().get("detail", "")
|
||||
assert (
|
||||
"input_reference is not supported" in detail
|
||||
), f"Unexpected error detail for T2V input_reference: {detail}"
|
||||
|
||||
def test_diffusion_perf(
|
||||
self,
|
||||
case: DiffusionTestCase,
|
||||
@@ -744,6 +775,7 @@ Consider updating perf_baselines.json with the snippets below:
|
||||
|
||||
# Test /v1/models endpoint for router compatibility
|
||||
self._test_v1_models_endpoint(diffusion_server, case)
|
||||
self._test_t2v_rejects_input_reference(diffusion_server, case)
|
||||
|
||||
# LoRA API functionality test with E2E validation (only for LoRA-enabled cases)
|
||||
if case.server_args.lora_path or case.server_args.dynamic_lora_path:
|
||||
|
||||
Reference in New Issue
Block a user