{"record":{"id":"10a262dd9c094fb1","repo":"invoke-ai/InvokeAI","slug":"reference-image-dimensions-self-ref-image-width-10a262","errorCode":null,"errorMessage":"Reference-image dimensions ({self.ref_image.width}x{self.ref_image.height}) must match denoise dimensions ({self.width}x{self.height}).","messagePattern":"Reference-image dimensions \\((.+?)x(.+?)\\) must match denoise dimensions \\((.+?)x(.+?)\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/wan_video_denoise.py","lineNumber":213,"sourceCode":"            )\n\n        # I2V condition tensor. Two flavours:\n        #   * A14B I2V — [1, 20, T_lat, H_lat, W_lat] (4 mask + 16 latent channels).\n        #     Concatenated to noise latents along the channel dim each step → 36ch.\n        #   * TI2V-5B I2V — [1, 48, 1, H_lat, W_lat] (single latent frame, same\n        #     channel count as the noise latents). Blended with noise via a\n        #     first_frame_mask at every step (expand_timesteps path).\n        # Variant dispatch happens via the condition tensor's channel count below.\n        ref_condition: torch.Tensor | None = None\n        if self.ref_image is not None:\n            if variant not in (WanVariantType.I2V_A14B, WanVariantType.TI2V_5B):\n                raise ValueError(\n                    f\"Reference-image conditioning is only supported by Wan 2.2 I2V variants \"\n                    f\"(I2V-A14B or TI2V-5B). The selected transformer is {variant.value!r}. \"\n                    \"Remove the Reference Image input or load an I2V variant.\"\n                )\n            if self.ref_image.width != self.width or self.ref_image.height != self.height:\n                raise ValueError(\n                    f\"Reference-image dimensions ({self.ref_image.width}x{self.ref_image.height}) must \"\n                    f\"match denoise dimensions ({self.width}x{self.height}).\"\n                )\n            # A14B encodes one condition tensor per pixel-frame count, so the\n            # encoder's num_frames must match. TI2V-5B's condition is always\n            # single-frame regardless of the output length, so the field's\n            # num_frames is informational only and we skip this check.\n            if variant == WanVariantType.I2V_A14B and self.ref_image.num_frames != self.num_frames:\n                raise ValueError(\n                    f\"Reference-image num_frames ({self.ref_image.num_frames}) must match denoise \"\n                    f\"num_frames ({self.num_frames}). Re-run the Reference Image - Wan 2.2 node with \"\n                    f\"num_frames={self.num_frames}.\"\n                )\n            ref_condition = context.tensors.load(self.ref_image.condition_tensor_name).to(\n                device=device, dtype=inference_dtype\n            )\n            _validate_ref_condition_shape(\n                ref_condition,","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/wan_video_denoise.py#L195-L231","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nref_encoder.width, ref_encoder.height = 832, 480\ndenoise.width, denoise.height = 512, 512\n// after\nref_encoder.width, ref_encoder.height = 512, 512\ndenoise.width, denoise.height = 512, 512","handlingStrategy":"validation","validationCode":"if ref_image is not None and (ref_image.width != width or ref_image.height != height):\n    raise ValueError(f\"Ref {ref_image.width}x{ref_image.height} != denoise {width}x{height}; re-encode\")","typeGuard":null,"tryCatchPattern":"try:\n    tensor = denoise._run_diffusion(context)\nexcept ValueError as e:\n    if \"must match denoise dimensions\" in str(e):\n        ref_condition = re_encode_reference(width=width, height=height)\n    else:\n        raise","preventionTips":["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."],"tags":["validation","dimension-mismatch","reference-image","wan"],"backgroundTag":"dimension-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}