{"record":{"id":"d599400f2df7eff7","repo":"Comfy-Org/ComfyUI","slug":"missing-int8-weight-scale-for-layer-layer-name","errorCode":null,"errorMessage":"Missing INT8 weight scale for layer {layer_name}","messagePattern":"Missing INT8 weight scale for layer (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"comfy/ops.py","lineNumber":1179,"sourceCode":"\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}\")\n            scales = {\"scale\": ts, \"block_scale\": bs}\n        elif module.quant_format == \"int8_tensorwise\":\n            scale = pop_scale(\"weight_scale\")\n            if scale is None:\n                raise ValueError(f\"Missing INT8 weight scale for layer {layer_name}\")\n            scales = {\"scale\": scale}\n            params_conf = layer_conf.get(\"params\", {})\n            if not isinstance(params_conf, dict):\n                params_conf = {}\n            if layer_conf.get(\"convrot\", params_conf.get(\"convrot\", False)):\n                scales[\"convrot\"] = True\n                scales[\"convrot_groupsize\"] = int(\n                    layer_conf.get(\"convrot_groupsize\", params_conf.get(\"convrot_groupsize\", 256))\n                )\n        elif module.quant_format == \"convrot_w4a4\":\n            scale = pop_scale(\"weight_scale\")\n            if scale is None:\n                raise ValueError(f\"Missing ConvRot W4A4 weight scale for layer {layer_name}\")\n            params_conf = layer_conf.get(\"params\", {})\n            if not isinstance(params_conf, dict):\n                params_conf = {}\n            scales = {\n                \"scale\": scale,","sourceCodeStart":1161,"sourceCodeEnd":1197,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ops.py#L1161-L1197","documentation":"Raised in comfy/ops.py when a layer declares quant_format 'int8_tensorwise' via its `comfy_quant` blob but no `weight_scale` key is present in the state dict. INT8 tensor-wise quantization requires one fp32 scale per tensor to dequantize; without it the layer cannot be reconstructed and loading fails with the layer name in the message.","triggerScenarios":"Loading an int8_tensorwise-quantized checkpoint where the `weight_scale` tensor is missing under the layer prefix; state dict filtering/cleanup code that dropped small 1-element tensors along with scales; mixing an int8 weight from one file with config metadata from another.","commonSituations":"Third-party INT8 conversions that omit or rename the per-tensor scale; incomplete model downloads; safetensors files assembled by scripts that skip scalar tensors; version drift in quantized checkpoint formats.","solutions":["List the checkpoint keys and verify `<prefix>.weight_scale` (a scalar/1-element tensor) exists for the failing layer.","Re-quantize with ComfyUI's int8_tensorwise path so the scale is saved alongside the weight and comfy_quant blob.","Re-download or re-merge the checkpoint if a shard containing scales was missed.","As a last resort, dequantize to bf16 or remove the comfy_quant marker to load the layer dense."],"exampleFix":"# before: int8 layer without scale\nsd = {'layers.0.mlp.up_proj.weight': int8_weight,\n      'layers.0.mlp.up_proj.comfy_quant': cfg_int8}\n\n# after: include the tensorwise scale\nsd = {'layers.0.mlp.up_proj.weight': int8_weight,\n      'layers.0.mlp.up_proj.weight_scale': torch.tensor([0.0123]),\n      'layers.0.mlp.up_proj.comfy_quant': cfg_int8}","handlingStrategy":"validation","validationCode":"prefix = 'model.layers.0.mlp.up_proj.'\nassert (prefix + 'weight_scale') in sd, f'{prefix}weight_scale missing for int8_tensorwise layer'","typeGuard":null,"tryCatchPattern":"try:\n    model_patcher = load_diffusion_model(path)\nexcept ValueError as e:\n    if 'Missing INT8 weight scale' in str(e):\n        raise SystemExit(f'{path} lacks int8 scale tensors; re-quantize or re-download')\n    raise","preventionTips":["Do not filter 1-element tensors out of state dicts during cleanup scripts.","Keep quantized weights, scales, and comfy_quant blobs together when re-saving checkpoints.","Prefer checkpoints quantized by the ComfyUI version you run."],"tags":["quantization","int8","checkpoint-loading","state-dict"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}