Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
01bd7964
Unverified
Commit
01bd7964
authored
Jan 07, 2025
by
hlky
Committed by
GitHub
Jan 07, 2025
Browse files
Fix HunyuanVideo produces NaN on PyTorch<2.5 (#10482)
Co-authored-by:
Sayak Paul
<
spsayakpaul@gmail.com
>
parent
03bcf5ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
src/diffusers/models/transformers/transformer_hunyuan_video.py
...iffusers/models/transformers/transformer_hunyuan_video.py
+4
-4
No files found.
src/diffusers/models/transformers/transformer_hunyuan_video.py
View file @
01bd7964
...
...
@@ -713,15 +713,15 @@ class HunyuanVideoTransformer3DModel(ModelMixin, ConfigMixin, PeftAdapterMixin,
condition_sequence_length
=
encoder_hidden_states
.
shape
[
1
]
sequence_length
=
latent_sequence_length
+
condition_sequence_length
attention_mask
=
torch
.
zeros
(
batch_size
,
sequence_length
,
sequence_length
,
device
=
hidden_states
.
device
,
dtype
=
torch
.
bool
)
# [B,
N,
N]
batch_size
,
sequence_length
,
device
=
hidden_states
.
device
,
dtype
=
torch
.
bool
)
# [B, N]
effective_condition_sequence_length
=
encoder_attention_mask
.
sum
(
dim
=
1
,
dtype
=
torch
.
int
)
# [B,]
effective_sequence_length
=
latent_sequence_length
+
effective_condition_sequence_length
for
i
in
range
(
batch_size
):
attention_mask
[
i
,
:
effective_sequence_length
[
i
],
:
effective_sequence_length
[
i
]]
=
True
attention_mask
=
attention_mask
.
unsqueeze
(
1
)
# [B, 1,
N,
N], for broadcasting across attention heads
attention_mask
[
i
,
:
effective_sequence_length
[
i
]]
=
True
attention_mask
=
attention_mask
.
unsqueeze
(
1
)
# [B, 1, N], for broadcasting across attention heads
# 4. Transformer blocks
if
torch
.
is_grad_enabled
()
and
self
.
gradient_checkpointing
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment