-
Notifications
You must be signed in to change notification settings - Fork 7k
fix(qwen): fix CFG failing when passing neg prompt embeds with none mask #13379
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
sayakpaul
merged 12 commits into
huggingface:main
from
Sunhill666:fix/qwen-image-cfg-mask
Apr 17, 2026
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
dbe4f95
fix(qwen): fix CFG failing when passing neg prompt embeds with none mask
Sunhill666 d7814c3
Merge branch 'huggingface:main' into fix/qwen-image-cfg-mask
Sunhill666 f600a36
fix(qwen): safely handle missing embeds masks in edit and inpaint pip…
Sunhill666 5b2a1d2
test(qwen): add tests for true cfg scale without neg prompt mask
Sunhill666 c774885
Merge branch 'main' into fix/qwen-image-cfg-mask
sayakpaul 908c304
Merge branch 'main' into fix/qwen-image-cfg-mask
Sunhill666 eb86a2e
fix(qwen): correct comments for copied functions in controlnet and in…
Sunhill666 42587ae
fix(qwen): add warnings for missing prompt and negative prompt masks …
Sunhill666 7fa33ee
test(qwen): use torch_device and clarify dummy inputs in cfg mask tests
Sunhill666 17938f5
fix(qwen): address Claude PR review feedback
Sunhill666 30e10dd
fix(qwen): fix warning message based on reviewer suggestion
Sunhill666 4f736f7
Merge branch 'main' into fix/qwen-image-cfg-mask
Sunhill666 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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.
How do we handle
negative_prompt_embeds_mask? 👀 Is this block affected?diffusers/src/diffusers/pipelines/qwenimage/pipeline_qwenimage.py
Lines 261 to 267 in 71a6fd9
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.
If
negative_prompt_embeds_maskisn't provided (isNone), that block is safely skipped, andencode_promptjust returnsNonefor the mask. The transformer model later receives thisNonemask and handles it natively by treating all tokens as valid.Interestingly, while working on this, I found that some other variants (like
editandinpaint) were actually missing this exactif prompt_embeds_mask is not None:check and were crashing on.repeat(). I've added the same check to those pipelines in this PR as well so they all handleNonemasks gracefully now.