1515"""
1616
1717import os
18+ from types import SimpleNamespace
1819import unittest
20+ from unittest .mock import Mock
1921
2022from jax .sharding import Mesh
2123
@@ -35,6 +37,39 @@ class MaxDiffusionUtilsTest(unittest.TestCase):
3537 def setUp (self ):
3638 MaxDiffusionUtilsTest .dummy_data = {}
3739
40+ def test_get_dummy_wan_inputs_generates_latents_without_pipeline_prepare_latents (self ):
41+ config = SimpleNamespace (height = 64 , width = 80 , num_frames = 9 , seed = 0 )
42+ pipeline = SimpleNamespace (
43+ transformer = SimpleNamespace (config = SimpleNamespace (in_channels = 16 )),
44+ vae_scale_factor_temporal = 4 ,
45+ vae_scale_factor_spatial = 8 ,
46+ prepare_latents = Mock (side_effect = AssertionError ("prepare_latents should not be called" )),
47+ )
48+
49+ latents , prompt_embeds , timesteps = maxdiffusion_utils .get_dummy_wan_inputs (config , pipeline , batch_size = 2 )
50+
51+ pipeline .prepare_latents .assert_not_called ()
52+ self .assertEqual (latents .shape , (2 , 16 , 3 , 8 , 10 ))
53+ self .assertEqual (prompt_embeds .shape , (2 , 512 , 4096 ))
54+ self .assertEqual (timesteps .shape , (2 ,))
55+
56+ def test_get_dummy_wan_inputs_supports_two_expert_pipeline (self ):
57+ config = SimpleNamespace (height = 64 , width = 80 , num_frames = 9 , seed = 0 )
58+ pipeline = SimpleNamespace (
59+ low_noise_transformer = SimpleNamespace (config = SimpleNamespace (in_channels = 48 )),
60+ high_noise_transformer = SimpleNamespace (config = SimpleNamespace (in_channels = 48 )),
61+ vae_scale_factor_temporal = 4 ,
62+ vae_scale_factor_spatial = 8 ,
63+ prepare_latents = Mock (side_effect = AssertionError ("prepare_latents should not be called" )),
64+ )
65+
66+ latents , prompt_embeds , timesteps = maxdiffusion_utils .get_dummy_wan_inputs (config , pipeline , batch_size = 2 )
67+
68+ pipeline .prepare_latents .assert_not_called ()
69+ self .assertEqual (latents .shape , (2 , 48 , 3 , 8 , 10 ))
70+ self .assertEqual (prompt_embeds .shape , (2 , 512 , 4096 ))
71+ self .assertEqual (timesteps .shape , (2 ,))
72+
3873 def test_create_scheduler (self ):
3974 """Test create scheduler with different schedulers"""
4075 pyconfig .initialize (
0 commit comments