{"record":{"id":"b4db3cdb23bfb2a1","repo":"Comfy-Org/ComfyUI","slug":"unknown-seedvr2-vae-forward-mode-mode","errorCode":null,"errorMessage":"Unknown SeedVR2 VAE forward mode: {mode}","messagePattern":"Unknown SeedVR2 VAE forward mode: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/seedvr/vae.py","lineNumber":1440,"sourceCode":"                    self._decode(z_slices[z_idx], memory_state=MemoryState.ACTIVE, memory_cache=memory_cache)\n                )\n            out = torch.cat(decoded_slices, dim=2)\n            return out\n        else:\n            return self._decode(z)\n\n    def forward(self, x: torch.FloatTensor, mode: Literal[\"encode\", \"decode\", \"all\"] = \"all\"):\n        def _unwrap(value):\n            return value[0] if isinstance(value, tuple) else value\n\n        if mode == \"encode\":\n            return _unwrap(self.encode(x))\n        if mode == \"decode\":\n            return _unwrap(self.decode_(x))\n        if mode == \"all\":\n            latent = _unwrap(self.encode(x))\n            return _unwrap(self.decode_(latent))\n        raise ValueError(f\"Unknown SeedVR2 VAE forward mode: {mode}\")\n\nclass VideoAutoencoderKLWrapper(VideoAutoencoderKL):\n    def __init__(\n        self,\n        spatial_downsample_factor = 8,\n        temporal_downsample_factor = 4,\n    ):\n        self.spatial_downsample_factor = spatial_downsample_factor\n        self.temporal_downsample_factor = temporal_downsample_factor\n        super().__init__()\n        self.set_memory_limit(BYTEDANCE_VAE_CONV_MEM_GIB, BYTEDANCE_VAE_NORM_MEM_GIB)\n\n    def forward(self, x: torch.FloatTensor):\n        z, p = self._encode_with_raw_latent(x)\n        x = self.decode(z)\n        return x, z, p\n\n    def _encode_with_raw_latent(self, x):","sourceCodeStart":1422,"sourceCodeEnd":1458,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/seedvr/vae.py#L1422-L1458","documentation":"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.","triggerScenarios":"Calling vae.forward(x, mode=\"enc\"), mode=\"auto\", mode=None, or passing a mode variable that was never validated.","commonSituations":"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.","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."],"exampleFix":"# before\nout = vae(x, mode=\"enc\")\n# after\nout = vae(x, mode=\"encode\")","handlingStrategy":"validation","validationCode":"VALID_MODES = {\"encode\", \"decode\", \"all\"}\nif mode not in VALID_MODES:\n    raise ValueError(f\"mode must be one of {VALID_MODES}, got {mode!r}\")\nout = vae.forward(x, mode=mode)","typeGuard":"def is_seedvr_forward_mode(mode) -> bool:\n    return mode in (\"encode\", \"decode\", \"all\")","tryCatchPattern":null,"preventionTips":["Call encode()/decode_() directly instead of the mode dispatcher when possible.","Validate user-supplied mode strings against the literal set before the call."],"tags":["seedvr","vae","forward","invalid-argument"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}