Fix missing .unsqueeze(1) in attention mask for HunyuanVideo VAE#13133
Open
Minisal wants to merge 1 commit intohuggingface:mainfrom
Open
Fix missing .unsqueeze(1) in attention mask for HunyuanVideo VAE#13133Minisal wants to merge 1 commit intohuggingface:mainfrom
Minisal wants to merge 1 commit intohuggingface:mainfrom
Conversation
Member
|
Can you provide a reproducer? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR fixes a dimension mismatch in the attention mask handling for the HunyuanVideo1.5 VAE implementation in
autoencoder_kl_hunyuanvideo15.py.Problem
In the current implementation (line 148 of
autoencoder_kl_hunyuanvideo15.py), theattention_maskis passed directly toscaled_dot_product_attentionwithout reshaping:However, the original HuanyuanVideo implementation (line 211 of
huanyuanvideo_15_vae.py) correctly applies.unsqueeze(1)to the mask:This ensures the attention mask has the correct shape for batched attention computation. Without this, the mask dimensions may not align with the query/key/value tensors, leading to potential runtime errors or incorrect attention behavior.
Fix
Add
.unsqueeze(1)to theattention_maskargument in thescaled_dot_product_attentioncall to match the original implementation.Changes
src/diffusers/models/autoencoder_kl_hunyuanvideo15.pyWho can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@yiyixuxu
@asomoza
@sayakpaul
@DN6