sgl-project/sglang · error · ValueError
Weight name {weight_name!r} matches multiple files: {list(ba
Error message
Weight name {weight_name!r} matches multiple files: {list(basename_matches)} What it means
The given weight_name matches more than one candidate file by basename (files in different subfolders sharing a name), so selection is ambiguous and the library refuses to guess.
Source
Thrown at python/sglang/multimodal_gen/runtime/weights/source.py:234
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:
return candidates[0]View on GitHub (pinned to 0132848349)
Solutions
- Select by exact file URL including the subfolder path
- Narrow the source to the subfolder (owner/repo/subfolder) before selecting
- Pass the full relative path if the API accepts it
Example fix
# before
resolve_weight("org/repo", weight_name="model.safetensors")
# after
resolve_weight("org/repo/transformer/resolve/main/model.safetensors") Defensive patterns
Strategy: validation
Validate before calling
from pathlib import PurePosixPath
matches = [f for f in inv.files if PurePosixPath(f).name == weight_name]
if len(matches) != 1:
raise SystemExit(f"ambiguous or missing {weight_name}: {matches}") Try / catch
try:
f = select_weight_file(inv, weight_name)
except ValueError as e:
# disambiguate with an exact URL built from matches
raise Prevention
- Prefer exact file URLs for repos with same-named files in multiple subfolders
- Check basename uniqueness before calling
When it happens
Trigger: A repo contains e.g. 'transformer/model.safetensors' and 'vae/model.safetensors' and the caller asks for weight_name='model.safetensors'.
Common situations: Multi-component diffusion checkpoints where several subfolders each contain a same-named shard.
Related errors
- Source contains multiple independent weight files; select on
- Duplicate tensor names detected across safetensors files. Re
- RIFE weight file not found: {flownet_path} Expected layout:
- Invalid Hugging Face {field_name}: {path!r}
- Weight URL pins revision {url_revision!r}, which conflicts w
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/04dc7206b0c4ec68.
Report an issue: GitHub.