sgl-project/sglang · error · ValueError

Only huggingface.co weight URLs are supported; use a local p

Error message

Only huggingface.co weight URLs are supported; use a local path or an owner/repo reference for other sources

What it means

Raised by _parse_huggingface_url when a URL-style weight source's host is not huggingface.co (or www.huggingface.co). Only huggingface.co URLs are parsed; other hosts must be referenced differently.

Source

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

    pure_path = PurePosixPath(normalized)
    if not path or pure_path.is_absolute() or ".." in pure_path.parts:
        raise ValueError(f"Invalid Hugging Face {field_name}: {path!r}")
    return normalized


def _merge_revision(url_revision: str | None, revision: str | None) -> str | None:
    if url_revision is not None and revision is not None and url_revision != revision:
        raise ValueError(
            f"Weight URL pins revision {url_revision!r}, which conflicts with "
            f"revision {revision!r}"
        )
    return url_revision or revision


def _parse_huggingface_url(source: str, revision: str | None) -> WeightSource:
    parsed = urlparse(source)
    if parsed.netloc.lower() not in ("huggingface.co", "www.huggingface.co"):
        raise ValueError(
            "Only huggingface.co weight URLs are supported; use a local path "
            "or an owner/repo reference for other sources"
        )

    raw_parts = [part for part in parsed.path.split("/") if part]
    if raw_parts and raw_parts[0] in ("datasets", "spaces"):
        raise ValueError("Diffusion weights must come from a Hugging Face model repo")
    if len(raw_parts) < 2:
        raise ValueError(f"Hugging Face weight URL has no model repo: {source!r}")

    repo_id = "/".join(unquote(part) for part in raw_parts[:2])
    validate_repo_id(repo_id)
    action = raw_parts[2] if len(raw_parts) > 2 else None
    if action is None:
        return WeightSource(
            original=source,
            kind="huggingface",
            repo_id=repo_id,

View on GitHub (pinned to 0132848349)

Solutions

  1. Download or export the weights locally and pass a local filesystem path instead
  2. Use the owner/repo identifier form if the repo is (mirrored to) Hugging Face
  3. Switch the host to huggingface.co if the URL was merely mistyped

Example fix

# before
parse_weight_source("https://modelscope.cn/org/repo")
# after
parse_weight_source("/data/weights/org-repo")  # local snapshot
# or
parse_weight_source("org/repo")
Defensive patterns

Strategy: type-guard

Validate before calling

from urllib.parse import urlparse
netloc = urlparse(source).netloc.lower()
if "://" in source and netloc not in ("huggingface.co", "www.huggingface.co"):
    source = download_to_local(source)  # or map to owner/repo

Type guard

def is_supported_weight_source(source: str) -> bool:
    if "://" not in source:
        return True  # local path or owner/repo
    return urlparse(source).netloc.lower() in ("huggingface.co", "www.huggingface.co")

Try / catch

try:
    src = parse_weight_source(source)
except ValueError as e:
    if "Only huggingface.co" in str(e):
        src = parse_weight_source(mirror_to_local_path(source))
    else:
        raise

Prevention

When it happens

Trigger: Calling parse_weight_source with e.g. https://modelscope.cn/org/repo or https://my-mirror.com/org/repo.

Common situations: Using a HF mirror/CDN domain, a ModelScope or S3 URL, or an internal artifact store while the loader only supports huggingface.co.

Related errors


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