Skip to content

QwenImage has_neg_prompt derivation #13475

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:

ifprompt_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_promptisnotNoneor (
negative_prompt_embedsisnotNoneandnegative_prompt_embeds_maskisnotNone
)

So do_true_cfg evaluates to False and the user silently gets no guidance.

Cc: @kashif

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions