{"record":{"id":"37f9fe94a32c1f3f","repo":"Comfy-Org/ComfyUI","slug":"pidnet-requires-lq-latent-attach-via-pidconditio","errorCode":null,"errorMessage":"PidNet requires lq_latent — attach via PiDConditioning","messagePattern":"PidNet requires lq_latent — attach via PiDConditioning","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/pixeldit/pid.py","lineNumber":236,"sourceCode":"            device=device, dtype=dtype, **rope_opts,\n        )\n\n    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","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/pixeldit/pid.py#L218-L254","documentation":"PidNet (pixel-level degradation network for PixDiT super-resolution) requires a low-quality latent ('lq_latent') every forward pass; it is the essential input that the Pi gates inject into the patch/pixel blocks. The ValueError fires when the model is run without lq_latent, i.e. the PiD conditioning was never attached to the model input. The message points you to the intended API: supply it via the PiDConditioning node.","triggerScenarios":"Loading a PixDiT PiD-LoRA/model and running a normal text-to-image sampler pass with no PiDConditioning input attached; calling model forward directly without the lq_latent kwarg; a workflow that connects the PiD model but forgets the LQ image/latent conditioning input.","commonSituations":"User loads a PiD (photo-realistic image degradation/super-resolution) checkpoint but wires it like a plain T2I model; the LQ image input node is muted or bypassed in the workflow; a converted workflow from another UI dropped the PiD conditioning link.","solutions":["Add the PiDConditioning node to the workflow and connect your low-quality image/latent so lq_latent reaches the model.","Verify the conditioning chain is not bypassed/muted (bypassed nodes pass None through).","Check that the LQ image and the target generation share resolution settings — the LQ latent grid must line up with the patch stream.","If you do not want super-resolution behavior, load the plain PixDiT_T2I model instead of the PiD variant."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def check_pid_inputs(lq_latent):\n    if lq_latent is None:\n        raise ValueError(\"PiD workflows require an LQ latent via PiDConditioning; connect the LQ image input\")\n    return lq_latent","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat PiD checkpoints as conditioning-dependent models: always add the PiDConditioning node when the workflow loads one.","Unmute/unbypass conditioning nodes before sampling.","Name workflow inputs clearly ('LQ image') so the missing link is obvious."],"tags":["pixeldit","pidnet","conditioning","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}