sgl-project/sglang · error · ValueError

Model directory {model_path} is missing required component d

Error message

Model directory {model_path} is missing required component directories: {missing_str}.

What it means

Each component key in model_index.json must correspond to a subdirectory of the model path. verify_model_config_and_directory collects keys with nested config (non-string values) and raises ValueError listing any subdirectories that are missing.

Source

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

    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)
            raise ValueError(
                f"Model directory {model_path} is missing required component "
                f"directories: {missing_str}."
            )
    else:
        transformer_dir = os.path.join(model_path, "transformer")
        vae_dir = os.path.join(model_path, "vae")
        if not os.path.exists(transformer_dir):
            raise ValueError(
                f"Model directory {model_path} does not contain a transformer/ directory."
            )
        if not os.path.exists(vae_dir):
            raise ValueError(
                f"Model directory {model_path} does not contain a vae/ directory."
            )
    return cast(dict[str, Any], config)


def _resolve_remote_repo_model_index_path(model_name_or_path: str) -> str:

View on GitHub (pinned to 0132848349)

Solutions

  1. Delete the incomplete local model directory and re-download fully
  2. If intentionally excluding a component (e.g. offloaded text encoder), remove its key from model_index.json or use the loader's component-override mechanism instead of deleting folders
Defensive patterns

Strategy: validation

Validate before calling

import json, os
idx = json.load(open(f'{model_path}/model_index.json'))
comps = [k for k, v in idx.items() if isinstance(v, (list, tuple))]
missing = [c for c in comps if not os.path.isdir(os.path.join(model_path, c))]
assert not missing, missing

Prevention

When it happens

Trigger: Calling from_pretrained on a partially downloaded model: model_index.json lists transformer/, vae/, text_encoder/ etc., but some of those directories are absent from the local snapshot.

Common situations: Interrupted downloads; manually deleting component folders to save disk; wrong-revision mixups where components live at a different revision.

Related errors


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