{"record":{"id":"7b917a895c598d3e","repo":"sgl-project/sglang","slug":"error-msg-7b917a","errorCode":null,"errorMessage":"{error_msg}","messagePattern":"\\{error_msg\\}","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/layers/quantization/petit_utils.py","lineNumber":58,"sourceCode":"        return (\n            False,\n            \"Petit currently only supports: NVFP4\"\n            \" quantizations in sglang. Please check the \"\n            \"`hf_quant_config.json` file for your model's \"\n            \"quant configuration.\",\n        )\n    if group_size is not None and group_size != 16:\n        return (\n            False,\n            \"Petit currently only supports: group_size=16\" \" quantizations.\",\n        )\n    return (True, None)\n\n\ndef verify_petit_nvfp4_supported(quant_method: str, group_size: Optional[int]) -> None:\n    supported, error_msg = _check_petit_nvfp4_supported(quant_method, group_size)\n    if not supported:\n        raise ValueError(error_msg)\n\n\ndef prepare_nvfp4_layer_for_petit(layer: torch.nn.Module) -> None:\n    # Repack weights to petit format\n    part_size_n = layer.output_size_per_partition\n    part_size_k = layer.input_size_per_partition\n    qweight = layer.weight.view(torch.int32).contiguous()\n    petit_qweight = repack_nvfp4(qweight, size_n=part_size_n, size_k=part_size_k)\n    layer.weight = torch.nn.Parameter(petit_qweight, requires_grad=False)\n\n    # Permute scales\n    weight_scale = process_nvfp4_scales(\n        scales=layer.weight_scale, size_k=part_size_k, size_n=part_size_n\n    )\n    layer.weight_scale = torch.nn.Parameter(weight_scale, requires_grad=False)\n\n    return\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/quantization/petit_utils.py#L40-L76","documentation":"verify_petit_nvfp4_supported re-raises the message produced by _check_petit_nvfp4_supported as a ValueError when the (quant_method, group_size) combination is not supported by Petit. It is the validation entry point called from from_config, so it fails early at config parse time rather than mid-forward.","triggerScenarios":"Calling verify_petit_nvfp4_supported(quant_method, group_size) (directly, or via a quant config's from_config that enables Petit) with a quant_method/group_size pair that _check_petit_nvfp4_supported rejects — e.g. a non-NVFP4 method or a group size other than the supported value (16).","commonSituations":"Pointing --quantization at a checkpoint whose quant config (e.g. an FP8 or INT4 quark/compressed-tensors config) is fed into the Petit path; custom checkpoints with unusual weight_block_size/group_size; mixing Petit flags with models that were not NVFP4-quantized with group size 16.","solutions":["Inspect the checkpoint's quant_config (quant_method and group_size/weight_block_size) and confirm it is NVFP4 with the supported group size (16).","If the checkpoint is not NVFP4, remove the Petit enabling flags so the standard quantization method is used.","Re-quantize the model to NVFP4 (group size 16) using llm-compressor or the equivalent tooling if Petit acceleration is required.","Update sglang/petit-kernel if a newer release supports your group size."],"exampleFix":"# before\n# checkpoint config: quant_method=\"fp8\", group_size=None -> verify_petit_nvfp4_supported raises\n\n# after\n# use an NVFP4 checkpoint: quant_method=\"NVFP4\", weight_block_size=[16,16]\nverify_petit_nvfp4_supported(\"NVFP4\", 16)  # passes","handlingStrategy":"validation","validationCode":"from sglang.srt.layers.quantization.petit_utils import _check_petit_utils if False else None\nsupported, msg = None, None\ntry:\n    from sglang.srt.layers.quantization.petit_utils import _check_petit_nvfp4_supported\n    supported, msg = _check_petit_nvfp4_supported(quant_method, group_size)\nexcept ImportError:\n    supported = False\nif not supported:\n    raise RuntimeError(f\"Petit unsupported for this config: {msg}\")","typeGuard":"def is_petit_nvfp4_config(quant_method: str, group_size) -> bool:\n    return quant_method in (\"NVFP4\", \"W4A16_NVFP4\") and group_size in (16, None)","tryCatchPattern":"try:\n    verify_petit_nvfp4_supported(quant_method, group_size)\nexcept ValueError as e:\n    if \"Petit\" in str(e) or \"group\" in str(e):\n        logger.warning(\"Falling back to standard NVFP4 kernels: %s\", e)\n        use_petit = False\n    else:\n        raise","preventionTips":["Validate quant_method and weight_block_size/group_size against the supported set (NVFP4, group 16) before enabling Petit.","Print the checkpoint's quant config at startup and assert it matches expectations.","Keep a matrix test of supported (method, group) combos in CI."],"tags":["quantization","nvfp4","petit","config-validation","python"],"backgroundTag":"quantization-config-unsupported","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}