ComfyUI WanVideo I2V fails in WanVideoVACEEncode with tensor size mismatch (32 vs 64)

Understanding the “WanVideo I2V fails in WanVideoVACEEncode” Tensor Size Mismatch (32 vs 64) Error in ComfyUI

ComfyUI has quickly become a go‑to visual programming environment for building complex AI pipelines, especially in the realm of generative video. One of its most exciting nodes, WanVideo I2V, enables image‑to‑video generation using the powerful WanVideoVACEEncode encoder. However, many users encounter a cryptic runtime error:

RuntimeError: Tensor size mismatch: expected 64 but got 32

This post dives deep into why this happens, how to diagnose it, and practical steps to resolve the issue.

1. What Is WanVideo I2V?

WanVideo I2V (Image‑to‑Video) is a node that takes a single or batch of images and produces a short video clip by leveraging a latent diffusion model. Internally, it performs three main stages:

  1. Encoding: The input image(s) are passed through WanVideoVACEEncode to obtain a latent representation.
  2. Temporal Diffusion: The latent is expanded across time steps and refined using a video diffusion model.
  3. Decoding: The final latent is decoded back into RGB frames.

The error we’re discussing occurs during the first stage – the encoding step.

2. Why the Tensor Size Mismatch Happens

The WanVideoVACEEncode node expects a latent tensor with a specific channel dimension. In most official configurations this dimension is 64. If the incoming tensor has only 32 channels, the underlying torch.nn.Conv2d (or a similar operation) throws the size‑mismatch exception.

Common reasons for receiving a 32‑channel tensor include:

  • Using a mismatched checkpoint: Loading a checkpoint trained for a 32‑channel latent space (e.g., a lightweight version of Stable Diffusion) while the node is configured for the default 64‑channel model.
  • Incorrect preprocessing: Downsampling or applying a torch.nn.Conv2d that reduces channel count before the encoder.
  • Batch size or dimension errors: Supplying a tensor shaped (B, 32, H, W) instead of (B, 64, H, W) due to a custom script or a previous node that altered the channel dimension.

3. Step‑by‑Step Debugging Guide

3.1 Verify Model Checkpoint

Open the Model Loader node attached to WanVideoVACEEncode and confirm you’re loading the official wanvideo_vace_64.pt (or similarly named) checkpoint. If you see a filename with _32 or lite, replace it with the 64‑channel version.

3.2 Inspect Tensor Shape Before Encoding

Add a Debug Tensor Shape node right before WanVideoVACEEncode. The output should read something like:

Tensor shape: (batch=1, channels=64, height=256, width=256)

If you see channels=32, trace back to the node that produces this tensor.

3.3 Check Pre‑Processing Nodes

Common culprits:

  • Resize or Crop nodes that inadvertently change channel count.
  • Custom Linear Projection nodes set to output 32 features.

Ensure these nodes either preserve the channel dimension or explicitly expand it back to 64 using a 1x1 Conv or Linear layer.

3.4 Review the “Latent Dim” Parameter

Some nodes expose a “latent dimension” field. It must be set to 64 for compatibility with WanVideoVACEEncode. A mismatch here will propagate downstream.

4. Fixes and Workarounds

4.1 Load the Correct Checkpoint

Replace the checkpoint path with the official 64‑channel model:

model_path = "models/wanvideo_vace_64.pt"

4.2 Insert a Channel‑Expansion Node

If you must use a 32‑channel latent (e.g., for memory constraints), add a Conv2d (1x1, out_channels=64) node right before the encoder:

torch.nn.Conv2d(in_channels=32, out_channels=64, kernel_size=1)

This projects the 32‑channel tensor into the required 64‑channel space.

4.3 Adjust the Encoder Configuration

Some advanced users edit the WanVideoVACEEncode source to accept 32 channels. This involves changing the first convolution layer’s in_channels argument and retraining or fine‑tuning the model – not recommended for most workflows.

4.4 Use a “Latent Upscale” Node

ComfyUI provides a Latent Upscale node that can increase channel dimensions while preserving spatial size. Set scale_factor=2 and mode=nearest to double the channels from 32 to 64.

5. Best Practices to Prevent Future Mismatches

  • Standardize on a single checkpoint version across the entire graph.
  • Document tensor shapes in comments or node labels.
  • Validate shapes after each major transformation using a Debug Tensor Shape node.
  • Keep a backup of a working pipeline configuration to revert quickly.

6. Conclusion

The “tensor size mismatch (32 vs 64)” error in WanVideoVACEEncode is almost always a symptom of a channel‑dimension inconsistency introduced earlier in the ComfyUI graph. By confirming you’re using the correct 64‑channel checkpoint, inspecting tensor shapes, and, if needed, inserting a channel‑expansion step, you can get WanVideo I2V back on track and generate stunning AI‑driven videos.

Happy compositing, and may your latent spaces always align! 🚀

Popular posts from this blog

Top 5 Free WHMCS Alternatives for 2025 (Open-Source & Zero-Cost Options)

Top 5 Free Hosting Providers in 2025