@@ -88,13 +88,8 @@ def apply_split_rotary_emb(x: Array, freqs: Tuple[Array, Array]) -> Array:
8888 first_x = split_x [..., 0 , :]
8989 second_x = split_x [..., 1 , :]
9090
91- cos_u = jnp .expand_dims (cos , axis = - 2 )
92- sin_u = jnp .expand_dims (sin , axis = - 2 )
93-
94- out = split_x * cos_u
95-
96- out_first = out [..., 0 , :] - second_x * sin_u .squeeze (- 2 )
97- out_second = out [..., 1 , :] + first_x * sin_u .squeeze (- 2 )
91+ out_first = first_x * cos - second_x * sin
92+ out_second = second_x * cos + first_x * sin
9893
9994 out = jnp .stack ([out_first , out_second ], axis = - 2 )
10095 out = out .reshape (* out .shape [:- 2 ], last_dim )
@@ -176,12 +171,6 @@ def prepare_video_coords(
176171 patch_ends = grid + patch_size_delta
177172
178173 # Combine start and end coordinates
179- latent_coords = jnp .stack ([grid , patch_ends ], axis = - 1 ) # [3, N_F, N_H, N_W, 2]
180- latent_coords = latent_coords .transpose (1 , 2 , 3 , 0 , 4 ) # [N_F, N_H, N_W, 3, 2]
181- latent_coords = latent_coords .reshape (- 1 , 3 , 2 ) # [num_patches, 3, 2]
182- latent_coords = jnp .expand_dims (latent_coords , 0 ) # [1, num_patches, 3, 2]
183- latent_coords = jnp .tile (latent_coords , (batch_size , 1 , 1 , 1 )) # [B, num_patches, 3, 2]
184-
185174 latent_coords = jnp .stack ([grid , patch_ends ], axis = - 1 ) # [3, N_F, N_H, N_W, 2]
186175 latent_coords = latent_coords .reshape (3 , - 1 , 2 ) # [3, num_patches, 2]
187176 latent_coords = jnp .expand_dims (latent_coords , 0 ) # [1, 3, num_patches, 2]
@@ -485,7 +474,7 @@ def __call__(
485474 # 3. Apply RoPE
486475 with jax .named_scope ("Apply RoPE" ):
487476 if rotary_emb is not None :
488- if hasattr ( self , "rope_type" ) and self .rope_type == "split" :
477+ if self .rope_type == "split" :
489478 # Split RoPE: passing full freqs [B, H, S, D//2]
490479 # apply_split_rotary_emb handles reshaping query/key
491480
0 commit comments