[TRTLLM-14135][feat] Add Qwen-Image-Edit-2511 support#16095
[TRTLLM-14135][feat] Add Qwen-Image-Edit-2511 support#16095yibinl-nvidia wants to merge 11 commits into
Conversation
c9634fc to
3779b15
Compare
6d0ec5f to
bbf4efa
Compare
📝 WalkthroughWalkthroughChangesQwen Image Edit support
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as qwen_image_edit.py
participant VisualGen
participant Pipeline as QwenImageEditPlusPipeline
participant Transformer as QwenImageTransformer2DModel
participant Scheduler
participant VAE
CLI->>VisualGen: generate image-edit request
VisualGen->>Pipeline: infer request
Pipeline->>Transformer: denoise conditioned latents
Transformer-->>Pipeline: noise prediction
Pipeline->>Scheduler: update latents
Pipeline->>VAE: decode output latents
VAE-->>Pipeline: edited image
Pipeline-->>VisualGen: PipelineOutput
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
tensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image_edit.py (1)
14-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winApply the repository’s Python 3.10 typing conventions.
tensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image_edit.py#L14-L14: replace legacy typing aliases with built-in generics and|.tensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image_edit.py#L338-L338: typereqand thePipelineOutputreturn.tensorrt_llm/_torch/visual_gen/models/qwen_image/transformer_qwen_image.py#L980-L985: type the runner and nested key callback.As per coding guidelines, “Annotate every function” and “prefer built-in generic types and
|.”🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image_edit.py` at line 14, Update tensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image_edit.py:14 to remove legacy typing aliases and use Python 3.10 built-in generics and | unions; annotate req and the PipelineOutput return in the relevant pipeline function at line 338. Also update tensorrt_llm/_torch/visual_gen/models/qwen_image/transformer_qwen_image.py:980-985 to annotate the runner and nested key callback, following the repository’s “Annotate every function” convention. These changes are required at all three listed sites.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/visual_gen/configs/qwen-image-edit-2511-fp4-1gpu.yaml`:
- Around line 18-19: Remove the “trtllm-serve” sharing claim from the comment
near the Qwen-Image-Edit FP4 configuration in
examples/visual_gen/configs/qwen-image-edit-2511-fp4-1gpu.yaml:18-19, rewording
it to describe only the supported offline visual-generation usage. The
references in docs/source/models/supported-models.md:182 and
docs/source/models/visual-generation.md:57 require no direct change unless
needed to keep documentation consistent.
In
`@tensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image_edit.py`:
- Around line 524-547: In the do_true_cfg path, clone the conditional noise_pred
prefix immediately after slicing it and before the second self.transformer call,
so the negative CUDA-graph replay cannot overwrite or alias the conditional
prediction used by CFG. Keep the existing negative prediction, combination, and
norm-rescaling logic unchanged.
- Around line 338-365: Update infer so num_images_per_prompt is not expanded
into the prompts list, which currently causes forward to reject the batch. Pass
the count separately through infer/forward and use it to produce the effective
latent and output batch for each prompt, while preserving prompt batching;
alternatively, reject values greater than one during request validation if the
pipeline cannot support them.
In `@tests/integration/defs/examples/visual_gen/test_visual_gen.py`:
- Around line 1846-1898: Add type annotations throughout the new tests: in
tests/integration/defs/examples/visual_gen/test_visual_gen.py:1846-1898,
annotate fixture parameters and add -> None to test_qwen_image_edit_example; in
tests/unittest/_torch/visual_gen/test_qwen_image_pipeline_config.py:231-272, add
the helper return type, -> None on tests, and record_call(self) -> None; in
tests/unittest/_torch/visual_gen/test_qwen_image_registry.py:84-96, annotate
fixture parameters and add -> None to the new tests.
---
Nitpick comments:
In
`@tensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image_edit.py`:
- Line 14: Update
tensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image_edit.py:14
to remove legacy typing aliases and use Python 3.10 built-in generics and |
unions; annotate req and the PipelineOutput return in the relevant pipeline
function at line 338. Also update
tensorrt_llm/_torch/visual_gen/models/qwen_image/transformer_qwen_image.py:980-985
to annotate the runner and nested key callback, following the repository’s
“Annotate every function” convention. These changes are required at all three
listed sites.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 5fdd62ff-54ce-4cd4-bfbd-abc1d6bf36dd
📒 Files selected for processing (14)
docs/source/models/supported-models.mddocs/source/models/visual-generation.mdexamples/visual_gen/README.mdexamples/visual_gen/configs/qwen-image-edit-2511-bf16-1gpu.yamlexamples/visual_gen/configs/qwen-image-edit-2511-fp4-1gpu.yamlexamples/visual_gen/models/qwen_image_edit.pytensorrt_llm/_torch/visual_gen/cuda_graph_runner.pytensorrt_llm/_torch/visual_gen/models/__init__.pytensorrt_llm/_torch/visual_gen/models/qwen_image/__init__.pytensorrt_llm/_torch/visual_gen/models/qwen_image/pipeline_qwen_image_edit.pytensorrt_llm/_torch/visual_gen/models/qwen_image/transformer_qwen_image.pytests/integration/defs/examples/visual_gen/test_visual_gen.pytests/unittest/_torch/visual_gen/test_qwen_image_pipeline_config.pytests/unittest/_torch/visual_gen/test_qwen_image_registry.py
34093c1 to
35e7fd7
Compare
|
/bot run |
|
PR_Github #60479 [ run ] triggered by Bot. Commit: |
|
PR_Github #60479 [ run ] completed with state |
|
/bot run |
|
PR_Github #60799 [ run ] triggered by Bot. Commit: |
|
PR_Github #60799 [ run ] completed with state
|
| | `Lightricks/LTX-2` | Text-to-Video (with Audio), Image-to-Video (with Audio) | | ||
| | `Qwen/Qwen-Image` | Text-to-Image | | ||
| | `Qwen/Qwen-Image-2512` | Text-to-Image | | ||
| | `Qwen/Qwen-Image-Edit-2511` | Image Editing | |
There was a problem hiding this comment.
Not sure if we should name like text+image-to-image, and also some other models such as Flux also supports text+image-to-image.
There was a problem hiding this comment.
Maybe Image Editing (text+image-to-image)?
| | `Lightricks/LTX-2` | Text-to-Video (with Audio), Image-to-Video (with Audio) | | ||
| | `Qwen/Qwen-Image` | Text-to-Image | | ||
| | `Qwen/Qwen-Image-2512` | Text-to-Image | | ||
| | `Qwen/Qwen-Image-Edit-2511` | Image Editing | |
There was a problem hiding this comment.
Not sure if we should name like text+image-to-image, and also some other models such as Flux also supports text+image-to-image.
There was a problem hiding this comment.
Maybe Image Editing (text+image-to-image)?
| quant_config: | ||
| quant_algo: NVFP4 | ||
| dynamic: true | ||
| ignore: | ||
| - "transformer_blocks.*.attn.to_q" | ||
| - "transformer_blocks.*.attn.to_k" | ||
| - "transformer_blocks.*.attn.to_v" | ||
| - "transformer_blocks.*.attn.add_q_proj" | ||
| - "transformer_blocks.*.attn.add_k_proj" | ||
| - "transformer_blocks.*.attn.add_v_proj" |
There was a problem hiding this comment.
Why these settings? When disclose such, we should have some docs to clarify the methodology.
There was a problem hiding this comment.
I briefly mentioned in the comment above that
Q/K/V projections remain in BF16 because they preserve accuracy
Or we could use FP8 quant.
There was a problem hiding this comment.
modified to use FP8 quant config instead.
| "--image", | ||
| nargs="+", |
There was a problem hiding this comment.
This support is similar to Flux Kontext cc @karljang
663012b to
36779f0
Compare
c6ca070 to
51c15b9
Compare
|
/bot run |
|
PR_Github #61097 [ run ] triggered by Bot. Commit: |
|
PR_Github #61097 [ run ] completed with state
|
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
Signed-off-by: Yibin Li <109242046+yibinl-nvidia@users.noreply.github.com>
51c15b9 to
9d85816
Compare
|
/bot run |
|
PR_Github #61344 [ run ] triggered by Bot. Commit: |
|
PR_Github #61344 [ run ] completed with state
|
|
/bot run |
|
PR_Github #61376 [ run ] triggered by Bot. Commit: |
|
PR_Github #61376 [ run ] completed with state
|
chang-l
left a comment
There was a problem hiding this comment.
Does this PR also include trtllm-serve support for the image-edit endpoint?
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Description
Add Qwen-Image-Edit-2511 support to the TRT-LLM visual generation stack using the existing Qwen-Image transformer, VAE, scheduler, processor, and visual-gen executor path. The implementation adds an image-edit example entrypoint/config, routes Qwen-Image-Edit checkpoints to the edit pipeline, and keeps the architecture aligned with the existing Qwen-Image building blocks.
Supported Features
cfg_size=2splits positive and negative CFG branches across two ranks. Eager CFG=1 vs CFG=2 matched exactly in local validation; withtorch.compile, LPIPS drift was observed around 0.096 and considered acceptable for this image generation path.See visuals
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.