Skip to content

QwenImage has_neg_prompt derivation #13475

@sayakpaul

Description

@sayakpaul

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions