Skip to content

Commit f6c36b9

Browse files
committed
Fix get_dummy_wan_inputs for two-expert Wan2.2 I2V pipeline
get_dummy_wan_inputs (used by WanPipeline.quantize_transformer) assumed a single pipeline.transformer and the single-transformer prepare_latents() signature. WanPipelineI2V_2_2 (Wan2.2-I2V-A14B) is two-expert: it has low_noise_transformer / high_noise_transformer (no .transformer) and a different prepare_latents() signature, so qwix quantization crashed with AttributeError: 'WanPipelineI2V_2_2' object has no attribute 'transformer' and then TypeError: prepare_latents() got an unexpected keyword argument 'vae_scale_factor_temporal'. When pipeline.transformer is absent, build dummy latents directly in the (B, C, F, H, W) layout WanModel.__call__ expects, taking num_channels_latents from an existing expert. The single-transformer path is unchanged. Validated on Wan2.2-I2V-A14B (v6e): quantization now proceeds past these errors into qwix.quantize_model.
1 parent 08566b1 commit f6c36b9

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

src/maxdiffusion/maxdiffusion_utils.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,29 @@ def get_dummy_ltx2_inputs(config, pipeline, batch_size):
358358

359359

360360
def get_dummy_wan_inputs(config, pipeline, batch_size):
361-
latents = pipeline.prepare_latents(
362-
batch_size,
363-
vae_scale_factor_temporal=pipeline.vae_scale_factor_temporal,
364-
vae_scale_factor_spatial=pipeline.vae_scale_factor_spatial,
365-
height=config.height,
366-
width=config.width,
367-
num_frames=config.num_frames,
368-
num_channels_latents=pipeline.transformer.config.in_channels,
369-
)
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+
)
370384
bsz = latents.shape[0]
371385
prompt_embeds = jax.random.normal(jax.random.key(config.seed), (batch_size, 512, 4096))
372386
timesteps = jnp.array([0] * bsz, dtype=jnp.int32)

0 commit comments

Comments
 (0)