Comfy-Org/ComfyUI · error · RuntimeError
SeedVR2 VideoAutoencoderKLWrapper.decode: 4-D latent input m
Error message
SeedVR2 VideoAutoencoderKLWrapper.decode: 4-D latent input must use collapsed channel layout (B, {SEEDVR2_LATENT_CHANNELS}*T, H, W); got shape {tuple(z.shape)}. What it means
decode() accepts a 4-D latent in the collapsed layout (B, SEEDVR2_LATENT_CHANNELS*T, H, W); the channel dimension must be an exact multiple of SEEDVR2_LATENT_CHANNELS so it can be unambiguously reshaped to (B, C, T, H, W). A non-divisible channel count means the tensor is not a SeedVR2 latent in that layout, and reshape would either fail or silently scramble frames.
Source
Thrown at comfy/ldm/seedvr/vae.py:1489
seedvr2_tiling = {} if seedvr2_tiling is None else seedvr2_tiling
if not isinstance(seedvr2_tiling, dict):
raise RuntimeError(
"SeedVR2 VideoAutoencoderKLWrapper.decode: `seedvr2_tiling` must be a dict; "
f"got {type(seedvr2_tiling).__name__} with value {seedvr2_tiling!r}."
)
if z.ndim == 5:
_, c, _, _, _ = z.shape
if c != SEEDVR2_LATENT_CHANNELS:
raise RuntimeError(
"SeedVR2 VideoAutoencoderKLWrapper.decode: 5-D latent input must "
f"have {SEEDVR2_LATENT_CHANNELS} channels; got shape {tuple(z.shape)}."
)
latent = z
elif z.ndim == 4:
b, tc, h, w = z.shape
if tc % SEEDVR2_LATENT_CHANNELS != 0:
raise RuntimeError(
"SeedVR2 VideoAutoencoderKLWrapper.decode: 4-D latent input must "
f"use collapsed channel layout (B, {SEEDVR2_LATENT_CHANNELS}*T, H, W); "
f"got shape {tuple(z.shape)}."
)
latent = z.reshape(b, SEEDVR2_LATENT_CHANNELS, -1, h, w)
else:
raise RuntimeError(
"SeedVR2 VideoAutoencoderKLWrapper.decode: latent input must be "
f"4-D collapsed (B, {SEEDVR2_LATENT_CHANNELS}*T, H, W) or "
f"5-D (B, {SEEDVR2_LATENT_CHANNELS}, T, H, W); "
f"got shape {tuple(z.shape)}."
)
scale = BYTEDANCE_VAE_SCALING_FACTOR
shift = BYTEDANCE_VAE_SHIFTING_FACTOR
latent = latent / scale + shift
self.device = latent.device
enable_tiling = seedvr2_tiling.get("enable_tiling", False)View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Verify the tensor is a SeedVR2 latent in collapsed layout and that z.shape[1] is a multiple of SEEDVR2_LATENT_CHANNELS.
- If you built the collapsed layout yourself, keep the full channel dim: torch.cat over time must produce C*T channels, not fewer.
- Use the 5-D form when T is ambiguous.
Example fix
# before out = vae.decode(rgb_image) # (B,3,H,W): 3 % latent_channels != 0 # after latent = vae.encode(rgb_image) # collapsed SeedVR2 latent out = vae.decode(latent)
Defensive patterns
Strategy: validation
Validate before calling
if z.ndim == 4 and z.shape[1] % SEEDVR2_LATENT_CHANNELS != 0:
raise ValueError(f"collapsed channel dim {z.shape[1]} is not a multiple of {SEEDVR2_LATENT_CHANNELS}")
vae.decode(z) Type guard
def is_valid_4d_seedvr_latent(z) -> bool:
return z.ndim == 4 and z.shape[1] % SEEDVR2_LATENT_CHANNELS == 0 Prevention
- Never pass raw images or other-VAE latents to the SeedVR2 decoder.
- Log latent shapes at pipeline boundaries to catch wrong sources early.
When it happens
Trigger: decode(z) with z.ndim == 4 and z.shape[1] % SEEDVR2_LATENT_CHANNELS != 0 — e.g. passing a 4-channel SD latent or a 3-channel RGB image tensor.
Common situations: Passing a latent from a different VAE (4/8/16 channels with a different channel count basis); passing raw images instead of latents; truncating or slicing the latent channel dim.
Related errors
- SeedVR2 VideoAutoencoderKLWrapper.decode: 5-D latent input m
- SeedVR2 VideoAutoencoderKLWrapper.decode: `seedvr2_tiling` m
- SeedVR2 VideoAutoencoderKLWrapper.decode: latent input must
- SeedVR2 decoder only supports UpDecoderBlock3D, got {up_bloc
- Unknown SeedVR2 VAE forward mode: {mode}
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/73b320db29e64b5e.
Report an issue: GitHub.