invoke-ai/InvokeAI · error · ValueError

Expected Main_Diffusers_Ideogram4_Config, got {type(config).

Error message

Expected Main_Diffusers_Ideogram4_Config, got {type(config).__name__}.

What it means

The Ideogram 4 loader only accepts its typed config record Main_Diffusers_Ideogram4_Config. Passing any other config subclass (another model family's or a generic checkpoint config) means the loader's assumptions about config.path and the diffusers layout would be invalid, so it fails fast with a ValueError naming the actual type received.

Source

Thrown at invokeai/backend/model_manager/load/model_loaders/ideogram4.py:83

    ]
    if meta:
        raise RuntimeError(
            f"{context}: {len(meta)} parameter(s) remain on the meta device after loading "
            f"(missing or mismatched weights): {meta[:10]}"
        )


@ModelLoaderRegistry.register(base=BaseModelType.Ideogram4, type=ModelType.Main, format=ModelFormat.Diffusers)
class Ideogram4DiffusersModel(ModelLoader):
    """Loads Ideogram 4 main models (nf4 / fp8) bundled in diffusers layout."""

    def _load_model(
        self,
        config: AnyModelConfig,
        submodel_type: Optional[SubModelType] = None,
    ) -> AnyModel:
        if not isinstance(config, Main_Diffusers_Ideogram4_Config):
            raise ValueError(f"Expected Main_Diffusers_Ideogram4_Config, got {type(config).__name__}.")
        if submodel_type is None:
            raise Exception("A submodel type must be provided when loading Ideogram 4 main pipelines.")

        model_path = Path(config.path)

        match submodel_type:
            case SubModelType.Transformer:
                return self._load_transformer_pair(model_path)
            case SubModelType.TextEncoder:
                return self._load_text_encoder(model_path)
            case SubModelType.Tokenizer:
                from transformers import AutoTokenizer

                return AutoTokenizer.from_pretrained(model_path / "tokenizer", local_files_only=True)
            case SubModelType.VAE:
                return self._load_vae(model_path)

        raise ValueError(

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Ensure the model record is stored as Main_Diffusers_Ideogram4_Config (correct base/type/format fields) so registry dispatch creates the right config class.
  2. Wrap or convert the incoming config to Main_Diffusers_Ideogram4_Config before calling the loader.
  3. Check the loader registration/dispatch logic — BaseModelType.Ideogram4 with ModelType.Main and ModelFormat.Diffusers — is being matched.

Example fix

// before
loader._load_model(SomeOtherConfig(path=...), SubModelType.Transformer)
// after
from invokeai.backend.model_manager.configs.main import Main_Diffusers_Ideogram4_Config
cfg = Main_Diffusers_Ideogram4_Config(path=...)
loader._load_model(cfg, SubModelType.Transformer)
Defensive patterns

Strategy: type-guard

Validate before calling

from invokeai.backend.model_manager.configs.main import Main_Diffusers_Ideogram4_Config
if not isinstance(config, Main_Diffusers_Ideogram4_Config):
    raise TypeError(f"need Ideogram4 config, got {type(config).__name__}")

Type guard

def is_ideogram4_config(config) -> bool:
    from invokeai.backend.model_manager.configs.main import Main_Diffusers_Ideogram4_Config
    return isinstance(config, Main_Diffusers_Ideogram4_Config)

Try / catch

try:
    model = loader._load_model(config, submodel_type)
except ValueError as e:
    if "Expected Main_Diffusers_Ideogram4_Config" in str(e):
        config = convert_to_ideogram4_config(config)
        model = loader._load_model(config, submodel_type)
    else:
        raise

Prevention

When it happens

Trigger: Calling _load_model (or dispatching a load through the model manager) with a config object that is not an instance of Main_Diffusers_Ideogram4_Config while routing to the Ideogram4 loader.

Common situations: Model-registry records pointing at the wrong loader; hand-written loader invocations reusing another model's config object; config serialization/deserialization yielding a base config type instead of the specific one.

Related errors


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