sgl-project/sglang · error · ValueError

model_index.json for {model_name_or_path} does not contain _

Error message

model_index.json for {model_name_or_path} does not contain _class_name field

What it means

maybe_download_model_index validates the downloaded model_index.json requires a _class_name field (the pipeline class, e.g. FluxPipeline). Missing field means the JSON is not a valid diffusers pipeline index.

Source

Thrown at python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py:823

            # Not a pipeline, maybe a single model.
            config_path = os.path.join(model_name_or_path, "config.json")
            if os.path.exists(config_path):
                with open(config_path) as f:
                    config = json.load(f)
                return config
            raise

    # For remote models, resolve model_index.json (Hub-first, cache fallback).
    try:
        model_index_path = _resolve_remote_repo_model_index_path(model_name_or_path)

        # Load the model_index.json
        with open(model_index_path) as f:
            config: dict[str, Any] = json.load(f)

        # Verify it has the required fields
        if "_class_name" not in config:
            raise ValueError(
                f"model_index.json for {model_name_or_path} does not contain _class_name field"
            )

        if "_diffusers_version" not in config:
            raise ValueError(
                f"model_index.json for {model_name_or_path} does not contain _diffusers_version field"
            )

        # Add the pipeline name for downstream use
        config["pipeline_name"] = config["_class_name"]

        logger.debug(
            "Resolved model_index.json for %s, pipeline: %s",
            model_name_or_path,
            config["_class_name"],
        )
        return config
    except EntryNotFoundError:

View on GitHub (pinned to 0132848349)

Solutions

  1. Add "_class_name": "<PipelineName>" to the repo's model_index.json
  2. Use the official diffusers repo revision for the model

Example fix

// model_index.json before: {}
// after: {"_class_name":"FluxPipeline","_diffusers_version":"0.32.0"}
Defensive patterns

Strategy: validation

Validate before calling

cfg = json.load(open(model_index_path))
assert '_class_name' in cfg

Prevention

When it happens

Trigger: Calling _get_config_info / get_model_info / _has_pe_in_model_index on a repo whose model_index.json lacks _class_name — hand-written index, stripped metadata, or a non-pipeline JSON that happens to be named model_index.json.

Common situations: Custom-merged model repos; metadata-stripping proxies/mirrors; misconfigured cache serving the wrong file.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


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