Skip to content

Commit 01eaf44

Browse files
committed
Fix joint attention mask being applied on image-only self-attention
Only prepare and apply the joint attention mask when encoder_hidden_states is present. SD3.5 dual-attention blocks pass joint_attention_kwargs (including the text mask) to attn2 self-attention, which should ignore the mask.
1 parent f41465a commit 01eaf44

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/diffusers/models/attention_processor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,10 @@ def __call__(
15131513
value = torch.cat([value, encoder_hidden_states_value_proj], dim=2)
15141514

15151515
if attention_mask is not None:
1516-
attention_mask = attn.prepare_joint_attention_mask(attention_mask, key.shape[2], key.dtype)
1516+
if encoder_hidden_states is not None:
1517+
attention_mask = attn.prepare_joint_attention_mask(attention_mask, key.shape[2], key.dtype)
1518+
else:
1519+
attention_mask = None
15171520

15181521
hidden_states = F.scaled_dot_product_attention(
15191522
query, key, value, attn_mask=attention_mask, dropout_p=0.0, is_causal=False

0 commit comments

Comments
 (0)