{"record":{"id":"565ef5881fbc859f","repo":"Comfy-Org/ComfyUI","slug":"seedvr2-conditioning-shape-must-match-latent-batch","errorCode":null,"errorMessage":"SeedVR2 conditioning shape must match latent batch/temporal/spatial dimensions; got latent {tuple(x.shape)} and conditioning {tuple(conditions.shape)}.","messagePattern":"SeedVR2 conditioning shape must match latent batch/temporal/spatial dimensions; got latent (.+?) and conditioning (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/seedvr/model.py","lineNumber":1292,"sourceCode":"    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\", {})\n        blocks_replace = patches_replace.get(\"dit\", {})\n        conditions = kwargs.get(\"condition\")\n        if conditions is None:\n            raise ValueError(\"SeedVR2 requires conditioning latents from the SeedVR2Conditioning node.\")\n        x = self._check_seedvr2_video_latent(x, SEEDVR2_LATENT_CHANNELS, \"latent\")\n        conditions = self._check_seedvr2_video_latent(conditions, SEEDVR2_LATENT_CHANNELS + 1, \"conditioning\")\n        b, _, t, h, w = x.shape\n        if conditions.shape[0] != b or conditions.shape[2:] != (t, h, w):\n            raise ValueError(\n                f\"SeedVR2 conditioning shape must match latent batch/temporal/spatial dimensions; got latent {tuple(x.shape)} and conditioning {tuple(conditions.shape)}.\"\n            )\n        x = x.movedim(1, -1)\n        conditions = conditions.movedim(1, -1)\n        cache = Cache(disable=disable_cache)\n\n        txt, txt_shape = self._resolve_text_conditioning(context, transformer_options.get(\"cond_or_uncond\"))\n\n        vid, vid_shape = flatten(x)\n        cond_latent, _ = flatten(conditions)\n\n        vid = torch.cat([vid, cond_latent], dim=-1)\n\n        txt = self.txt_in(txt)\n\n        vid_shape_before_patchify = vid_shape\n        vid, vid_shape = self.vid_in(vid, vid_shape, cache=cache)\n","sourceCodeStart":1274,"sourceCodeEnd":1310,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/seedvr/model.py#L1274-L1310","documentation":"After channel/ndim checks, SeedVR2 requires the conditioning latent to match the noisy latent in batch, temporal, and spatial dims (conditions.shape[0] == b and conditions.shape[2:] == (t, h, w)) because they are concatenated token-wise after flattening. Any mismatch — different resolution, frame count, or batch — aborts with both shapes printed.","triggerScenarios":"Encoding the LQ/reference video at a different resolution or frame count than the generation target; batch size of the conditioning differing from the latent batch; cropping/trimming one input but not the other.","commonSituations":"Upscaling workflows where the LQ video was resized to the target resolution with slightly different rounding (off-by-one dims); frame-count changes after trimming to satisfy T % t == 1 on only one side; batch-2 sampling with a batch-1 conditioning latent.","solutions":["Make the LQ conditioning video exactly the target latent's T/H/W (match resolution and frame count before VAE encode).","Ensure batch dims agree — replicate the conditioning if you batch the latent.","Apply the same temporal trimming (T % t == 1) to both latent and conditioning.","Use the SeedVR2Conditioning node, which validates alignment, instead of manual concatenation."],"exampleFix":"# before\ncond = lq_latent  # encoded at 720x1280, latent is 724x1284\n# after\nlq = torch.nn.functional.interpolate(lq_video, size=(T, H_out, W_out), mode='trilinear')\ncond = seedvr_vae.encode(lq)  # same T,H,W as target latent","handlingStrategy":"validation","validationCode":"def check_conditioning_alignment(x, cond):\n    b, _, t, h, w = x.shape\n    if cond.shape[0] != b or cond.shape[2:] != (t, h, w):\n        raise ValueError(\n            f\"conditioning {tuple(cond.shape)} must match latent (b={b}, t={t}, h={h}, w={w})\"\n        )\n    return cond","typeGuard":"def conditioning_aligned(x, cond) -> bool:\n    return cond.dim() == 5 and cond.shape[0] == x.shape[0] and cond.shape[2:] == x.shape[2:]","tryCatchPattern":null,"preventionTips":["Encode LQ and target at identical resolution and frame counts.","Apply identical temporal trimming to latent and conditioning.","Replicate the conditioning tensor when batching the latent."],"tags":["seedvr2","shape-mismatch","conditioning","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}