Comfy-Org/ComfyUI · error · ValueError
Unknown SeedVR2 VAE forward mode: {mode}
Error message
Unknown SeedVR2 VAE forward mode: {mode} What it means
SeedVR2 VAE forward() accepts only the literal modes "encode", "decode", and "all" (encode then decode). Any other string falls through the if-chain and raises a ValueError. This is a narrow dispatcher, so an unrecognized mode is always a caller bug, never a runtime data condition.
Source
Thrown at comfy/ldm/seedvr/vae.py:1440
self._decode(z_slices[z_idx], memory_state=MemoryState.ACTIVE, memory_cache=memory_cache)
)
out = torch.cat(decoded_slices, dim=2)
return out
else:
return self._decode(z)
def forward(self, x: torch.FloatTensor, mode: Literal["encode", "decode", "all"] = "all"):
def _unwrap(value):
return value[0] if isinstance(value, tuple) else value
if mode == "encode":
return _unwrap(self.encode(x))
if mode == "decode":
return _unwrap(self.decode_(x))
if mode == "all":
latent = _unwrap(self.encode(x))
return _unwrap(self.decode_(latent))
raise ValueError(f"Unknown SeedVR2 VAE forward mode: {mode}")
class VideoAutoencoderKLWrapper(VideoAutoencoderKL):
def __init__(
self,
spatial_downsample_factor = 8,
temporal_downsample_factor = 4,
):
self.spatial_downsample_factor = spatial_downsample_factor
self.temporal_downsample_factor = temporal_downsample_factor
super().__init__()
self.set_memory_limit(BYTEDANCE_VAE_CONV_MEM_GIB, BYTEDANCE_VAE_NORM_MEM_GIB)
def forward(self, x: torch.FloatTensor):
z, p = self._encode_with_raw_latent(x)
x = self.decode(z)
return x, z, p
def _encode_with_raw_latent(self, x):View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Pass one of the three supported literals: "encode", "decode", or "all".
- If the mode comes from user input, validate it against {"encode", "decode", "all"} before calling forward.
- Prefer calling encode()/decode_() directly instead of the mode dispatcher when only one operation is needed.
Example fix
# before out = vae(x, mode="enc") # after out = vae(x, mode="encode")
Defensive patterns
Strategy: validation
Validate before calling
VALID_MODES = {"encode", "decode", "all"}
if mode not in VALID_MODES:
raise ValueError(f"mode must be one of {VALID_MODES}, got {mode!r}")
out = vae.forward(x, mode=mode) Type guard
def is_seedvr_forward_mode(mode) -> bool:
return mode in ("encode", "decode", "all") Prevention
- Call encode()/decode_() directly instead of the mode dispatcher when possible.
- Validate user-supplied mode strings against the literal set before the call.
When it happens
Trigger: Calling vae.forward(x, mode="enc"), mode="auto", mode=None, or passing a mode variable that was never validated.
Common situations: Typos in workflow scripts; passing a mode read from a user config file or JSON without validation; refactoring code that used a different VAE class with more modes.
Related errors
- SeedVR2 decoder only supports UpDecoderBlock3D, got {up_bloc
- SeedVR2 VideoAutoencoderKLWrapper.decode: `seedvr2_tiling` m
- SeedVR2 VideoAutoencoderKLWrapper.decode: 5-D latent input m
- SeedVR2 VideoAutoencoderKLWrapper.decode: 4-D latent input m
- SeedVR2 VideoAutoencoderKLWrapper.decode: latent input must
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/b4db3cdb23bfb2a1.
Report an issue: GitHub.