{"record":{"id":"9cbd224111e53591","repo":"Comfy-Org/ComfyUI","slug":"seedvr2-expected-name-to-be-5-d-native-latent-g","errorCode":null,"errorMessage":"SeedVR2 expected {name} to be 5-D native latent, got shape {tuple(x.shape)}.","messagePattern":"SeedVR2 expected (.+?) to be 5-D native latent, got shape (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/seedvr/model.py","lineNumber":1263,"sourceCode":"        if context.shape[0] % 2 != 0:\n            raise ValueError(f\"SeedVR2 expected an even text-conditioning batch, got shape {tuple(context.shape)}\")\n        neg_cond, pos_cond = context.chunk(2, dim=0)\n        if pos_cond.shape[0] == 1:\n            pos_cond, neg_cond = pos_cond.squeeze(0), neg_cond.squeeze(0)\n            return flatten([pos_cond, neg_cond])\n        return flatten((*pos_cond.unbind(0), *neg_cond.unbind(0)))\n\n    @staticmethod\n    def _seedvr2_is_single_conditioning_branch(cond_or_uncond):\n        if cond_or_uncond is None or len(cond_or_uncond) == 0:\n            return False\n        first = cond_or_uncond[0]\n        return all(entry == first for entry in cond_or_uncond)\n\n    @staticmethod\n    def _check_seedvr2_video_latent(x, channels, name):\n        if x.ndim != 5:\n            raise ValueError(f\"SeedVR2 expected {name} to be 5-D native latent, got shape {tuple(x.shape)}.\")\n        if x.shape[1] != channels:\n            raise ValueError(f\"SeedVR2 expected {name} channels to be {channels}, got shape {tuple(x.shape)}.\")\n        return x\n\n    def _swap_pos_neg_halves(self, out, cond_or_uncond=None):\n        if NaDiT._seedvr2_is_single_conditioning_branch(cond_or_uncond):\n            return out\n        pos, neg = out.chunk(2, dim=0)\n        return torch.cat([neg, pos], dim=0)\n\n    def forward(\n        self,\n        x,\n        timestep,\n        context,  # l c\n        disable_cache: bool = False,\n        **kwargs\n    ):","sourceCodeStart":1245,"sourceCodeEnd":1281,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/seedvr/model.py#L1245-L1281","documentation":"SeedVR2 is a video restoration transformer: every latent it touches must be a 5-D native video tensor [B, C, T, H, W]. _check_seedvr2_video_latent raises when ndim != 5, catching 4-D image latents ([B,C,H,W]) or already-flattened token streams before they hit the video reshape logic.","triggerScenarios":"Passing a standard 4-D image latent to SeedVR2 forward; passing the 'condition' kwarg a 4-D tensor from an image VAE encode; feeding output of a previous flatten() step back in as input.","commonSituations":"Trying to use a video-restoration model on a single image without the [B,C,1,H,W] video layout; mixing image workflow tensors into the SeedVR2 path; converting workflows from image models without adding the temporal dimension.","solutions":["Give tensors a temporal dimension: x = x.unsqueeze(2) to get [B,C,1,H,W] for single images.","Use the SeedVR2 latent/conditioning nodes, which produce 5-D tensors natively.","For single-image restoration, ensure the frame count also satisfies the T % patch_t == 1 rule (1 frame is valid).","Audit any custom adapters that strip or drop the time dimension."],"exampleFix":"# before\nx = image_latent          # [B, C, H, W]\nout = model(x, ...)\n# after\nx = image_latent.unsqueeze(2)  # [B, C, 1, H, W]\nout = model(x, ...)","handlingStrategy":"type-guard","validationCode":"def ensure_video_latent(x):\n    if x.dim() == 4:\n        x = x.unsqueeze(2)  # image -> [B, C, 1, H, W]\n    if x.dim() != 5:\n        raise ValueError(f\"SeedVR2 needs a 5-D latent [B,C,T,H,W], got {tuple(x.shape)}\")\n    return x","typeGuard":"def is_seedvr2_video_latent(x) -> bool:\n    import torch\n    return torch.is_tensor(x) and x.dim() == 5","tryCatchPattern":null,"preventionTips":["Wrap any image tensor entering a SeedVR2 path with unsqueeze(2).","Use SeedVR2 latent/conditioning nodes that emit 5-D tensors.","Assert ndim == 5 at adapter boundaries in custom pipelines."],"tags":["seedvr2","video","shape-mismatch","latent","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}