invoke-ai/InvokeAI · error · ValueError

The "{submodel_type}" submodel is not available for this mod

Error message

The "{submodel_type}" submodel is not available for this model.

What it means

get_hf_load_class resolves the Python class for a requested submodel by reading the diffusers model_index.json and indexing it with submodel_type.value. If the key is absent from model_index.json (KeyError) — i.e. this pipeline does not contain that submodel — it re-raises as this ValueError.

Source

Thrown at invokeai/backend/model_manager/load/model_loaders/generic_diffusers.py:63

                e
            ):  # try without the variant, just in case user's preferences changed
                result = model_class.from_pretrained(model_path, torch_dtype=self._torch_dtype, local_files_only=True)
            else:
                raise e
        result = self._apply_fp8_layerwise_casting(result, config, submodel_type)
        return result

    # TO DO: Add exception handling
    def get_hf_load_class(self, model_path: Path, submodel_type: Optional[SubModelType] = None) -> ModelMixin:
        """Given the model path and submodel, returns the diffusers ModelMixin subclass needed to load."""
        result = None
        if submodel_type:
            try:
                config = self._load_diffusers_config(model_path, config_name="model_index.json")
                module, class_name = config[submodel_type.value]
                result = self._hf_definition_to_type(module=module, class_name=class_name)
            except KeyError as e:
                raise ValueError(f'The "{submodel_type}" submodel is not available for this model.') from e
        else:
            try:
                config = self._load_diffusers_config(model_path, config_name="config.json")
                if class_name := config.get("_class_name"):
                    result = self._hf_definition_to_type(module="diffusers", class_name=class_name)
                elif class_name := config.get("architectures"):
                    result = self._hf_definition_to_type(module="transformers", class_name=class_name[0])
                else:
                    raise RuntimeError("Unable to decipher Load Class based on given config.json")
            except KeyError as e:
                raise ValueError("An expected config.json file is missing from this model.") from e
        assert result is not None
        return result

    # TO DO: Add exception handling
    def _hf_definition_to_type(self, module: str, class_name: str) -> ModelMixin:  # fix with correct type
        if module in [
            "diffusers",

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Verify model_index.json actually contains the requested submodel key before requesting it
  2. Load only submodels the pipeline provides; get the rest from a different model
  3. Fix or regenerate model_index.json if it is corrupt or incomplete

Example fix

# before
cls = loader.get_hf_load_class(path, SubModelType.TextEncoder)  # VAE-only repo
# after
if SubModelType.TextEncoder.value in json.loads((path / "model_index.json").read_text()):
    cls = loader.get_hf_load_class(path, SubModelType.TextEncoder)
Defensive patterns

Strategy: validation

Validate before calling

import json
def submodel_available(model_path, submodel_type):
    mi = json.loads((model_path / "model_index.json").read_text())
    return submodel_type.value in mi

Type guard

def has_submodel(model_path, st: SubModelType) -> bool:
    mi = json.loads((model_path / "model_index.json").read_text())
    return st.value in mi

Try / catch

try:
    cls = loader.get_hf_load_class(model_path, submodel_type)
except ValueError as e:
    if "submodel is not available for this model" in str(e):
        print(f"{submodel_type} absent from this pipeline; load it from another model")
    else:
        raise

Prevention

When it happens

Trigger: Requesting e.g. SubModelType.TextEncoder from a diffusers pipeline that has no text_encoder entry (unconditional models, some VAE-only dirs, ControlNet repos), or a model_index.json missing/corrupt entries.

Common situations: Loading ControlNet/VAE-only directories as full pipelines; older or hand-assembled diffusers repos lacking standard keys; typos in submodel lookups; models exported without optional components (e.g. safety_checker).

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/0dae49498259a966. Report an issue: GitHub.