Skip to content

Commit 994a92d

Browse files
authored
[tests] fix cosmos3 tests (#14229)
fix cosmos3 tests
1 parent e97c271 commit 994a92d

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/diffusers/models/transformers/transformer_cosmos3.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,8 @@ def forward(
702702
packed_tokens_vision, original_latent_shapes = self._patchify_and_pack_latents(vision_tokens)
703703
packed_tokens_vision = self.proj_in(packed_tokens_vision)
704704
timesteps_vision = vision_timesteps * self.config.timestep_scale
705-
packed_timestep_embeds_vision = self.time_embedder(self.time_proj(timesteps_vision))
705+
time_embedder_dtype = next(self.time_embedder.parameters()).dtype
706+
packed_timestep_embeds_vision = self.time_embedder(self.time_proj(timesteps_vision).to(time_embedder_dtype))
706707
packed_timestep_embeds_vision = packed_timestep_embeds_vision.to(target_dtype)
707708
packed_tokens_vision = self._apply_timestep_embeds_to_noisy_tokens(
708709
packed_tokens=packed_tokens_vision,
@@ -717,7 +718,7 @@ def forward(
717718
packed_tokens_sound = self._pack_sound_latents(sound_tokens, sound_token_shapes).to(target_dtype)
718719
packed_tokens_sound = self.audio_proj_in(packed_tokens_sound) + self.audio_modality_embed
719720
timesteps_sound = sound_timesteps * self.config.timestep_scale
720-
packed_timestep_embeds_sound = self.time_embedder(self.time_proj(timesteps_sound))
721+
packed_timestep_embeds_sound = self.time_embedder(self.time_proj(timesteps_sound).to(time_embedder_dtype))
721722
packed_timestep_embeds_sound = packed_timestep_embeds_sound.to(target_dtype)
722723
packed_tokens_sound = self._apply_timestep_embeds_to_noisy_tokens(
723724
packed_tokens=packed_tokens_sound,
@@ -738,7 +739,9 @@ def forward(
738739
packed_tokens_action = packed_tokens_action + self.action_modality_embed
739740
if action_mse_loss_indexes.numel() > 0:
740741
timesteps_action = action_timesteps * self.config.timestep_scale
741-
packed_timestep_embeds_action = self.time_embedder(self.time_proj(timesteps_action))
742+
packed_timestep_embeds_action = self.time_embedder(
743+
self.time_proj(timesteps_action).to(time_embedder_dtype)
744+
)
742745
packed_timestep_embeds_action = packed_timestep_embeds_action.to(target_dtype)
743746
packed_tokens_action = self._apply_timestep_embeds_to_noisy_tokens(
744747
packed_tokens=packed_tokens_action,

tests/models/transformers/test_models_transformer_cosmos3.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ def test_cosmos3_nemotron_rms_norm_multiplies_in_float32(self):
195195

196196

197197
class TestCosmos3OmniTransformerMemory(Cosmos3OmniTransformerTesterConfig, MemoryTesterMixin):
198-
pass
198+
@pytest.mark.skip("The transformer returns one tensor list per generated modality.")
199+
def test_layerwise_casting_training(self):
200+
super().test_layerwise_casting_training()
199201

200202

201203
class TestCosmos3OmniTransformerTorchCompile(Cosmos3OmniTransformerTesterConfig, TorchCompileTesterMixin):

0 commit comments

Comments
 (0)