{"record":{"id":"d5eabe20dc90b78c","repo":"sgl-project/sglang","slug":"source-contains-multiple-independent-weight-files","errorCode":null,"errorMessage":"Source contains multiple independent weight files; select one with an exact file URL or weight name. Candidates: {list(candidates)}","messagePattern":"Source contains multiple independent weight files; select one with an exact file URL or weight name\\. Candidates: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/weights/source.py","lineNumber":255,"sourceCode":"    )\n\n\ndef select_weight_file(\n    inventory: WeightInventory, weight_name: str | None = None\n) -> str:\n    \"\"\"Select weights deterministically; never guess among independent files.\"\"\"\n    candidates = tuple(\n        path for path in inventory.files if path.lower().endswith(_WEIGHT_SUFFIXES)\n    )\n    if inventory.source.filename is not None:\n        return inventory.files[0]\n    if weight_name is not None:\n        return _select_named_file(candidates, weight_name)\n    if len(candidates) == 1:\n        return candidates[0]\n    if not candidates:\n        raise FileNotFoundError(\"Source contains no recognized weight files\")\n    raise ValueError(\n        \"Source contains multiple independent weight files; select one with \"\n        f\"an exact file URL or weight name. Candidates: {list(candidates)}\"\n    )\n\n\ndef resolve_weight(\n    source: str,\n    *,\n    revision: str | None = None,\n    weight_name: str | None = None,\n) -> ResolvedWeight:\n    \"\"\"Resolve one weight file without downloading its tensor payload.\"\"\"\n    parsed_source = parse_weight_source(source, revision=revision)\n    inventory = resolve_weight_inventory(parsed_source)\n    selected_file = select_weight_file(inventory, weight_name)\n    return ResolvedWeight(\n        inventory=inventory,\n        selected_file=selected_file,","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/weights/source.py#L237-L273","documentation":"Multiple candidate weight files were found and no weight_name or exact file URL was provided, so the choice is ambiguous and the resolver requires an explicit selection.","triggerScenarios":"A repo or directory containing several independent recognized weight files (e.g. both a full checkpoint and a sharded/fp8 variant) and calling resolve_weight(source) with no selector.","commonSituations":"Mixed-format checkpoints in one folder; repos with bf16 and fp8 exports side by side.","solutions":["Pass weight_name for the desired basename","Use an exact file URL to pin one file","Restrict the source to the subfolder containing the desired file"],"exampleFix":"# before\nresolve_weight(\"org/repo\")\n# after\nresolve_weight(\"org/repo\", weight_name=\"model_fp8.safetensors\")","handlingStrategy":"validation","validationCode":"inv = resolve_weight_inventory(parse_weight_source(source))\nif len(inv.files) > 1 and weight_name is None:\n    raise SystemExit(f\"multiple weights {inv.files}; pass weight_name\")","typeGuard":null,"tryCatchPattern":"try:\n    f = select_weight_file(inv)\nexcept ValueError as e:\n    logger.error(\"%s\", e)  # lists candidates\n    raise","preventionTips":["Always pass weight_name for multi-file sources in scripts","Log the candidate list from the error to pick the right file"],"tags":["weights","ambiguous-selection"],"backgroundTag":"ambiguous-file-selection","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}