sgl-project/sglang · error · ValueError

model_index.json does not contain _diffusers_version

Error message

model_index.json does not contain _diffusers_version

What it means

After loading model_index.json, verify_model_config_and_directory checks it declares _diffusers_version, which diffusers always writes when saving a pipeline. Its absence means the JSON is not a genuine diffusers model_index (hand-written, stripped, or wrong file).

Source

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

    Returns:
        The loaded model configuration as a dictionary
    """

    # Check for model_index.json which is required for diffusers models
    config_path = os.path.join(model_path, "model_index.json")
    if not os.path.exists(config_path):
        raise ValueError(
            f"Model directory {model_path} does not contain model_index.json. "
            "Only HuggingFace diffusers format is supported."
        )

    # Load the config
    with open(config_path) as f:
        config = json.load(f)

    # Verify diffusers version exists
    if "_diffusers_version" not in config:
        raise ValueError("model_index.json does not contain _diffusers_version")

    logger.info("Diffusers version: %s", config["_diffusers_version"])

    component_keys = [
        key
        for key, value in config.items()
        if isinstance(value, (list, tuple))
        and len(value) == 2
        and all(isinstance(item, str) for item in value)
    ]
    if component_keys:
        missing_components = [
            component_key
            for component_key in component_keys
            if not os.path.exists(os.path.join(model_path, component_key))
        ]
        if missing_components:
            missing_str = ", ".join(missing_components)

View on GitHub (pinned to 0132848349)

Solutions

  1. Add "_diffusers_version": "0.x.y" matching the pipeline's target version to model_index.json
  2. Re-download the model so the original model_index.json is restored

Example fix

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

Strategy: validation

Validate before calling

cfg = json.load(open(f'{model_path}/model_index.json'))
assert '_diffusers_version' in cfg

Prevention

When it happens

Trigger: Calling verify_model_config_and_directory on a directory whose model_index.json lacks the _diffusers_version key — e.g. a custom/minimal index or an older/edited snapshot.

Common situations: Hand-crafted model directories assembled from pieces; JSON sanitized by a deployment pipeline that dropped underscore-prefixed keys.

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/3520c51dd9d6537a. Report an issue: GitHub.