{"record":{"id":"0e5fdbd919644dfc","repo":"Comfy-Org/ComfyUI","slug":"unknown-quantization-format-for-layer-layer-name","errorCode":null,"errorMessage":"Unknown quantization format for layer {layer_name}","messagePattern":"Unknown quantization format for layer (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ops.py","lineNumber":1156,"sourceCode":"                v = v.view(dtype=dtype)\n            manually_loaded_keys.append(key)\n        return v\n\n    layer_conf = state_dict.pop(f\"{prefix}comfy_quant\", None)\n    if layer_conf is not None:\n        layer_conf = json.loads(layer_conf.numpy().tobytes())\n\n    if layer_conf is None:\n        module.weight = torch.nn.Parameter(weight.to(device=device, dtype=compute_dtype), requires_grad=False)\n    else:\n        module.quant_format = layer_conf.get(\"format\", None)\n        module._full_precision_mm_config = layer_conf.get(\"full_precision_matrix_mult\", False)\n        if not module._full_precision_mm:\n            module._full_precision_mm = module._full_precision_mm_config\n        if module.quant_format in disabled_formats:\n            module._full_precision_mm = True\n        if module.quant_format is None:\n            raise ValueError(f\"Unknown quantization format for layer {layer_name}\")\n\n        qconfig = QUANT_ALGOS[module.quant_format]\n        module.layout_type = qconfig[\"comfy_tensor_layout\"]\n        layout_cls = get_layout_class(module.layout_type)\n\n        # Per-format scales; fp8 dtype views handle both legacy uint8-on-disk and native fp8.\n        if module.quant_format in (\"float8_e4m3fn\", \"float8_e5m2\"):\n            scales = {\"scale\": pop_scale(\"weight_scale\")}\n        elif module.quant_format == \"mxfp8\":\n            bs = pop_scale(\"weight_scale\", torch.float8_e8m0fnu)\n            if bs is None:\n                raise ValueError(f\"Missing MXFP8 block scales for layer {layer_name}\")\n            scales = {\"scale\": bs}\n        elif module.quant_format == \"nvfp4\":\n            ts = pop_scale(\"weight_scale_2\")\n            bs = pop_scale(\"weight_scale\", torch.float8_e4m3fn)\n            if ts is None or bs is None:\n                raise ValueError(f\"Missing NVFP4 scales for layer {layer_name}\")","sourceCodeStart":1138,"sourceCodeEnd":1174,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ops.py#L1138-L1174","documentation":"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.","triggerScenarios":"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.","commonSituations":"Community-repacked quantized checkpoints; quantization tool version mismatch with the loader; partially downloaded checkpoints.","solutions":["Re-download the checkpoint from the original release.","Re-quantize/re-export with the tool version the loader supports so each layer carries a \"format\" field.","Update ComfyUI — newer versions may recognize additional metadata shapes."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for name, blob in layer_conf_items:\n    conf = json.loads(blob) if isinstance(blob, bytes) else blob\n    if isinstance(conf, dict) and conf.get(\"format\") is None:\n        logging.warning(\"layer %s has no quant 'format'; load will fail\", name)","typeGuard":"def has_quant_format(layer_conf) -> bool:\n    return isinstance(layer_conf, dict) and layer_conf.get(\"format\") is not None","tryCatchPattern":"try:\n    model = load_quantized_model(path)\nexcept ValueError as e:\n    if \"Unknown quantization format\" in str(e):\n        raise RuntimeError(\"checkpoint layer metadata missing/invalid; re-download or re-quantize\") from e\n    raise","preventionTips":["Download quantized checkpoints only from official releases.","Re-quantize with a supported tool rather than editing layer metadata by hand."],"tags":["quantization","checkpoint","ops","metadata"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}