invoke-ai/InvokeAI · error · ValueError

These latents hold {latents.shape[2]} frames of video; this

Error message

These latents hold {latents.shape[2]} frames of video; this node decodes a single image. Use 'Latents to Video - Wan 2.2' (wan_l2v) for video latents.

What it means

A 5D latent tensor with T > 1 holds multi-frame video. Decoding it here would run the full multi-frame VAE decode under a single-frame working-memory estimate and crash in an opaque einops rank error at the final rearrange. The node checks T == 1 before the VAE is even loaded and directs the user to the Wan 2.2 latents-to-video node.

Source

Thrown at invokeai/app/invocations/wan_latents_to_image.py:65

    vae: VAEField = InputField(description=FieldDescriptions.vae, input=Input.Connection)

    @torch.no_grad()
    def invoke(self, context: InvocationContext) -> ImageOutput:
        latents = context.tensors.load(self.latents.latents_name)

        if latents.ndim not in (4, 5):
            raise ValueError(
                f"Wan latents-to-image expects a 4D or 5D latent tensor [B, C, (T), H, W]; got {tuple(latents.shape)}."
            )
        if latents.shape[0] != 1:
            raise ValueError(f"Wan latents-to-image requires batch size 1; got {latents.shape[0]}.")

        # This node decodes exactly one image. Multi-frame video latents would otherwise
        # run the full (expensive) multi-frame VAE decode — under a working-memory
        # estimate that assumed one frame — and then die in an opaque einops rank error
        # at the final rearrange. Checked before the VAE is even loaded.
        if latents.ndim == 5 and latents.shape[2] != 1:
            raise ValueError(
                f"These latents hold {latents.shape[2]} frames of video; this node decodes a single "
                "image. Use 'Latents to Video - Wan 2.2' (wan_l2v) for video latents."
            )

        vae_info = context.models.load(self.vae.vae)
        if not isinstance(vae_info.model, AutoencoderKLWan):
            raise TypeError(f"Expected AutoencoderKLWan for Wan VAE, got {type(vae_info.model).__name__}.")

        spatial_scale = getattr(vae_info.model.config, "scale_factor_spatial", None) or 8
        estimated_working_memory = estimate_vae_working_memory_wan(
            operation="decode",
            vae=vae_info.model,
            pixel_height=latents.shape[-2] * spatial_scale,
            pixel_width=latents.shape[-1] * spatial_scale,
            pixel_frames=1,
        )

        with vae_info.model_on_device(working_mem_bytes=estimated_working_memory) as (_, vae):

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Use the 'Latents to Video - Wan 2.2' (wan_l2v) node for multi-frame latents
  2. Or squeeze/trim latents to a single frame (latents[:, :, :1]) if you truly want one frame decoded
  3. Fix the workflow wiring so video outputs go to the video decode node

Example fix

// before
videoLatents (T=16) -> wanLatentsToImage  // error
// after
videoLatents -> wanLatentsToVideo (wan_l2v)
Defensive patterns

Strategy: validation

Validate before calling

if latents.ndim == 5 and latents.shape[2] != 1:
    raise ValueError("multi-frame video latents: use wan_l2v instead")

Type guard

def is_single_frame(t: torch.Tensor) -> bool:
    return t.ndim == 4 or (t.ndim == 5 and t.shape[2] == 1)

Try / catch

try:
    out = wan_latents_to_image.invoke(context)
except ValueError as e:
    if 'frames of video' in str(e):
        out = wan_l2v.invoke(context)  # route to video node
    else:
        raise

Prevention

When it happens

Trigger: Passing video latents from a Wan text/image-to-video generation into the image (single-frame) decode node; using a denoise output that produced multiple frames.

Common situations: Confusing 'Wan Latents to Image' with 'Latents to Video - Wan 2.2' (wan_l2v) in a video workflow; template edits that swapped the decode node.

Related errors


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