Comfy-Org/ComfyUI · error · ValueError

Unknown latent_format: {latent_format}

Error message

Unknown latent_format: {latent_format}

What it means

Raised by the PiD (Perceptual Image Distillation) conditioning node when the latent_format combo string matches none of flux/sd3/sdxl/qwenimage. The choice selects the comfy.latent_formats class used to process_in the latents; an unknown string means no latent format contract can be applied.

Source

Thrown at comfy_extras/nodes_pid.py:44

                    tooltip="0 = clean latent. Increase to denoise corrupted latent outputs.",
                ),
            ],
            outputs=[io.Conditioning.Output()],
        )

    @classmethod
    def execute(cls, positive, latent, latent_format: str, degrade_sigma: float) -> io.NodeOutput:
        samples = latent["samples"]
        if latent_format == "flux":
            fmt_cls = comfy.latent_formats.Flux2 if samples.shape[1] == 128 else comfy.latent_formats.Flux
        elif latent_format == "sd3":
            fmt_cls = comfy.latent_formats.SD3
        elif latent_format == "sdxl":
            fmt_cls = comfy.latent_formats.SDXL
        elif latent_format == "qwenimage":
            fmt_cls = comfy.latent_formats.Wan21
        else:
            raise ValueError(f"Unknown latent_format: {latent_format}")
        lq_latent = fmt_cls().process_in(samples)
        if lq_latent.ndim == 5:
            lq_latent = lq_latent[:, :, 0]
        sigma_t = torch.tensor([float(degrade_sigma)], dtype=torch.float32)
        return io.NodeOutput(node_helpers.conditioning_set_values(
            positive, {"lq_latent": lq_latent, "degrade_sigma": sigma_t},
        ))


class PiDExtension(ComfyExtension):
    @override
    async def get_node_list(self) -> list[type[io.ComfyNode]]:
        return [PiDConditioning]


async def comfy_entrypoint() -> PiDExtension:
    return PiDExtension()

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Set latent_format to one of the exact strings: 'flux', 'sd3', 'sdxl', 'qwenimage'.
  2. For SD1.5/other checkpoints, this node does not support them — remove the node or wait for support.
  3. Check /object_info for the current combo options if unsure.

Example fix

// before
{"class_type": "...", "inputs": {"latent_format": "sd15", ...}}
// after
{"class_type": "...", "inputs": {"latent_format": "sdxl", ...}}
Defensive patterns

Strategy: validation

Validate before calling

VALID_PID_FORMATS = {'flux', 'sd3', 'sdxl', 'qwenimage'}
if latent_format not in VALID_PID_FORMATS:
    raise ValueError(f"latent_format must be one of {sorted(VALID_PID_FORMATS)}")

Type guard

def is_valid_pid_format(fmt: str) -> bool:
    return fmt in {'flux', 'sd3', 'sdxl', 'qwenimage'}

Prevention

When it happens

Trigger: Calling the node via the HTTP API or an edited workflow with latent_format outside {'flux','sd3','sdxl','qwenimage'} (e.g. 'sd15', 'Flux' with wrong capitalization, 'wan').

Common situations: Using PiD with an unsupported model family (SD1.5, AuraFlow); API scripts hardcoding format names that drift from the combo; copy-pasting workflows between ComfyUI versions where the option list changed.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/fe3a17a53a0d4b41. Report an issue: GitHub.