{"record":{"id":"6a21d8f9b17f1c97","repo":"Comfy-Org/ComfyUI","slug":"input-latent-has-lq-latent-shape-1-channels-th","errorCode":null,"errorMessage":"Input latent has {lq_latent.shape[1]} channels, this model variant expects {expected_c}. Flux1/SD3 = 16 channels, Flux2 = 128 channels.","messagePattern":"Input latent has (.+?) channels, this model variant expects (.+?)\\. Flux1/SD3 = 16 channels, Flux2 = 128 channels\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/pixeldit/pid.py","lineNumber":239,"sourceCode":"    def _pre_patch_block(self, s, i, pid_lq_features, pid_degrade_sigma, **kwargs):\n        if not self.lq_proj.is_gate_active(i):\n            return s\n        out_idx = self.lq_proj.output_index(i)\n        if out_idx >= len(pid_lq_features):\n            return s\n        return self.lq_proj.gate(s, pid_lq_features[out_idx], pid_degrade_sigma, out_idx)\n\n    def _pre_pixel_blocks(self, s, pid_pit_lq_feature=None, pid_degrade_sigma=None, **kwargs):\n        if pid_pit_lq_feature is None:\n            return s\n        return self.pit_lq_gate(s, pid_pit_lq_feature, pid_degrade_sigma)\n\n    def _forward(self, x, timesteps, context=None, attention_mask=None, transformer_options={}, lq_latent=None, degrade_sigma=None, **kwargs):\n        if lq_latent is None:\n            raise ValueError(\"PidNet requires lq_latent — attach via PiDConditioning\")\n        expected_c = self.lq_proj.latent_channels\n        if lq_latent.shape[1] != expected_c:\n            raise ValueError(\n                f\"Input latent has {lq_latent.shape[1]} channels, this model variant expects {expected_c}. \"\n                f\"Flux1/SD3 = 16 channels, Flux2 = 128 channels.\"\n            )\n        B = x.shape[0]\n        # Match the backbone's pad_to_patch_size (round up) so the LQ grid lines up with the patch stream.\n        Hs = -(-x.shape[2] // self.patch_size)\n        Ws = -(-x.shape[3] // self.patch_size)\n\n        degrade_sigma = degrade_sigma.to(device=x.device, dtype=torch.float32).reshape(-1)\n        if degrade_sigma.numel() == 1 and B > 1:\n            degrade_sigma = degrade_sigma.expand(B).contiguous()\n\n        lq_features = self.lq_proj(lq_latent=lq_latent.to(x), target_pH=Hs, target_pW=Ws)\n        pit_lq_feature = lq_features.pop() if self.pit_lq_inject else None\n\n        return super()._forward(\n            x, timesteps,\n            context=context, attention_mask=attention_mask,","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/pixeldit/pid.py#L221-L257","documentation":"PidNet checks that the supplied lq_latent channel count matches the channel count its lq projection was configured for (latent_channels of the loaded variant). Flux1/SD3 VAE latents have 16 channels while Flux2 uses 128, so mixing a Flux2 PiD model with a Flux1/SD3 VAE latent (or vice versa) fails here. The error text includes both observed and expected counts, making diagnosis direct.","triggerScenarios":"Attaching a PiD model variant built for 128-channel Flux2 latents but feeding a 16-channel SD3/Flux1 latent through PiDConditioning; or the reverse pairing. Also triggered by using a custom VAE with a non-standard latent channel count.","commonSituations":"Mixing checkpoints from different model families in one workflow (Flux2 base model with Flux1 PiD adapter); swapping the VAE override to an incompatible VAE; manually encoding the LQ image with the wrong VAE encode node.","solutions":["Match families: use the PiD variant trained for your base model (16-channel variant for Flux1/SD3, 128-channel variant for Flux2).","Encode the LQ image with the same VAE as the target model — do not mix a Flux1 VAE encode into a Flux2 workflow.","Check for a VAE override node forcing an incompatible VAE and remove it.","Read the printed expected_c in the message and compare with your latent's channel dimension to confirm which side is wrong."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def check_pid_channels(lq_latent, expected_channels):\n    c = lq_latent.shape[1]\n    if c != expected_channels:\n        raise ValueError(\n            f\"LQ latent has {c} channels but this PiD variant expects {expected_channels}; \"\n            \"match the PiD variant to your base model family (Flux1/SD3=16, Flux2=128)\"\n        )\n    return lq_latent","typeGuard":"def matches_pid_variant(lq_latent, variant) -> bool:\n    expected = {\"flux1\": 16, \"sd3\": 16, \"flux2\": 128}[variant]\n    return lq_latent.shape[1] == expected","tryCatchPattern":null,"preventionTips":["Keep PiD adapters and base models from the same family in one workflow.","Encode LQ images with the same VAE as the target model.","Log expected vs actual channel counts when building custom conditioning code."],"tags":["pixeldit","pidnet","channels","flux","latent-mismatch"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}