Comfy-Org/ComfyUI · error · ValueError

Unknown quantization format for layer {layer_name}

Error message

Unknown quantization format for layer {layer_name}

What it means

When loading a quantized layer, the per-layer metadata blob (layer_conf) must contain a "format" key naming the quantization algorithm (fp8, mxfp8, nvfp4, int8, ...). A None/missing format means the checkpoint's layer metadata is absent or unrecognized, so the loader cannot pick a QUANT_ALGOS entry and fails with the layer name.

Source

Thrown at comfy/ops.py:1156

                v = v.view(dtype=dtype)
            manually_loaded_keys.append(key)
        return v

    layer_conf = state_dict.pop(f"{prefix}comfy_quant", None)
    if layer_conf is not None:
        layer_conf = json.loads(layer_conf.numpy().tobytes())

    if layer_conf is None:
        module.weight = torch.nn.Parameter(weight.to(device=device, dtype=compute_dtype), requires_grad=False)
    else:
        module.quant_format = layer_conf.get("format", None)
        module._full_precision_mm_config = layer_conf.get("full_precision_matrix_mult", False)
        if not module._full_precision_mm:
            module._full_precision_mm = module._full_precision_mm_config
        if module.quant_format in disabled_formats:
            module._full_precision_mm = True
        if module.quant_format is None:
            raise ValueError(f"Unknown quantization format for layer {layer_name}")

        qconfig = QUANT_ALGOS[module.quant_format]
        module.layout_type = qconfig["comfy_tensor_layout"]
        layout_cls = get_layout_class(module.layout_type)

        # Per-format scales; fp8 dtype views handle both legacy uint8-on-disk and native fp8.
        if module.quant_format in ("float8_e4m3fn", "float8_e5m2"):
            scales = {"scale": pop_scale("weight_scale")}
        elif module.quant_format == "mxfp8":
            bs = pop_scale("weight_scale", torch.float8_e8m0fnu)
            if bs is None:
                raise ValueError(f"Missing MXFP8 block scales for layer {layer_name}")
            scales = {"scale": bs}
        elif module.quant_format == "nvfp4":
            ts = pop_scale("weight_scale_2")
            bs = pop_scale("weight_scale", torch.float8_e4m3fn)
            if ts is None or bs is None:
                raise ValueError(f"Missing NVFP4 scales for layer {layer_name}")

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Re-download the checkpoint from the original release.
  2. Re-quantize/re-export with the tool version the loader supports so each layer carries a "format" field.
  3. Update ComfyUI — newer versions may recognize additional metadata shapes.
Defensive patterns

Strategy: try-catch

Validate before calling

for name, blob in layer_conf_items:
    conf = json.loads(blob) if isinstance(blob, bytes) else blob
    if isinstance(conf, dict) and conf.get("format") is None:
        logging.warning("layer %s has no quant 'format'; load will fail", name)

Type guard

def has_quant_format(layer_conf) -> bool:
    return isinstance(layer_conf, dict) and layer_conf.get("format") is not None

Try / catch

try:
    model = load_quantized_model(path)
except ValueError as e:
    if "Unknown quantization format" in str(e):
        raise RuntimeError("checkpoint layer metadata missing/invalid; re-download or re-quantize") from e
    raise

Prevention

When it happens

Trigger: Loading a quantized checkpoint whose layer_conf JSON lacks "format" — e.g. a GGUF/repack tool that dropped metadata, an export from an unsupported quantizer, or a corrupted safetensors header entry.

Common situations: Community-repacked quantized checkpoints; quantization tool version mismatch with the loader; partially downloaded checkpoints.

Related errors


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