invoke-ai/InvokeAI · error · ValueError
Wan VAE decode produced zero frames.
Error message
Wan VAE decode produced zero frames.
What it means
After decoding, invoke() compares the number of decoded frames to zero and raises if the Wan VAE decode produced none. This catches degenerate decode results (e.g. empty/invalid latent input that slipped through, or a decode returning an empty tensor) before video encoding proceeds.
Source
Thrown at invokeai/app/invocations/wan_latents_to_video.py:222
_write_video_frames(writer, _iter_decoded_frames(chunk), context.util.is_canceled)
finally:
writer.close()
else:
# [C=3, T_pixel, H, W] in [-1, 1] (roughly), on CPU.
decoded = vae.decode(latents, return_dict=False)[0][0].cpu()
num_frames = decoded.shape[1]
del latents, latents_mean, latents_std
finally:
# The VAE instance is cached and shared; don't leak tiling into other nodes.
if use_tiling:
vae.disable_tiling()
TorchDevice.empty_cache()
if context.util.is_canceled():
raise CanceledException
if num_frames == 0:
raise ValueError("Wan VAE decode produced zero frames.")
if num_frames != t_pixel:
raise ValueError(f"Wan VAE decode produced {num_frames} frames; expected {t_pixel}.")
height, width = h_pixel, w_pixel
duration = num_frames / float(self.fps)
if decoded is not None:
context.logger.info(
f"Encoding MP4: {num_frames} frames @ {self.fps} fps "
f"({duration:.2f}s) at {width}x{height} via libx264"
)
context.util.signal_progress(f"Encoding MP4 ({num_frames} frames @ {self.fps} fps)")
writer = make_mp4_writer(tmp_path, self.fps)
try:
_write_video_frames(writer, _iter_decoded_frames(decoded), context.util.is_canceled)
finally:
writer.close()
del decoded
TorchDevice.empty_cache()View on GitHub (pinned to 0b6a024f2f)
Solutions
- Ensure latents have a valid temporal size and were produced by a Wan denoiser.
- Check the installed diffusers AutoencoderKLWan version for decode-output changes; upgrade/downgrade as needed.
- Inspect num_frames vs t_latent temporal scaling; verify frame_count/stride parameters are sane (>= 1).
Example fix
// before latents = denoise(num_frames=1) # decode yields 0 frames video = wan_latents_to_video(latents=latents) # ValueError // after latents = denoise(num_frames=21) # temporal stride-safe frame count video = wan_latents_to_video(latents=latents)
Defensive patterns
Strategy: validation
Validate before calling
expected = (latents.shape[2] - 1) * 4 + 1 # Wan temporal expansion
if expected <= 0:
raise ValueError("Latents would decode to zero frames; check temporal dim and frame_count params") Type guard
def decodes_to_frames(latents) -> bool:
return latents.ndim == 5 and latents.shape[2] > 0 and latents.shape[3] > 0 and latents.shape[4] > 0 Try / catch
try:
video = node.invoke(context)
except ValueError as e:
if "produced zero frames" in str(e):
latents = regenerate_latents(valid_frame_count=True)
video = node.invoke(context)
else:
raise Prevention
- Use Wan-conformant frame counts (4k+1) upstream.
- Verify diffusers/AutoencoderKLWan version matches the node's expectations.
- Never feed empty or placeholder latents to the video node.
- Log decode frame counts during pipeline bring-up.
When it happens
Trigger: VAE decode returning a tensor with zero temporal frames — typically after decoding empty or all-invalid latents, or a decode implementation quirk (e.g. t=1 latents producing 0 frames under a slicing scheme).
Common situations: Edge-case frame counts (single-frame videos) interacting badly with temporal slicing; corrupted latents; a VAE version whose decode output layout changed.
Related errors
- Wan VAE decode produced {num_frames} frames; expected {t_pix
- Concatenation produced zero output frames.
- Wan latents-to-video requires batch size 1; got {latents.sha
- Wan latents-to-video expects a 5D latent tensor [B, C, T, H,
- Wan latents-to-video requires non-empty temporal and spatial
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/741ede5bc2a6682f.
Report an issue: GitHub.