{"record":{"id":"e85c575aa63a7ddf","repo":"sgl-project/sglang","slug":"unable-to-find-matching-target-for-layer-name-in","errorCode":null,"errorMessage":"Unable to find matching target for {layer_name} in the compressed-tensors config.","messagePattern":"Unable to find matching target for (.+?) in the compressed-tensors config\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/layers/quantization/compressed_tensors/utils.py","lineNumber":144,"sourceCode":"    :param layer_name: layer name\n    :param module: torch.nn.Module\n    :param targets: list of targets to match the layer against\n    :param fused_mapping: map from fused layer names to its components\n    :param fused_strategy: either \"all\" or \"any\". If using \"all\", fused\n        layers match if \"all\" of its components match\n    \"\"\"\n\n    if layer_name is None:\n        layer_name = \"\"\n\n    matched_target = (\n        _find_first_match(layer_name, targets)\n        or _find_first_match(module.__class__.__name__, targets, True)\n        or _match_fused_layer(layer_name, targets, fused_mapping)\n    )\n\n    if matched_target is None:\n        raise ValueError(\n            f\"Unable to find matching target for {layer_name} in the \"\n            \"compressed-tensors config.\"\n        )\n\n    return matched_target\n\n\ndef _find_first_match(\n    value: str, targets: Iterable[str], check_contains: bool = False\n) -> Optional[str]:\n    \"\"\"\n    Returns first element of target that matches value either\n    exactly or as a regex after 're:'. If check_contains is set to True,\n    additionally checks if the target string is contained within the value.\n\n    :param value: string to compare the list of targets against\n    :param targets: list of targets to match the layer against\n    :param check_contains: whether or not to do a substring match","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/quantization/compressed_tensors/utils.py#L126-L162","documentation":"find_matched_target failed to match the layer name (or its class name, or fused-projection mapping) against any target in the compressed-tensors config. Every layer of a quantized model must match a config target; a miss means the config doesn't describe this layer.","triggerScenarios":"A layer name in the model (e.g. 'model.layers.5.mlp.gate_up_proj' or a renamed module) not covered by quantization_config.targets, and not resolvable via module class name or the fused-layer mapping, when get_scheme_dict/get_linear_scheme builds the scheme.","commonSituations":"Architectural changes (new module names) not reflected in the quant config; checkpoints quantized against a different model revision; typos in target patterns; custom models with non-standard layer names.","solutions":["Ensure quantization_config targets cover all linear layers, e.g. add the missing module name pattern or use a wildcard","Re-quantize from the exact model revision being served","Check for renamed/fused modules and match the naming the quantizer used"],"exampleFix":"// before\n\"targets\": [\"model.layers.0.self_attn.q_proj\", \"model.layers.1.self_attn.q_proj\"]\n// after\n\"targets\": [\"model.*.self_attn.*_proj\", \"model.*.mlp.*_proj\"]","handlingStrategy":"validation","validationCode":"import re\ntargets = cfg[\"quantization_config\"][\"targets\"]\nlayer = \"model.layers.0.mlp.down_proj\"\nassert any(re.fullmatch(t.replace(\"*\", \".*\"), layer) for t in targets), \"layer not covered\"","typeGuard":"def layer_covered(layer, targets):\n    import fnmatch\n    return any(fnmatch.fnmatch(layer, t) for t in targets)","tryCatchPattern":null,"preventionTips":["Use wildcard targets like model.*.mlp.*_proj","Re-quantize whenever module names change between revisions"],"tags":["quantization","compressed-tensors","layer-matching","config-mismatch"],"backgroundTag":"quantization-target-not-found","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}