invoke-ai/InvokeAI · error · ValueError

TI2V-5B I2V requires width and height to be multiples of 32

Error message

TI2V-5B I2V requires width and height to be multiples of 32 (got {self.width}x{self.height}). The Wan 2.2-VAE uses 16x spatial compression and the transformer adds a 2x patch on top, so pixel dims must divide by 32 for the patchify step.

What it means

TI2V-5B uses the Wan 2.2 VAE with 16x spatial compression and a transformer patch size of (1,2,2), so latent H/W must be even; that means pixel width and height must be multiples of 32. InvokeAI raises ValueError when they are not, because the patchify step would otherwise fail on odd latent dimensions.

Source

Thrown at invokeai/app/invocations/wan_ref_image_encoder.py:163

            # Pick the encoder path by VAE z_dim: 48 means the Wan 2.2-VAE (TI2V-5B),
            # which uses a single-frame 48-channel condition that the denoise loop
            # blends with the noisy latents at every step (expand_timesteps path).
            # 16 means the standard Wan VAE (A14B), which uses the 20-channel
            # mask + latent condition concatenated to noise along the channel dim.
            is_ti2v_5b = getattr(vae.config, "z_dim", 16) == 48
            if end_pil_image is not None and (is_ti2v_5b or self.num_frames <= 1):
                raise ValueError(
                    "End-image (FLF2V) interpolation is only supported for I2V-A14B video "
                    f"(num_frames > 1). Got {'TI2V-5B' if is_ti2v_5b else 'single-frame I2V'}. "
                    "Remove the End Image input, or use an A14B VAE with num_frames > 1."
                )
            if is_ti2v_5b:
                # TI2V-5B I2V needs latent H/W to be even for the transformer
                # patch_size=(1,2,2), so pixel dims must be multiples of 32
                # (16x VAE * 2 transformer patch). A14B's 8x VAE only needed
                # multiples of 16.
                if self.width % 32 != 0 or self.height % 32 != 0:
                    raise ValueError(
                        f"TI2V-5B I2V requires width and height to be multiples of 32 "
                        f"(got {self.width}x{self.height}). The Wan 2.2-VAE uses 16x "
                        f"spatial compression and the transformer adds a 2x patch on "
                        f"top, so pixel dims must divide by 32 for the patchify step."
                    )
                condition = encode_reference_image_to_ti2v_condition(
                    image=pil_image,
                    vae=vae,
                    width=self.width,
                    height=self.height,
                    device=device,
                    dtype=target_dtype,
                )
            elif self.num_frames <= 1:
                condition = encode_reference_image_to_condition(
                    image=pil_image,
                    vae=vae,
                    width=self.width,

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Round width and height up to the nearest multiple of 32 (e.g. 832x480 -> 832x480 is fine since 32*26 and 32*15; 512x704 works; 848 -> 864).
  2. Use standard 32-multiple resolutions like 1280x704 or 960x544 for TI2V-5B.
  3. Switch to the A14B VAE/transformer if you need finer 16-pixel granularity.

Example fix

// before
width, height = 816, 480  # 816 % 32 != 0
// after
width, height = 832, 480  # both multiples of 32
Defensive patterns

Strategy: validation

Validate before calling

assert is_ti2v_5b is False or (width % 32 == 0 and height % 32 == 0), \
    f"TI2V-5B needs multiples of 32, got {width}x{height}"
width, height = (w + 31) // 32 * 32, (h + 31) // 32 * 32

Try / catch

try:
    out = encoder.invoke(context)
except ValueError as e:
    if "multiples of 32" in str(e):
        width, height = (width + 31) // 32 * 32, (height + 31) // 32 * 32
    else:
        raise

Prevention

When it happens

Trigger: Running wan_ref_image_encoder with a TI2V-5B VAE and width/height not divisible by 32, e.g. 512x704, 1024x576, or any multiple of 8/16 that isn't a multiple of 32.

Common situations: Reusing dimensions tuned for A14B (8x VAE, multiples of 16 suffice, e.g. 832x480) and applying them to TI2V-5B.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/a59e5cf308444019. Report an issue: GitHub.