Fix get_dummy_wan_inputs for two-expert Wan2.2-I2V-A14B pipeline#427
Fix get_dummy_wan_inputs for two-expert Wan2.2-I2V-A14B pipeline#427ThomasNing wants to merge 2 commits into
Conversation
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.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
| if getattr(pipeline, "transformer", None) is not None: | ||
| latents = pipeline.prepare_latents( | ||
| batch_size, | ||
| vae_scale_factor_temporal=pipeline.vae_scale_factor_temporal, | ||
| vae_scale_factor_spatial=pipeline.vae_scale_factor_spatial, | ||
| height=config.height, | ||
| width=config.width, | ||
| num_frames=config.num_frames, | ||
| num_channels_latents=pipeline.transformer.config.in_channels, | ||
| ) | ||
| else: |
There was a problem hiding this comment.
Good catch! Wondering instead of an if/else block, can we make this cleaner and more robust by completely decoupling the dummy generation from the pipeline methods and generate the inputs uniformly for all pipeline variants?
Perseus14
left a comment
There was a problem hiding this comment.
Thanks for the PR. I have added a comment, PTAL!
|
@Perseus14 Hi Rishabh, could you take another look? |
|
LGTM! Could you please run this linting check? For some reason that test is not being triggered.
If no errors, will approve the PR |
Problem
get_dummy_wan_inputs(called byWanPipeline.quantize_transformer→qwix.quantize_model) assumes a singlepipeline.transformerand the single-transformerprepare_latents()signature. The two-expertWanPipelineI2V_2_2(Wan2.2-I2V-A14B) haslow_noise_transformer/high_noise_transformer(no.transformer) and a differentprepare_latents()signature, souse_qwix_quantization=Truecrashes:and, once that's worked around:
Fix
When
pipeline.transformeris absent (two-expert pipeline), build the dummy latents directly in the(B, C, F, H, W)layoutWanModel.__call__expects, takingnum_channels_latentsfrom an existing expert (low_noise_transformer). The single-transformer path is unchanged.Validation
On Wan2.2-I2V-A14B (TPU v6e-16, 1080p, 4-step): with this change, quantization proceeds past both errors above into
qwix.quantize_model(the model forward traces correctly with(latents, timesteps, prompt_embeds)). A separate qwix↔JAX version issue (conv_general_dilated() got an unexpected keyword argument 'out_sharding') then surfaces in our environment — unrelated to this change.