fix: QwenImage pipelines silently disable CFG with pre-computed negative_prompt_embeds#13449
Open
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Open
Conversation
…beds mask is None `encode_prompt()` optimizes all-ones masks to `None`, but `has_neg_prompt` required both `negative_prompt_embeds` and `negative_prompt_embeds_mask` to be non-None. This caused CFG to be silently skipped when users passed pre-computed `negative_prompt_embeds` with an optimized `None` mask. Remove the `negative_prompt_embeds_mask is not None` check from all 9 QwenImage pipeline variants so that a `None` mask correctly means "all tokens valid" rather than "no negative prompt". Fixes huggingface#13377 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
negative_prompt_embedswithNonemaskencode_prompt()converts all-ones masks toNoneas an optimization (line 266-267), buthas_neg_promptrequired mask to be non-None — creating an inconsistencyand negative_prompt_embeds_mask is not Nonecheck soNonemask means "all tokens valid"Affected pipelines
pipeline_qwenimage.pypipeline_qwenimage_img2img.pypipeline_qwenimage_inpaint.pypipeline_qwenimage_layered.pypipeline_qwenimage_controlnet.pypipeline_qwenimage_controlnet_inpaint.pypipeline_qwenimage_edit.pypipeline_qwenimage_edit_inpaint.pypipeline_qwenimage_edit_plus.pyTest plan
encode_prompt()converts all-ones mask toNone(line 266-267)Fixes #13377
🤖 Generated with Claude Code