{"record":{"id":"e7a4849e61e96f5c","repo":"Comfy-Org/ComfyUI","slug":"seedvr2-expected-name-channels-to-be-channels","errorCode":null,"errorMessage":"SeedVR2 expected {name} channels to be {channels}, got shape {tuple(x.shape)}.","messagePattern":"SeedVR2 expected (.+?) channels to be (.+?), got shape (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/seedvr/model.py","lineNumber":1265,"sourceCode":"        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    ):\n        transformer_options = kwargs.get(\"transformer_options\", {})\n        patches_replace = transformer_options.get(\"patches_replace\", {})","sourceCodeStart":1247,"sourceCodeEnd":1283,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/seedvr/model.py#L1247-L1283","documentation":"The companion check to the 5-D guard: SeedVR2 requires exactly the expected channel count on the video latent axis 1 (SEEDVR2_LATENT_CHANNELS for the noisy latent, that +1 for the conditioning latent which carries an extra mask channel). A different channel count means the wrong VAE or wrong tensor was supplied.","triggerScenarios":"Passing a conditioning latent with the same channel count as the noise latent (missing the extra conditioning channel); using a non-SeedVR2 VAE to encode; concatenating a mask incorrectly so channel count is off by more or less than one.","commonSituations":"Building SeedVR2 conditioning by hand instead of using SeedVR2Conditioning; swapping in an SD VAE (4-ch) or other VAE encode output; a conversion script that drops the appended mask channel.","solutions":["Generate the conditioning latent with the SeedVR2Conditioning node so channel counts are exact.","If building by hand, append exactly one mask channel to the LQ latent: cond = torch.cat([lq_latent, mask], dim=1).","Encode inputs only with the SeedVR2 VAE; remove incompatible VAE overrides.","Compare x.shape[1] with the expected value printed in the message to identify which tensor is wrong."],"exampleFix":"# before\ncond = lq_latent  # same channels as x\n# after\nmask = torch.ones_like(lq_latent[:, :1])\ncond = torch.cat([lq_latent, mask], dim=1)  # latent_channels + 1","handlingStrategy":"validation","validationCode":"def check_latent_channels(x, expected, name):\n    if x.shape[1] != expected:\n        raise ValueError(f\"{name} must have {expected} channels, got {x.shape[1]} (shape {tuple(x.shape)})\")\n    return x","typeGuard":"def channels_match(x, expected) -> bool:\n    return x.dim() == 5 and x.shape[1] == expected","tryCatchPattern":null,"preventionTips":["Build conditioning with the SeedVR2Conditioning node rather than manual concatenation.","Append exactly one mask channel when constructing conditioning by hand.","Never substitute another VAE's latent into a SeedVR2 workflow."],"tags":["seedvr2","channels","conditioning","latent","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}