@@ -357,30 +357,29 @@ def get_dummy_ltx2_inputs(config, pipeline, batch_size):
357357 )
358358
359359
360+ def _get_wan_transformer_for_dummy_inputs (pipeline ):
361+ for transformer_attr in ("transformer" , "low_noise_transformer" , "high_noise_transformer" ):
362+ transformer = getattr (pipeline , transformer_attr , None )
363+ if transformer is not None :
364+ return transformer
365+ raise ValueError ("WAN dummy inputs require a transformer, low_noise_transformer, or high_noise_transformer." )
366+
367+
368+ def _get_dummy_wan_latents (config , pipeline , batch_size ):
369+ transformer = _get_wan_transformer_for_dummy_inputs (pipeline )
370+ num_channels_latents = transformer .config .in_channels
371+ num_latent_frames = (int (config .num_frames ) - 1 ) // pipeline .vae_scale_factor_temporal + 1
372+ latent_height = int (config .height ) // pipeline .vae_scale_factor_spatial
373+ latent_width = int (config .width ) // pipeline .vae_scale_factor_spatial
374+ return jax .random .normal (
375+ jax .random .key (config .seed ),
376+ (batch_size , num_channels_latents , num_latent_frames , latent_height , latent_width ),
377+ dtype = jnp .float32 ,
378+ )
379+
380+
360381def get_dummy_wan_inputs (config , pipeline , batch_size ):
361- if getattr (pipeline , "transformer" , None ) is not None :
362- latents = pipeline .prepare_latents (
363- batch_size ,
364- vae_scale_factor_temporal = pipeline .vae_scale_factor_temporal ,
365- vae_scale_factor_spatial = pipeline .vae_scale_factor_spatial ,
366- height = config .height ,
367- width = config .width ,
368- num_frames = config .num_frames ,
369- num_channels_latents = pipeline .transformer .config .in_channels ,
370- )
371- else :
372- # The two-expert Wan2.2 I2V pipeline (WanPipelineI2V_2_2) has no `.transformer`
373- # and a different `prepare_latents()` signature, so build dummy latents directly
374- # in the (B, C, F, H, W) layout WanModel.__call__ expects.
375- transformer = getattr (pipeline , "low_noise_transformer" , None ) or pipeline .high_noise_transformer
376- num_channels_latents = transformer .config .in_channels
377- num_latent_frames = (config .num_frames - 1 ) // pipeline .vae_scale_factor_temporal + 1
378- latent_height = config .height // pipeline .vae_scale_factor_spatial
379- latent_width = config .width // pipeline .vae_scale_factor_spatial
380- latents = jax .random .normal (
381- jax .random .key (config .seed ),
382- (batch_size , num_channels_latents , num_latent_frames , latent_height , latent_width ),
383- )
382+ latents = _get_dummy_wan_latents (config , pipeline , batch_size )
384383 bsz = latents .shape [0 ]
385384 prompt_embeds = jax .random .normal (jax .random .key (config .seed ), (batch_size , 512 , 4096 ))
386385 timesteps = jnp .array ([0 ] * bsz , dtype = jnp .int32 )
0 commit comments