sgl-project/sglang · error · ValueError

Diffusion weights must come from a Hugging Face model repo

Error message

Diffusion weights must come from a Hugging Face model repo

What it means

Raised by _parse_huggingface_url when the URL path starts with 'datasets' or 'spaces', i.e. the URL points at a Hugging Face dataset or Space rather than a model repo. Diffusion weights must live in a model repo.

Source

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

    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,
            revision=revision,
        )
    if action not in ("tree", "blob", "resolve") or len(raw_parts) < 4:
        raise ValueError(f"Unsupported Hugging Face weight URL: {source!r}")

    url_revision = unquote(raw_parts[3])
    selected_revision = _merge_revision(url_revision, revision)

View on GitHub (pinned to 0132848349)

Solutions

  1. Use the model-repo URL, e.g. https://huggingface.co/org/model-name
  2. Move/publish the weights into a model repo if they currently live in a dataset repo
  3. If it is genuinely dataset content, load it via a dataset loader, not the weight source parser

Example fix

# before
parse_weight_source("https://huggingface.co/datasets/org/diffusion-data")
# after
parse_weight_source("https://huggingface.co/org/diffusion-model")
Defensive patterns

Strategy: type-guard

Validate before calling

parts = [p for p in urlparse(url).path.split("/") if p]
if parts and parts[0] in ("datasets", "spaces"):
    raise ValueError("pass a model repo URL, not a dataset/space")

Type guard

def is_model_repo_url(url: str) -> bool:
    parts = [p for p in urlparse(url).path.split("/") if p]
    return not (parts and parts[0] in ("datasets", "spaces"))

Prevention

When it happens

Trigger: Calling parse_weight_source with https://huggingface.co/datasets/org/name or https://huggingface.co/spaces/org/name.

Common situations: Copying the wrong tab's URL from the Hub (datasets/spaces instead of models), or storing weights in a dataset repo for quota reasons.

Related errors


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