sgl-project/sglang · error · FileNotFoundError

Requested weight {weight_name!r} was not found

Error message

Requested weight {weight_name!r} was not found

What it means

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.

Source

Thrown at python/sglang/multimodal_gen/runtime/weights/source.py:233

    files = tuple(sibling.rfilename for sibling in model_info.siblings)
    return WeightInventory(
        source=source,
        resolved_revision=model_info.sha,
        files=_filter_inventory_files(files, source),
    )


def _select_named_file(candidates: tuple[str, ...], weight_name: str) -> str:
    exact = tuple(path for path in candidates if path == weight_name)
    if exact:
        return exact[0]
    basename_matches = tuple(
        path for path in candidates if PurePosixPath(path).name == weight_name
    )
    if len(basename_matches) == 1:
        return basename_matches[0]
    if not basename_matches:
        raise FileNotFoundError(f"Requested weight {weight_name!r} was not found")
    raise ValueError(
        f"Weight name {weight_name!r} matches multiple files: "
        f"{list(basename_matches)}"
    )


def select_weight_file(
    inventory: WeightInventory, weight_name: str | None = None
) -> str:
    """Select weights deterministically; never guess among independent files."""
    candidates = tuple(
        path for path in inventory.files if path.lower().endswith(_WEIGHT_SUFFIXES)
    )
    if inventory.source.filename is not None:
        return inventory.files[0]
    if weight_name is not None:
        return _select_named_file(candidates, weight_name)
    if len(candidates) == 1:

View on GitHub (pinned to 0132848349)

Solutions

  1. Inspect inventory.files from resolve_weight_inventory to see actual names
  2. Correct the weight_name to the real basename
  3. Select by exact file URL instead if names vary

Example fix

# before
resolve_weight("org/repo", weight_name="model.safetensors")
# after
resolve_weight("org/repo", weight_name="diffusion_pytorch_model.safetensors")
Defensive patterns

Strategy: validation

Validate before calling

inv = resolve_weight_inventory(parse_weight_source(source))
names = {__import__('posixpath').basename(f) for f in inv.files}
assert weight_name in names, f"{weight_name} not in {sorted(names)}"

Try / catch

try:
    f = select_weight_file(inv, weight_name)
except FileNotFoundError:
    logger.error("weight %s absent; have %s", weight_name, inv.files)
    raise

Prevention

When it happens

Trigger: Calling resolve_weight(source, weight_name="foo.safetensors") when no recognized weight file has that basename; wrong extension or typo in the name.

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/284ef41e4e75560b. Report an issue: GitHub.