Skip to content
Draft
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
7 changes: 6 additions & 1 deletion wan_va/modules/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def half(x):
def init_mask(
latent_shape,
action_shape,
text_sequence_length,
padded_length,
chunk_size,
window_size,
Expand Down Expand Up @@ -133,7 +134,9 @@ def init_mask(
)
FlexAttnFunc.attention_mask = block_mask

text_seq_ids = torch.arange(B)[:, None].expand(-1, 512).flatten()
text_seq_ids = torch.arange(B)[:, None].expand(
-1, text_sequence_length
).flatten()
mask_mod_cross = FlexAttnFunc._get_cross_mask_mod(seq_ids.long().to(device), text_seq_ids.long().to(device))
block_mask_cross = FlexAttnFunc.compiled_create_block_mask(
mask_mod_cross, 1, 1, len(seq_ids), len(text_seq_ids), device=device, _compile=True
Expand Down Expand Up @@ -712,6 +715,7 @@ def forward_train(self, input_dict):
latent_hidden_states = self._input_embed(latent_dict['noisy_latents'], input_type='latent').flatten(0, 1)[None]
action_hidden_states = self._input_embed(action_dict['noisy_latents'], input_type='action').flatten(0, 1)[None]
text_hidden_states = self._input_embed(latent_dict["text_emb"], input_type='text')
text_sequence_length = text_hidden_states.shape[1]

text_hidden_states = text_hidden_states.flatten(0, 1)[None]

Expand Down Expand Up @@ -764,6 +768,7 @@ def forward_train(self, input_dict):

FlexAttnFunc.init_mask(latent_dict['noisy_latents'].shape,
action_dict['noisy_latents'].shape,
text_sequence_length,
padded_length,
input_dict["chunk_size"],
window_size=input_dict['window_size'],
Expand Down