For QwenImage, encode_prompt drops prompt_embeds_mask when all True, breaking true CFG with pre-computed embeddings.
When passing pre-computed negative_prompt_embeds and negative_prompt_embeds_mask to the QwenImage pipeline, classifier-free guidance silently fails to activate if the mask is all True.
Root cause: encode_prompt sets the mask to None when every position is attended to:
|
if prompt_embeds_mask.all(): |
|
prompt_embeds_mask = None |
This is common for short prompts (e.g., a negative prompt of " "). The has_neg_prompt check then fails because it requires both (negative_prompt_embeds and negative_prompt_embeds_mask) to be non-None:
|
has_neg_prompt = negative_prompt is not None or ( |
|
negative_prompt_embeds is not None and negative_prompt_embeds_mask is not None |
|
) |
So do_true_cfg evaluates to False and the user silently gets no guidance.
Cc: @kashif
For QwenImage,
encode_promptdropsprompt_embeds_maskwhen all True, breaking true CFG with pre-computed embeddings.When passing pre-computed
negative_prompt_embedsandnegative_prompt_embeds_maskto the QwenImage pipeline, classifier-free guidance silently fails to activate if the mask is allTrue.Root cause: encode_prompt sets the mask to None when every position is attended to:
diffusers/src/diffusers/pipelines/qwenimage/pipeline_qwenimage.py
Lines 266 to 267 in 0d79fc2
This is common for short prompts (e.g., a negative prompt of " "). The
has_neg_promptcheck then fails because it requires both (negative_prompt_embedsandnegative_prompt_embeds_mask) to be non-None:diffusers/src/diffusers/pipelines/qwenimage/pipeline_qwenimage.py
Lines 587 to 589 in 0d79fc2
So
do_true_cfgevaluates to False and the user silently gets no guidance.Cc: @kashif