sgl-project/sglang · error · ValueError

Weight source {source!r} is neither a local path nor an owne

Error message

Weight source {source!r} is neither a local path nor an owner/repo Hugging Face reference

What it means

parse_weight_source accepts either an existing local filesystem path or a Hugging Face 'owner/repo' reference. This error fires when the string is neither: the path does not exist on disk AND it does not look like a two-segment owner/repo ID (fewer than two '/'-separated non-empty leading parts).

Source

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

    parsed = urlparse(source)
    if parsed.scheme in ("http", "https"):
        return _parse_huggingface_url(source, revision)

    looks_local = (
        os.path.exists(expanded)
        or os.path.isabs(expanded)
        or source.startswith(("./", "../", "~"))
    )
    if looks_local:
        return WeightSource(
            original=source,
            kind="local",
            local_path=os.path.abspath(expanded),
        )

    parts = source.split("/")
    if len(parts) < 2 or not all(parts[:2]):
        raise ValueError(
            f"Weight source {source!r} is neither a local path nor an "
            "owner/repo Hugging Face reference"
        )
    repo_id = "/".join(parts[:2])
    validate_repo_id(repo_id)
    tail = "/".join(parts[2:]) or None
    filename = (
        _validate_relative_hub_path(tail, "filename")
        if tail is not None and tail.lower().endswith(_WEIGHT_SUFFIXES)
        else None
    )
    subfolder = tail if filename is None else None
    if subfolder is not None:
        subfolder = _validate_relative_hub_path(subfolder, "subfolder")
    return WeightSource(
        original=source,
        kind="huggingface",
        repo_id=repo_id,

View on GitHub (pinned to 0132848349)

Solutions

  1. Check spelling and use the full 'owner/repo' HF id
  2. If it is meant to be local, verify the path exists (and that '~' / env vars are intended)
  3. For full URLs, use the huggingface.co URL form with a revision/file path so it is routed to the HF parser

Example fix

# before
parse_weight_source("flux-dev")
# after
parse_weight_source("black-forest-labs/flux-dev")
Defensive patterns

Strategy: validation

Validate before calling

import os

def is_valid_source(s: str) -> bool:
    if os.path.exists(os.path.expanduser(s)):
        return True
    parts = s.split("/")
    return len(parts) >= 2 and all(parts[:2])

Type guard

def is_owner_repo_ref(s: str) -> bool:
    parts = s.split("/")
    return len(parts) >= 2 and all(parts[:2]) and "://" not in s

Try / catch

try:
    src = parse_weight_source(user_input)
except ValueError as e:
    raise SystemExit(f"Bad weight source: {e}") from e

Prevention

When it happens

Trigger: Passing a bare model name like 'stable-diffusion' (one segment), an empty string, a URL that failed local-path expansion, or a typo'd repo id; also a local-looking path that does not exist.

Common situations: Typos in repo ids; forgetting the namespace prefix on HF hub ids; passing a path with an unexpanded '~' that does not exist; passing an http URL that is not recognized as a HF URL format.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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