Skip to content

Commit dcac72f

Browse files
Ricardo-M-Lclaude
andcommitted
fix: QwenImage pipelines silently disable CFG when negative_prompt_embeds 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 #13377 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dc8d903 commit dcac72f

9 files changed

Lines changed: 9 additions & 9 deletions

src/diffusers/pipelines/qwenimage/pipeline_qwenimage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ def __call__(
585585
device = self._execution_device
586586

587587
has_neg_prompt = negative_prompt is not None or (
588-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
588+
negative_prompt_embeds is not None
589589
)
590590

591591
if true_cfg_scale > 1 and not has_neg_prompt:

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_controlnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def __call__(
701701
device = self._execution_device
702702

703703
has_neg_prompt = negative_prompt is not None or (
704-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
704+
negative_prompt_embeds is not None
705705
)
706706

707707
if true_cfg_scale > 1 and not has_neg_prompt:

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_controlnet_inpaint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ def __call__(
740740
device = self._execution_device
741741

742742
has_neg_prompt = negative_prompt is not None or (
743-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
743+
negative_prompt_embeds is not None
744744
)
745745
do_true_cfg = true_cfg_scale > 1 and has_neg_prompt
746746
prompt_embeds, prompt_embeds_mask = self.encode_prompt(

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def __call__(
706706
image = image.unsqueeze(2)
707707

708708
has_neg_prompt = negative_prompt is not None or (
709-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
709+
negative_prompt_embeds is not None
710710
)
711711

712712
if true_cfg_scale > 1 and not has_neg_prompt:

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit_inpaint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ def __call__(
879879
image = image.to(dtype=torch.float32)
880880

881881
has_neg_prompt = negative_prompt is not None or (
882-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
882+
negative_prompt_embeds is not None
883883
)
884884

885885
if true_cfg_scale > 1 and not has_neg_prompt:

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit_plus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ def __call__(
694694
vae_images.append(self.image_processor.preprocess(img, vae_height, vae_width).unsqueeze(2))
695695

696696
has_neg_prompt = negative_prompt is not None or (
697-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
697+
negative_prompt_embeds is not None
698698
)
699699

700700
if true_cfg_scale > 1 and not has_neg_prompt:

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_img2img.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ def __call__(
678678
device = self._execution_device
679679

680680
has_neg_prompt = negative_prompt is not None or (
681-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
681+
negative_prompt_embeds is not None
682682
)
683683

684684
if true_cfg_scale > 1 and not has_neg_prompt:

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_inpaint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ def __call__(
823823
device = self._execution_device
824824

825825
has_neg_prompt = negative_prompt is not None or (
826-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
826+
negative_prompt_embeds is not None
827827
)
828828

829829
if true_cfg_scale > 1 and not has_neg_prompt:

src/diffusers/pipelines/qwenimage/pipeline_qwenimage_layered.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ def __call__(
698698
batch_size = prompt_embeds.shape[0]
699699

700700
has_neg_prompt = negative_prompt is not None or (
701-
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None
701+
negative_prompt_embeds is not None
702702
)
703703

704704
if true_cfg_scale > 1 and not has_neg_prompt:

0 commit comments

Comments
 (0)