-
Notifications
You must be signed in to change notification settings - Fork 1k
[Bugfix] Limit Qwen-Image-Edit-2511 input image count #2840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hsliuustc0106
merged 18 commits into
vllm-project:main
from
david6666666:codex/issue-2793-qwen-image-edit-oom
Apr 17, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0e2f009
Fix Qwen image edit plus prompt encoding memory
david6666666 eec0785
Clamp Qwen image edit plus prompt length
david6666666 72af603
Limit Qwen image edit plus input images
david6666666 f1900fe
Translate omni image edit input errors
david6666666 c95d20c
Validate image edit limits in API layer
david6666666 731c536
Refine image edit input limit helpers
david6666666 8c857c3
Simplify image edit input limit helper
david6666666 0c25a06
Wrap image edit limit error message
david6666666 826c74a
Use model-specific image edit limits
david6666666 297d06b
Reject over-limit image edits before loading
david6666666 4ea2271
Document image edit limit handling
david6666666 f414061
[Fix] Make image edit input limits config-driven
david6666666 05a7a5d
[Refactor] Move diffusion image limits into shared metadata
david6666666 f3e7ce9
[Fix] Apply pre-commit import ordering
david6666666 3015646
[Docs] Clarify shared diffusion image limit metadata
david6666666 ddca44b
Merge branch 'main' into codex/issue-2793-qwen-image-edit-oom
david6666666 a6ee807
Merge branch 'main' into codex/issue-2793-qwen-image-edit-oom
Gaohan123 8e257fa
Merge branch 'main' into codex/issue-2793-qwen-image-edit-oom
david6666666 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
tests/diffusion/models/qwen_image/test_qwen_image_edit_plus.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
| from types import SimpleNamespace | ||
|
|
||
| import numpy as np | ||
| import pytest | ||
| from PIL import Image | ||
|
|
||
| from vllm_omni.diffusion.models.qwen_image.pipeline_qwen_image_edit_plus import ( | ||
| get_qwen_image_edit_plus_pre_process_func, | ||
| ) | ||
|
|
||
| pytestmark = [pytest.mark.core_model, pytest.mark.diffusion, pytest.mark.cpu] | ||
|
|
||
|
|
||
| def test_qwen_image_edit_plus_rejects_too_many_input_images(tmp_path: Path): | ||
| vae_dir = tmp_path / "vae" | ||
| vae_dir.mkdir() | ||
| # Keep the mock config intentionally minimal: this test only needs the | ||
| # fields touched during pre-process initialization. | ||
| (vae_dir / "config.json").write_text(json.dumps({"z_dim": 16})) | ||
|
|
||
| pre_process = get_qwen_image_edit_plus_pre_process_func(SimpleNamespace(model=str(tmp_path))) | ||
| image = Image.fromarray(np.zeros((32, 32, 3), dtype=np.uint8)) | ||
| request = SimpleNamespace( | ||
| prompts=[ | ||
| { | ||
| "prompt": "combine", | ||
| "multi_modal_data": {"image": [image, image, image, image, image]}, | ||
| } | ||
| ], | ||
| sampling_params=SimpleNamespace(height=None, width=None), | ||
| ) | ||
|
|
||
| with pytest.raises(ValueError, match=r"At most 4 images are supported by this model"): | ||
| pre_process(request) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| from dataclasses import dataclass | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class DiffusionModelMetadata: | ||
| # Keep serving-facing capability metadata in a lightweight shared module so | ||
| # config/model plumbing can read it without importing concrete pipelines. | ||
| supports_multimodal_inputs: bool = False | ||
| max_multimodal_image_inputs: int | None = None | ||
|
|
||
|
|
||
| QWEN_IMAGE_EDIT_PLUS_MAX_INPUT_IMAGES = 4 | ||
|
|
||
|
|
||
| _DIFFUSION_MODEL_METADATA: dict[str, DiffusionModelMetadata] = { | ||
| "QwenImageEditPlusPipeline": DiffusionModelMetadata( | ||
| supports_multimodal_inputs=True, | ||
| max_multimodal_image_inputs=QWEN_IMAGE_EDIT_PLUS_MAX_INPUT_IMAGES, | ||
| ), | ||
| } | ||
|
|
||
|
|
||
| def get_diffusion_model_metadata(model_class_name: str | None) -> DiffusionModelMetadata: | ||
| # Unknown models fall back to "no special multimodal capabilities" so new | ||
| # pipelines do not accidentally inherit limits meant for other models. | ||
| if model_class_name is None: | ||
| return DiffusionModelMetadata() | ||
| return _DIFFUSION_MODEL_METADATA.get(model_class_name, DiffusionModelMetadata()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mock VAE config is extremely minimal. Add a brief comment indicating it is intentionally minimal. This helps future maintainers understand why the test might break if
get_qwen_image_edit_plus_pre_process_funcstarts reading more keys at initialization.