Skip to content

Comments

[BugFix] Fix modulate_index shape error in Qwen-Image-Edit Task#1100

Merged
ZJY0516 merged 87 commits intovllm-project:mainfrom
mxuax:Non-Intrusive-SP
Jan 30, 2026
Merged

[BugFix] Fix modulate_index shape error in Qwen-Image-Edit Task#1100
ZJY0516 merged 87 commits intovllm-project:mainfrom
mxuax:Non-Intrusive-SP

Conversation

@mxuax
Copy link
Contributor

@mxuax mxuax commented Jan 30, 2026

PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED.
This PR fixes issue #1094.

Purpose

Fix modulate_index shape error in Qwen-Image-Edit Task
This bug is due to zero_cond_t being true when editing, and the current sp_plan does not include the sharding for the variable modulate_index created. I added a new submodule to handle this

Test Plan

Command:
CUDA_VISIBLE_DEVICES=0,1,2,3 python examples/offline_inference/image_to_image/image_edit.py --model "Qwen/Qwen-Image-Edit-2511" --image input.png --prompt "Add a sunset sky background" --output output_u2r2.png --ulysses_degree 2 --ring_degree 2 --enforce_eager --num_inference_steps 20

input image:
image

Test Result

Success with the right image.
image


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, such as providing test commands.
  • [ - ] The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (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)

mxuax and others added 30 commits January 14, 2026 15:06
Signed-off-by: mxuax <[email protected]>
Signed-off-by: mxuax <[email protected]>
Signed-off-by: mxuax <[email protected]>
Removed context parallelism plan and related comments.

Signed-off-by: XU Mingshi <[email protected]>
Signed-off-by: XU Mingshi <[email protected]>
Signed-off-by: mxuax <[email protected]>
Signed-off-by: XU Mingshi <[email protected]>
…e lengths

- Add sp_attention_mask, sp_padding_size, sp_original_seq_len to ForwardContext
- Add auto_pad option to SequenceParallelInput
- Implement _shard_with_auto_pad in SequenceParallelSplitHook
- Update SequenceParallelGatherHook to remove padding
- Update QwenImage _sp_plan with auto_pad=True
- Update QwenImageCrossAttention to use sp_attention_mask

Signed-off-by: mxuax <[email protected]>
Signed-off-by: mxuax <[email protected]>
Signed-off-by: mxuax <[email protected]>
@mxuax mxuax requested a review from hsliuustc0106 as a code owner January 30, 2026 04:15
@mxuax mxuax changed the title Fix modulate_index shape error in Qwen-Image-Edit Task [BugFix] Fix modulate_index shape error in Qwen-Image-Edit Task Jan 30, 2026
@chatgpt-codex-connector
Copy link

💡 Codex Review

if not HAS_FLASH_ATTN:
raise ImportError(
"FlashAttentionBackend requires Flash Attention. "
"Please install one of: fa3-fwd, flash-attention, or flash-attn. "
"Otherwise, use SDPA backend by setting DIFFUSION_ATTENTION_BACKEND=TORCH_SDPA"

P1 Badge Gate FlashAttention import error on CUDA/ROCm only

Raising ImportError at module import time makes the FLASH_ATTN backend unusable on NPU, even when mindiesd is present. The NPU platform selects FLASH_ATTN when mindiesd is available, but HAS_FLASH_ATTN is computed from FA2/FA3 CUDA/ROCm packages, which are typically absent on NPU, so importing this module now fails before the forward_npu path can be used. This breaks attention on NPU deployments that previously worked; consider deferring the check to forward_cuda or guarding it with a platform check so NPU can still load the backend.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@mxuax
Copy link
Contributor Author

mxuax commented Jan 30, 2026

This BugFix is ready. @ZJY0516 @hsliuustc0106

@hsliuustc0106 hsliuustc0106 added the ready label to trigger buildkite CI label Jan 30, 2026
@hsliuustc0106
Copy link
Collaborator

please add the benchmark results from benchmark/diffusion folder

Copy link
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

This PR fixes a shape mismatch error in the Qwen-Image-Edit task when using sequence parallelism (USP=2 or higher). The bug occurred because the modulate_index tensor was not being sharded correctly when zero_cond_t is enabled in image editing models.

Changes:

  • Introduced ModulateIndexPrepare module to encapsulate modulate_index creation logic and enable proper sequence parallel sharding
  • Updated _sp_plan configuration to shard the modulate_index output
  • Refactored the forward method to use the new module instead of inline tensor creation

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

@hsliuustc0106 hsliuustc0106 linked an issue Jan 30, 2026 that may be closed by this pull request
1 task
@ZJY0516
Copy link
Collaborator

ZJY0516 commented Jan 30, 2026

I think this is what we need to catch in CI

Copy link
Contributor

@gcanlin gcanlin left a comment

Choose a reason for hiding this comment

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

LGTM. It works on NPU as well.

@ZJY0516 ZJY0516 enabled auto-merge (squash) January 30, 2026 06:08
@mxuax
Copy link
Contributor Author

mxuax commented Jan 30, 2026

please add the benchmark results from benchmark/diffusion folder

This PR fixes the bug for edit, but the benchmark is for t2i. Thus, I think it won't influence the result.

@ZJY0516 ZJY0516 merged commit be835c4 into vllm-project:main Jan 30, 2026
6 of 7 checks passed
dongbo910220 pushed a commit to dongbo910220/vllm-omni that referenced this pull request Feb 1, 2026
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]: Qwen-Image-Edit-2511 USP=2 failed

4 participants