Fix get_dummy_wan_inputs for two-expert Wan2.2-I2V-A14B pipeline#427
Open
ThomasNing wants to merge 2 commits into
Open
Fix get_dummy_wan_inputs for two-expert Wan2.2-I2V-A14B pipeline#427ThomasNing wants to merge 2 commits into
ThomasNing 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. |
Perseus14
reviewed
Jun 24, 2026
Comment on lines
+361
to
+371
| 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: |
Collaborator
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
reviewed
Jun 24, 2026
Perseus14
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the PR. I have added a comment, PTAL!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.