Comfy-Org/ComfyUI · critical · ValueError

Missing INT8 weight scale for layer {layer_name}

Error message

Missing INT8 weight scale for layer {layer_name}

What it means

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.

Source

Thrown at comfy/ops.py:1179

        # 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}")
            scales = {"scale": ts, "block_scale": bs}
        elif module.quant_format == "int8_tensorwise":
            scale = pop_scale("weight_scale")
            if scale is None:
                raise ValueError(f"Missing INT8 weight scale for layer {layer_name}")
            scales = {"scale": scale}
            params_conf = layer_conf.get("params", {})
            if not isinstance(params_conf, dict):
                params_conf = {}
            if layer_conf.get("convrot", params_conf.get("convrot", False)):
                scales["convrot"] = True
                scales["convrot_groupsize"] = int(
                    layer_conf.get("convrot_groupsize", params_conf.get("convrot_groupsize", 256))
                )
        elif module.quant_format == "convrot_w4a4":
            scale = pop_scale("weight_scale")
            if scale is None:
                raise ValueError(f"Missing ConvRot W4A4 weight scale for layer {layer_name}")
            params_conf = layer_conf.get("params", {})
            if not isinstance(params_conf, dict):
                params_conf = {}
            scales = {
                "scale": scale,

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. List the checkpoint keys and verify `<prefix>.weight_scale` (a scalar/1-element tensor) exists for the failing layer.
  2. Re-quantize with ComfyUI's int8_tensorwise path so the scale is saved alongside the weight and comfy_quant blob.
  3. Re-download or re-merge the checkpoint if a shard containing scales was missed.
  4. As a last resort, dequantize to bf16 or remove the comfy_quant marker to load the layer dense.

Example fix

# before: int8 layer without scale
sd = {'layers.0.mlp.up_proj.weight': int8_weight,
      'layers.0.mlp.up_proj.comfy_quant': cfg_int8}

# after: include the tensorwise scale
sd = {'layers.0.mlp.up_proj.weight': int8_weight,
      'layers.0.mlp.up_proj.weight_scale': torch.tensor([0.0123]),
      'layers.0.mlp.up_proj.comfy_quant': cfg_int8}
Defensive patterns

Strategy: validation

Validate before calling

prefix = 'model.layers.0.mlp.up_proj.'
assert (prefix + 'weight_scale') in sd, f'{prefix}weight_scale missing for int8_tensorwise layer'

Try / catch

try:
    model_patcher = load_diffusion_model(path)
except ValueError as e:
    if 'Missing INT8 weight scale' in str(e):
        raise SystemExit(f'{path} lacks int8 scale tensors; re-quantize or re-download')
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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