invoke-ai/InvokeAI · error · ValueError
Reference-image dimensions ({self.ref_image.width}x{self.ref
Error message
Reference-image dimensions ({self.ref_image.width}x{self.ref_image.height}) must match denoise dimensions ({self.width}x{self.height}). What it means
The A14B reference condition tensor is spatially aligned with the denoise latents, so the reference image's width/height (baked in at encode time) must exactly match the denoise node's width/height. InvokeAI raises ValueError on any mismatch rather than resizing, which would corrupt the conditioning geometry.
Source
Thrown at invokeai/app/invocations/wan_video_denoise.py:213
)
# I2V condition tensor. Two flavours:
# * A14B I2V — [1, 20, T_lat, H_lat, W_lat] (4 mask + 16 latent channels).
# Concatenated to noise latents along the channel dim each step → 36ch.
# * TI2V-5B I2V — [1, 48, 1, H_lat, W_lat] (single latent frame, same
# channel count as the noise latents). Blended with noise via a
# first_frame_mask at every step (expand_timesteps path).
# Variant dispatch happens via the condition tensor's channel count below.
ref_condition: torch.Tensor | None = None
if self.ref_image is not None:
if variant not in (WanVariantType.I2V_A14B, WanVariantType.TI2V_5B):
raise ValueError(
f"Reference-image conditioning is only supported by Wan 2.2 I2V variants "
f"(I2V-A14B or TI2V-5B). The selected transformer is {variant.value!r}. "
"Remove the Reference Image input or load an I2V variant."
)
if self.ref_image.width != self.width or self.ref_image.height != self.height:
raise ValueError(
f"Reference-image dimensions ({self.ref_image.width}x{self.ref_image.height}) must "
f"match denoise dimensions ({self.width}x{self.height})."
)
# A14B encodes one condition tensor per pixel-frame count, so the
# encoder's num_frames must match. TI2V-5B's condition is always
# single-frame regardless of the output length, so the field's
# num_frames is informational only and we skip this check.
if variant == WanVariantType.I2V_A14B and self.ref_image.num_frames != self.num_frames:
raise ValueError(
f"Reference-image num_frames ({self.ref_image.num_frames}) must match denoise "
f"num_frames ({self.num_frames}). Re-run the Reference Image - Wan 2.2 node with "
f"num_frames={self.num_frames}."
)
ref_condition = context.tensors.load(self.ref_image.condition_tensor_name).to(
device=device, dtype=inference_dtype
)
_validate_ref_condition_shape(
ref_condition,View on GitHub (pinned to 0b6a024f2f)
Solutions
- Set the Reference Image node's width/height to exactly the denoise node's width/height (or vice versa).
- Use the same shared resolution constants/fields in both nodes so they cannot diverge.
- Re-run the Reference Image - Wan 2.2 node after any resolution change.
Example fix
// before ref_encoder.width, ref_encoder.height = 832, 480 denoise.width, denoise.height = 512, 512 // after ref_encoder.width, ref_encoder.height = 512, 512 denoise.width, denoise.height = 512, 512
Defensive patterns
Strategy: validation
Validate before calling
if ref_image is not None and (ref_image.width != width or ref_image.height != height):
raise ValueError(f"Ref {ref_image.width}x{ref_image.height} != denoise {width}x{height}; re-encode") Try / catch
try:
tensor = denoise._run_diffusion(context)
except ValueError as e:
if "must match denoise dimensions" in str(e):
ref_condition = re_encode_reference(width=width, height=height)
else:
raise Prevention
- Bind width/height to shared workflow fields used by both nodes.
- Re-run the reference encoder whenever output resolution changes.
- Don't hardcode resolution in one node and leave the other on template defaults.
When it happens
Trigger: Encoding a reference image at, say, 832x480 in the Reference Image node, then setting Wan Video Denoise width/height to 512x512 (or any other size).
Common situations: Changing output resolution in the denoise node after encoding, or using separate width/height fields in the two nodes that drifted apart; common when building workflows from templates with different defaults.
Related errors
- Reference-image conditioning is only supported by Wan 2.2 I2
- Reference-image num_frames ({self.ref_image.num_frames}) mus
- TI2V-5B requires width and height to be multiples of 32 (got
- Wan reference condition must be a 5D tensor; got shape {tupl
- Source longer side ({long_side}px) is smaller than the Wan p
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/10a262dd9c094fb1.
Report an issue: GitHub.