{"record":{"id":"284ef41e4e75560b","repo":"sgl-project/sglang","slug":"requested-weight-weight-name-r-was-not-found","errorCode":null,"errorMessage":"Requested weight {weight_name!r} was not found","messagePattern":"Requested weight (.+?) was not found","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/weights/source.py","lineNumber":233,"sourceCode":"    files = tuple(sibling.rfilename for sibling in model_info.siblings)\n    return WeightInventory(\n        source=source,\n        resolved_revision=model_info.sha,\n        files=_filter_inventory_files(files, source),\n    )\n\n\ndef _select_named_file(candidates: tuple[str, ...], weight_name: str) -> str:\n    exact = tuple(path for path in candidates if path == weight_name)\n    if exact:\n        return exact[0]\n    basename_matches = tuple(\n        path for path in candidates if PurePosixPath(path).name == weight_name\n    )\n    if len(basename_matches) == 1:\n        return basename_matches[0]\n    if not basename_matches:\n        raise FileNotFoundError(f\"Requested weight {weight_name!r} was not found\")\n    raise ValueError(\n        f\"Weight name {weight_name!r} matches multiple files: \"\n        f\"{list(basename_matches)}\"\n    )\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:","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/weights/source.py#L215-L251","documentation":"select_weight_file was given an explicit weight_name, but no candidate file in the inventory has that basename. Candidates are already filtered to recognized weight files, so the name is absent entirely.","triggerScenarios":"Calling resolve_weight(source, weight_name=\"foo.safetensors\") when no recognized weight file has that basename; wrong extension or typo in the name.","commonSituations":"Checkpoint files named differently than expected (e.g. diffusion_pytorch_model.safetensors vs model.safetensors); user assumes a naming convention the export does not follow.","solutions":["Inspect inventory.files from resolve_weight_inventory to see actual names","Correct the weight_name to the real basename","Select by exact file URL instead if names vary"],"exampleFix":"# before\nresolve_weight(\"org/repo\", weight_name=\"model.safetensors\")\n# after\nresolve_weight(\"org/repo\", weight_name=\"diffusion_pytorch_model.safetensors\")","handlingStrategy":"validation","validationCode":"inv = resolve_weight_inventory(parse_weight_source(source))\nnames = {__import__('posixpath').basename(f) for f in inv.files}\nassert weight_name in names, f\"{weight_name} not in {sorted(names)}\"","typeGuard":null,"tryCatchPattern":"try:\n    f = select_weight_file(inv, weight_name)\nexcept FileNotFoundError:\n    logger.error(\"weight %s absent; have %s\", weight_name, inv.files)\n    raise","preventionTips":["Log inventory.files before selecting","Derive weight_name from an actual listing rather than a guess"],"tags":["weights","file-selection"],"backgroundTag":"file-not-found","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}