{"record":{"id":"741ede5bc2a6682f","repo":"invoke-ai/InvokeAI","slug":"wan-vae-decode-produced-zero-frames","errorCode":null,"errorMessage":"Wan VAE decode produced zero frames.","messagePattern":"Wan VAE decode produced zero frames\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/wan_latents_to_video.py","lineNumber":222,"sourceCode":"                                    _write_video_frames(writer, _iter_decoded_frames(chunk), context.util.is_canceled)\n                            finally:\n                                writer.close()\n                        else:\n                            # [C=3, T_pixel, H, W] in [-1, 1] (roughly), on CPU.\n                            decoded = vae.decode(latents, return_dict=False)[0][0].cpu()\n                            num_frames = decoded.shape[1]\n                        del latents, latents_mean, latents_std\n                finally:\n                    # The VAE instance is cached and shared; don't leak tiling into other nodes.\n                    if use_tiling:\n                        vae.disable_tiling()\n\n            TorchDevice.empty_cache()\n\n            if context.util.is_canceled():\n                raise CanceledException\n            if num_frames == 0:\n                raise ValueError(\"Wan VAE decode produced zero frames.\")\n            if num_frames != t_pixel:\n                raise ValueError(f\"Wan VAE decode produced {num_frames} frames; expected {t_pixel}.\")\n\n            height, width = h_pixel, w_pixel\n            duration = num_frames / float(self.fps)\n            if decoded is not None:\n                context.logger.info(\n                    f\"Encoding MP4: {num_frames} frames @ {self.fps} fps \"\n                    f\"({duration:.2f}s) at {width}x{height} via libx264\"\n                )\n                context.util.signal_progress(f\"Encoding MP4 ({num_frames} frames @ {self.fps} fps)\")\n                writer = make_mp4_writer(tmp_path, self.fps)\n                try:\n                    _write_video_frames(writer, _iter_decoded_frames(decoded), context.util.is_canceled)\n                finally:\n                    writer.close()\n                del decoded\n                TorchDevice.empty_cache()","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/wan_latents_to_video.py#L204-L240","documentation":"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.","triggerScenarios":"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).","commonSituations":"Edge-case frame counts (single-frame videos) interacting badly with temporal slicing; corrupted latents; a VAE version whose decode output layout changed.","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)."],"exampleFix":"// before\nlatents = denoise(num_frames=1)  # decode yields 0 frames\nvideo = wan_latents_to_video(latents=latents)  # ValueError\n// after\nlatents = denoise(num_frames=21)  # temporal stride-safe frame count\nvideo = wan_latents_to_video(latents=latents)","handlingStrategy":"validation","validationCode":"expected = (latents.shape[2] - 1) * 4 + 1  # Wan temporal expansion\nif expected <= 0:\n    raise ValueError(\"Latents would decode to zero frames; check temporal dim and frame_count params\")","typeGuard":"def decodes_to_frames(latents) -> bool:\n    return latents.ndim == 5 and latents.shape[2] > 0 and latents.shape[3] > 0 and latents.shape[4] > 0","tryCatchPattern":"try:\n    video = node.invoke(context)\nexcept ValueError as e:\n    if \"produced zero frames\" in str(e):\n        latents = regenerate_latents(valid_frame_count=True)\n        video = node.invoke(context)\n    else:\n        raise","preventionTips":["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."],"tags":["wan","vae-decode","empty-output","video"],"backgroundTag":"empty-decode-output","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}