Skip to content

[Bugfix] diffusion end points allow model mismatch#2805

Merged
lishunyang12 merged 7 commits intovllm-project:mainfrom
xiaohajiayou:bugfix/image-model-mismatch-400
Apr 19, 2026
Merged

[Bugfix] diffusion end points allow model mismatch#2805
lishunyang12 merged 7 commits intovllm-project:mainfrom
xiaohajiayou:bugfix/image-model-mismatch-400

Conversation

@xiaohajiayou
Copy link
Copy Markdown
Contributor

@xiaohajiayou xiaohajiayou commented Apr 15, 2026

Purpose

Fix #2804

Return HTTP 400 when the request model does not match the served model for:

  • /v1/images/generations
  • /v1/images/edits
  • video generation requests handled by the OpenAI-compatible API

Previously, these paths only logged a warning and silently used the server model, which is inconsistent with the documented error behavior for invalid parameters such as model mismatch.

Changes

  • Update /v1/images/generations to raise HTTPException(400) on model mismatch
  • Update /v1/images/edits to raise HTTPException(400) on model mismatch
  • Update video request parsing to raise HTTPException(400) on model mismatch
  • Remove the previous warning-only fallback behavior for these endpoints

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan. Please provide the test scripts & test commands. Please state the reasons if your codes don't require additional test scripts. For test file guidelines, please check the test style doc
  • The test results. Please paste the results comparison before and after, or the e2e results.
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model. Please run mkdocs serve to sync the documentation editions to ./docs.
  • (Optional) Release notes update. If your change is user-facing, please update the release notes draft.

BEFORE SUBMITTING, PLEASE READ https://github.com/vllm-project/vllm-omni/blob/main/CONTRIBUTING.md (anything written below this line will be removed by GitHub Actions)

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@xiaohajiayou xiaohajiayou force-pushed the bugfix/image-model-mismatch-400 branch 4 times, most recently from 4c0aa85 to d071f32 Compare April 15, 2026 02:12
Signed-off-by: xiaohajiayou <923390377@qq.com>
Copy link
Copy Markdown
Collaborator

@lishunyang12 lishunyang12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR correctly changes three diffusion endpoints from logging a warning on model mismatch to raising HTTPException(400). The change aligns these endpoints with the existing behavior in serving_chat.py and serving_speech.py, and with what the API docs already promise.

Correctness

The logic is straightforward and correct across all three sites:

  1. /v1/images/generations - Replaces logger.warning + silent fallback with raise HTTPException(400). The stale comment # Validate model field (warn if mismatch, don't error) is properly removed.
  2. /v1/images/edits - Same pattern, same fix.
  3. _parse_video_form - The raise happens inside a try block that already has except HTTPException: raise, so the new exception propagates correctly without being swallowed by the generic except Exception handler below it.

Error messages are clear and consistent across all three sites. Using HTTPStatus.BAD_REQUEST.value is consistent with the rest of the file.

Tests

Test coverage looks good: one test per endpoint (test_generate_images_rejects_model_mismatch, test_image_edit_rejects_model_mismatch, test_video_generation_rejects_model_mismatch), each asserting both the 400 status code and the presence of "model mismatch" in the error detail. The assertions use .lower() which makes them resilient to casing changes.

Minor Observations (non-blocking)

  • The parentheses around the f-string in detail=(f"Model mismatch: ...") are unnecessary (single expression, not a tuple), but this is purely cosmetic and not worth a revision.

LGTM. Clean, minimal, well-tested fix that resolves a real behavioral inconsistency.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes #2804 by making diffusion-oriented OpenAI-compatible endpoints reject requests whose model does not match the server’s served model, aligning behavior with existing chat/speech paths and the image API docs (400 on invalid params) instead of silently falling back.

Changes:

  • /v1/images/generations: raise HTTP 400 on request.model mismatch vs served model.
  • /v1/images/edits: raise HTTP 400 on model form field mismatch vs served model.
  • Video form parsing for /v1/videos + /v1/videos/sync: raise HTTP 400 on request.model mismatch.
  • Added regression tests asserting 400 + “model mismatch” detail for image + video endpoints.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
vllm_omni/entrypoints/openai/api_server.py Enforces model mismatch validation (HTTP 400) for image generation/edit and video request parsing.
tests/entrypoints/openai_api/test_video_server.py Adds test ensuring video generation rejects model mismatch with HTTP 400.
tests/entrypoints/openai_api/test_image_server.py Adds tests ensuring image generation and image edits reject model mismatch with HTTP 400.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@SamitHuang SamitHuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflicts to be fixed, otherwise LGTM

@lishunyang12 lishunyang12 added the ready label to trigger buildkite CI label Apr 18, 2026
@xiaohajiayou
Copy link
Copy Markdown
Contributor Author

xiaohajiayou commented Apr 19, 2026

@lishunyang12 @hsliuustc0106 Could you please take a look if we can merge this?

@lishunyang12 lishunyang12 merged commit 93beef1 into vllm-project:main Apr 19, 2026
8 checks passed
lvliang-intel pushed a commit to lvliang-intel/vllm-omni that referenced this pull request Apr 20, 2026
Signed-off-by: xiaohajiayou <923390377@qq.com>
Signed-off-by: Samit <285365963@qq.com>
Co-authored-by: Samit <285365963@qq.com>
Co-authored-by: SYLAR <125541396+lishunyang12@users.noreply.github.com>
qinganrice pushed a commit to qinganrice/vllm-omni that referenced this pull request Apr 23, 2026
Signed-off-by: xiaohajiayou <923390377@qq.com>
Signed-off-by: Samit <285365963@qq.com>
Co-authored-by: Samit <285365963@qq.com>
Co-authored-by: SYLAR <125541396+lishunyang12@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready label to trigger buildkite CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: diffusion end points allow model mismatch

4 participants