{"record":{"id":"9c86b8be915575ad","repo":"Comfy-Org/ComfyUI","slug":"seedvr2-vae-convolution-requires-an-explicit-memor","errorCode":null,"errorMessage":"SeedVR2 VAE convolution requires an explicit MemoryState.","messagePattern":"SeedVR2 VAE convolution requires an explicit MemoryState\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/seedvr/vae.py","lineNumber":581,"sourceCode":"                x[idx],\n                split_dim=split_dim + 1,\n                padding=padding,\n                prev_cache=cache\n            )\n\n            cache = next_cache\n\n        output = torch.cat(x, dim=split_dim)\n        return output\n\n    def forward(\n        self,\n        input,\n        memory_state: MemoryState = MemoryState.UNSET,\n        memory_cache = None,\n    ) -> Tensor:\n        if memory_state == MemoryState.UNSET:\n            raise ValueError(\"SeedVR2 VAE convolution requires an explicit MemoryState.\")\n        if memory_cache is None:\n            memory_cache = {}\n        if memory_state != MemoryState.ACTIVE:\n            memory_cache.pop(self, None)\n        if (\n            math.isinf(self.memory_limit)\n            and torch.is_tensor(input)\n        ):\n            return self.basic_forward(input, memory_state, memory_cache)\n        return self.slicing_forward(input, memory_state, memory_cache)\n\n    def basic_forward(self, input: Tensor, memory_state: MemoryState = MemoryState.UNSET, memory_cache = None):\n        mem_size = self.stride[0] - self.kernel_size[0]\n        memory = memory_cache.get(self) if memory_cache is not None else None\n        if (memory is not None) and (memory_state == MemoryState.ACTIVE):\n            input = extend_head(input, memory=memory, times=-1)\n        else:\n            input = extend_head(input, times=self.temporal_padding * 2)","sourceCodeStart":563,"sourceCodeEnd":599,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/seedvr/vae.py#L563-L599","documentation":"SeedVR2 VAE convolutions are streaming-aware: their forward requires an explicit MemoryState enum (ACTIVE for streaming with cache, or another state for non-streaming) because cache lifecycle management differs per state. The default parameter is MemoryState.UNSET, and any call that did not deliberately choose a state raises immediately — this is an API-contract guard, not a runtime data problem.","triggerScenarios":"Calling SeedVR2VaeConv forward directly (custom code, ported modules) without memory_state; wrapping the VAE in a tool that re-invokes submodules with default args; calling basic_forward-adjacent paths that forget the parameter.","commonSituations":"Custom node or research code reusing SeedVR2 VAE blocks; copying the module into another codebase and calling conv(x) idiomatically; migration from a diffusers-style API that had no memory state concept.","solutions":["Pass an explicit memory_state, e.g. memory_state=MemoryState.BASIC (non-cached) for a one-shot call, or ACTIVE within the VAE's own streaming loop.","Prefer calling the VAE's public encode/decode rather than individual conv modules.","If porting the module, thread memory_state through your call chain the same way SeedVR2 VAE code does.","Check the MemoryState enum values in comfy/ldm/seedvr/vae.py to pick the right state."],"exampleFix":"# before\ny = conv_block(x)\n# after\nfrom comfy.ldm.seedvr.vae import MemoryState\ny = conv_block(x, memory_state=MemoryState.BASIC)","handlingStrategy":"validation","validationCode":"from comfy.ldm.seedvr.vae import MemoryState\n\ndef call_conv(conv, x, streaming=False):\n    state = MemoryState.ACTIVE if streaming else MemoryState.BASIC\n    return conv(x, memory_state=state, memory_cache={})","typeGuard":"def is_valid_memory_state(s) -> bool:\n    from comfy.ldm.seedvr.vae import MemoryState\n    return s in MemoryState._value2member_map_","tryCatchPattern":null,"preventionTips":["Always pass an explicit memory_state when calling SeedVR2 VAE conv modules directly.","Call the VAE's public encode/decode instead of individual conv blocks.","Thread memory_state through custom wrappers — never rely on the default."],"tags":["seedvr2","vae","api-contract","streaming"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}