sgl-project/sglang · error · ValueError

Model directory {model_path} does not contain model_index.js

Error message

Model directory {model_path} does not contain model_index.json. Only HuggingFace diffusers format is supported.

What it means

verify_model_config_and_directory requires a diffusers-format model: the directory must contain model_index.json. If missing (e.g. you pointed at a single-file checkpoint or a non-diffusers repo), ValueError.

Source

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

        )
    return target


def verify_model_config_and_directory(model_path: str) -> dict[str, Any]:
    """
    Verify that the model directory contains a valid diffusers configuration.

    Args:
        model_path: Path to the model directory

    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))

View on GitHub (pinned to 0132848349)

Solutions

  1. Use the diffusers-format repo (often suffixed '-Diffusers') instead of the original single-file checkpoint
  2. If it's a legit diffusers model, re-download fully — model_index.json may have been lost
  3. For single transformer components, use the component-specific loader rather than the pipeline loader

Example fix

# before
--model stabilityai/stable-diffusion-3-medium  # non-diffusers layout
# after
--model stabilityai/stable-diffusion-3-medium-diffusers
Defensive patterns

Strategy: validation

Validate before calling

import os
assert os.path.isfile(os.path.join(model_path, 'model_index.json')), 'not a diffusers-format model'

Try / catch

try:
    from_pretrained(path)
except ValueError as e:
    if 'model_index.json' in str(e):
        from_pretrained(diffusers_variant_repo)

Prevention

When it happens

Trigger: Calling from_pretrained / _load_config / maybe_download_model_index with a model_path that has no model_index.json — e.g. a raw transformer folder, a ComfyUI/single-file .safetensors checkpoint, or a GGUF repo.

Common situations: Using a checkpoint that is not the '-Diffusers' variant of a model; downloading only the transformer component; passing a config-only path.

Related errors


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