Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions src/diffusers/models/transformers/transformer_cosmos3.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@ def forward(
packed_tokens_vision, original_latent_shapes = self._patchify_and_pack_latents(vision_tokens)
packed_tokens_vision = self.proj_in(packed_tokens_vision)
timesteps_vision = vision_timesteps * self.config.timestep_scale
packed_timestep_embeds_vision = self.time_embedder(self.time_proj(timesteps_vision))
time_embedder_dtype = next(self.time_embedder.parameters()).dtype
packed_timestep_embeds_vision = self.time_embedder(self.time_proj(timesteps_vision).to(time_embedder_dtype))
packed_timestep_embeds_vision = packed_timestep_embeds_vision.to(target_dtype)
packed_tokens_vision = self._apply_timestep_embeds_to_noisy_tokens(
packed_tokens=packed_tokens_vision,
Expand All @@ -717,7 +718,7 @@ def forward(
packed_tokens_sound = self._pack_sound_latents(sound_tokens, sound_token_shapes).to(target_dtype)
packed_tokens_sound = self.audio_proj_in(packed_tokens_sound) + self.audio_modality_embed
timesteps_sound = sound_timesteps * self.config.timestep_scale
packed_timestep_embeds_sound = self.time_embedder(self.time_proj(timesteps_sound))
packed_timestep_embeds_sound = self.time_embedder(self.time_proj(timesteps_sound).to(time_embedder_dtype))
packed_timestep_embeds_sound = packed_timestep_embeds_sound.to(target_dtype)
packed_tokens_sound = self._apply_timestep_embeds_to_noisy_tokens(
packed_tokens=packed_tokens_sound,
Expand All @@ -738,7 +739,9 @@ def forward(
packed_tokens_action = packed_tokens_action + self.action_modality_embed
if action_mse_loss_indexes.numel() > 0:
timesteps_action = action_timesteps * self.config.timestep_scale
packed_timestep_embeds_action = self.time_embedder(self.time_proj(timesteps_action))
packed_timestep_embeds_action = self.time_embedder(
self.time_proj(timesteps_action).to(time_embedder_dtype)
)
packed_timestep_embeds_action = packed_timestep_embeds_action.to(target_dtype)
packed_tokens_action = self._apply_timestep_embeds_to_noisy_tokens(
packed_tokens=packed_tokens_action,
Expand Down
4 changes: 3 additions & 1 deletion tests/models/transformers/test_models_transformer_cosmos3.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ def test_cosmos3_nemotron_rms_norm_multiplies_in_float32(self):


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


class TestCosmos3OmniTransformerTorchCompile(Cosmos3OmniTransformerTesterConfig, TorchCompileTesterMixin):
Expand Down
Loading