{"record":{"id":"e45a5621c125b45a","repo":"Comfy-Org/ComfyUI","slug":"missing-w4a8-group-scale-weight-s-rel-for-layer","errorCode":null,"errorMessage":"Missing W4A8 group scale (weight_s_rel) for layer {layer_name}","messagePattern":"Missing W4A8 group scale \\(weight_s_rel\\) for layer (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"comfy/ops.py","lineNumber":1209,"sourceCode":"            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,\n                \"convrot_groupsize\": int(\n                    layer_conf.get(\"convrot_groupsize\", params_conf.get(\"convrot_groupsize\", 256))\n                ),\n                \"quant_group_size\": 64,\n                \"linear_dtype\": layer_conf.get(\"linear_dtype\", params_conf.get(\"linear_dtype\", \"int4\")),\n            }\n        elif module.quant_format == \"asym_w4a8_int8\":\n            # int4 weight (packed int8 [N,K/2]) + fp8 per-group scale (weight_s_rel),\n            # fp32 per-channel scale (weight_s_channel) + optional Lloyd-Max codebook.\n            scale = pop_scale(\"weight_s_rel\")\n            if scale is None:\n                raise ValueError(f\"Missing W4A8 group scale (weight_s_rel) for layer {layer_name}\")\n            if scale.dtype == torch.uint8:\n                scale = scale.view(torch.float8_e4m3fn)\n            params_conf = layer_conf.get(\"params\", {})\n            if not isinstance(params_conf, dict):\n                params_conf = {}\n            scales = {\n                \"scale\": scale,\n                \"s_channel\": pop_scale(\"weight_s_channel\"),\n                \"codebook\": pop_scale(\"weight_codebook\"),\n                \"group_size\": int(layer_conf.get(\"group_size\", params_conf.get(\"group_size\", 16))),\n                \"convrot_groupsize\": int(\n                    layer_conf.get(\"convrot_groupsize\", params_conf.get(\"convrot_groupsize\", 256))\n                ),\n            }\n        else:\n            raise ValueError(f\"Unsupported quantization format: {module.quant_format}\")\n\n        params = layout_cls.Params(**scales, orig_dtype=compute_dtype, orig_shape=module._orig_shape)","sourceCodeStart":1191,"sourceCodeEnd":1227,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ops.py#L1191-L1227","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before: wrong scale key name\nsd['layers.0.self_attn.q_proj.group_scale'] = group_scale\n\n# after: expected key name\nsd['layers.0.self_attn.q_proj.weight_s_rel'] = group_scale","handlingStrategy":"validation","validationCode":"prefix = failing_layer_prefix\nassert (prefix + 'weight_s_rel') in sd, f'{prefix}weight_s_rel missing for asym_w4a8_int8 layer'","typeGuard":null,"tryCatchPattern":"try:\n    model_patcher = load_diffusion_model(path)\nexcept ValueError as e:\n    if 'weight_s_rel' in str(e):\n        raise SystemExit('asym_w4a8_int8 checkpoint missing group scales; re-quantize or rename keys')\n    raise","preventionTips":["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."],"tags":["quantization","w4a8","int4","checkpoint-loading"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}