Skip to content

fix: correct attention mask padding amount in prepare_attention_mask#596

Open
Mr-Neutr0n wants to merge 1 commit into
PKU-YuanGroup:mainfrom
Mr-Neutr0n:fix/attention-mask-padding
Open

fix: correct attention mask padding amount in prepare_attention_mask#596
Mr-Neutr0n wants to merge 1 commit into
PKU-YuanGroup:mainfrom
Mr-Neutr0n:fix/attention-mask-padding

Conversation

@Mr-Neutr0n

Copy link
Copy Markdown

Summary

Fix incorrect F.pad call in Attention.prepare_attention_mask() (opensora/models/diffusion/opensora_v1_3/modules.py).

F.pad(tensor, (0, N)) pads by N elements on the right — it does not pad to a total length of N. The existing code uses (0, target_length), which produces a tensor of length current_length + target_length instead of target_length.

Before

attention_mask = F.pad(attention_mask, (0, target_length), value=0.0)

After

attention_mask = F.pad(attention_mask, (0, target_length - current_length), value=0.0)

This ensures the mask is padded to exactly target_length elements, as intended.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant