Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/diffusers/models/transformers/transformer_prx.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ def __call__(
ones_img = torch.ones((bs, l_img), dtype=torch.bool, device=device)
attention_mask = attention_mask.to(device=device, dtype=torch.bool)
joint_mask = torch.cat([attention_mask, ones_img], dim=-1)
attn_mask_tensor = joint_mask[:, None, None, :].expand(-1, attn.heads, l_img, -1)
# Every attention backend broadcasts the mask itself, so materialising
# [B, heads, L_img, L_all] only costs bandwidth: at batch 32, 1024 image tokens
# and 28 heads that is a 1.1 GiB mask read per block. Keep it broadcastable.
attn_mask_tensor = joint_mask[:, None, None, :]

# Apply attention using dispatch_attention_fn for backend support
# Reshape to match dispatch_attention_fn expectations: [B, L, H, D]
Expand Down
Loading