Comfy-Org/ComfyUI · critical · ValueError
Missing W4A8 group scale (weight_s_rel) for layer {layer_nam
Error message
Missing W4A8 group scale (weight_s_rel) for layer {layer_name} What it means
Raised in comfy/ops.py for quant_format 'asym_w4a8_int8': an asymmetric int4-weight/int8-activation layout that requires a per-group fp8 scale stored under `weight_s_rel`. If that key is missing from the state dict the loader cannot reconstruct the weights and raises this error naming the layer.
Source
Thrown at comfy/ops.py:1209
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,
"convrot_groupsize": int(
layer_conf.get("convrot_groupsize", params_conf.get("convrot_groupsize", 256))
),
"quant_group_size": 64,
"linear_dtype": layer_conf.get("linear_dtype", params_conf.get("linear_dtype", "int4")),
}
elif module.quant_format == "asym_w4a8_int8":
# int4 weight (packed int8 [N,K/2]) + fp8 per-group scale (weight_s_rel),
# fp32 per-channel scale (weight_s_channel) + optional Lloyd-Max codebook.
scale = pop_scale("weight_s_rel")
if scale is None:
raise ValueError(f"Missing W4A8 group scale (weight_s_rel) for layer {layer_name}")
if scale.dtype == torch.uint8:
scale = scale.view(torch.float8_e4m3fn)
params_conf = layer_conf.get("params", {})
if not isinstance(params_conf, dict):
params_conf = {}
scales = {
"scale": scale,
"s_channel": pop_scale("weight_s_channel"),
"codebook": pop_scale("weight_codebook"),
"group_size": int(layer_conf.get("group_size", params_conf.get("group_size", 16))),
"convrot_groupsize": int(
layer_conf.get("convrot_groupsize", params_conf.get("convrot_groupsize", 256))
),
}
else:
raise ValueError(f"Unsupported quantization format: {module.quant_format}")
params = layout_cls.Params(**scales, orig_dtype=compute_dtype, orig_shape=module._orig_shape)View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Verify the state dict contains `<prefix>.weight_s_rel` (uint8/fp8 view) for the layer named in the error.
- Re-quantize the model with ComfyUI's asym_w4a8_int8 path so the group scale, optional `weight_s_channel` and `weight_codebook` are saved with the right names.
- If the file came from elsewhere, rename the equivalent group-scale key to `weight_s_rel` (and view as float8_e4m3fn if stored as uint8).
- Re-download the model in case scale shards are missing.
Example fix
# before: wrong scale key name sd['layers.0.self_attn.q_proj.group_scale'] = group_scale # after: expected key name sd['layers.0.self_attn.q_proj.weight_s_rel'] = group_scale
Defensive patterns
Strategy: validation
Validate before calling
prefix = failing_layer_prefix
assert (prefix + 'weight_s_rel') in sd, f'{prefix}weight_s_rel missing for asym_w4a8_int8 layer' Try / catch
try:
model_patcher = load_diffusion_model(path)
except ValueError as e:
if 'weight_s_rel' in str(e):
raise SystemExit('asym_w4a8_int8 checkpoint missing group scales; re-quantize or rename keys')
raise Prevention
- When converting from external quantizers, map group-scale keys to weight_s_rel exactly.
- Store fp8 scales as uint8 on disk only if the loader's dtype-view convention is preserved.
When it happens
Trigger: Loading an asym_w4a8_int8 checkpoint whose `weight_s_rel` group-scale tensor is missing; conversion tools that emit `weight_scale` instead of the expected `weight_s_rel` name; prefix mismatch between comfy_quant and the scale key.
Common situations: Quantized checkpoints produced by external tooling with different scale naming; partial downloads; older quantized files predating the weight_s_rel naming; manual state-dict surgery.
Related errors
- Missing NVFP4 scales for layer {layer_name}
- Missing INT8 weight scale for layer {layer_name}
- Missing ConvRot W4A4 weight scale for layer {layer_name}
- Unsupported quantization format: {module.quant_format}
- Unsupported dtype
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/e45a5621c125b45a.
Report an issue: GitHub.