invoke-ai/InvokeAI · error · TypeError

Expected Main_Checkpoint_ZImage_Config, got {type(config).__

Error message

Expected Main_Checkpoint_ZImage_Config, got {type(config).__name__}. Model configuration type mismatch.

What it means

_load_from_singlefile in the Z-Image single-file loader only accepts Main_Checkpoint_ZImage_Config model configs. Before loading the safetensors checkpoint it asserts the config type with isinstance and throws TypeError if any other config class is passed. This guards against the wrong loader being dispatched for a model, e.g. a GGUF or diffusers-folder config routed to the checkpoint path.

Source

Thrown at invokeai/backend/model_manager/load/model_loaders/z_image.py:392

            raise ValueError("Only CheckpointConfigBase models are currently supported here.")

        match submodel_type:
            case SubModelType.Transformer:
                return self._load_from_singlefile(config)

        raise ValueError(
            f"Only Transformer submodels are currently supported. Received: {submodel_type.value if submodel_type else 'None'}"
        )

    def _load_from_singlefile(
        self,
        config: AnyModelConfig,
    ) -> AnyModel:
        from diffusers import ZImageTransformer2DModel
        from safetensors.torch import load_file

        if not isinstance(config, Main_Checkpoint_ZImage_Config):
            raise TypeError(
                f"Expected Main_Checkpoint_ZImage_Config, got {type(config).__name__}. "
                "Model configuration type mismatch."
            )
        model_path = Path(config.path)

        # Load the state dict from safetensors/checkpoint file
        sd = load_file(model_path)

        # Some Z-Image checkpoint files have keys prefixed with "diffusion_model." or
        # "model.diffusion_model." (ComfyUI-style format). Check if we need to strip this prefix.
        prefix_to_strip = None
        for prefix in ["model.diffusion_model.", "diffusion_model."]:
            if any(k.startswith(prefix) for k in sd.keys() if isinstance(k, str)):
                prefix_to_strip = prefix
                break

        if prefix_to_strip:
            stripped_sd = {}

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Re-register/re-convert the model so its config type is Main_Checkpoint_ZImage_Config (checkpoint/safetensors single-file format).
  2. Check the model entry in the InvokeAI model manager UI/API and fix its 'format'/'config' so it matches the actual file type (GGUF vs checkpoint).
  3. If loading a GGUF or SDNQ model, ensure the matching loader class (GGUF or SDNQ loader) handles it, not the checkpoint loader.
  4. Verify no custom code calls ZimageCheckpointLoader._load_model directly with a foreign config.

Example fix

// before
config = Main_GGUF_ZImage_Config(path=model_file)
model = checkpoint_loader._load_model(config, SubModelType.Transformer)
// after
if isinstance(model_file, str) and model_file.endswith('.gguf'):
    config = Main_GGUF_ZImage_Config(path=model_file)
    model = gguf_loader._load_model(config, SubModelType.Transformer)
else:
    config = Main_Checkpoint_ZImage_Config(path=model_file)
    model = checkpoint_loader._load_model(config, SubModelType.Transformer)
Defensive patterns

Strategy: type-guard

Validate before calling

from invokeai.backend.model_manager.load.model_loaders.z_image import Main_Checkpoint_ZImage_Config
if not isinstance(config, Main_Checkpoint_ZImage_Config):
    raise TypeError(f"checkpoint loader requires Main_Checkpoint_ZImage_Config, got {type(config).__name__}")

Type guard

def is_zimage_checkpoint_config(config: AnyModelConfig) -> bool:
    return isinstance(config, Main_Checkpoint_ZImage_Config)

Try / catch

try:
    model = loader._load_model(config, SubModelType.Transformer)
except TypeError as e:
    if "Main_Checkpoint_ZImage_Config" in str(e):
        config = reclassify_config(config_path)  # fix model record, then retry
        model = loader._load_model(config, SubModelType.Transformer)
    else:
        raise

Prevention

When it happens

Trigger: Calling _load_model on the single-file Z-Image loader with a config that is not Main_Checkpoint_ZImage_Config — e.g. a Main_GGUF_ZImage_Config, Main_SDNQ_*_Config, or diffusers-folder config — so the isinstance check at z_image.py:392 fails and TypeError is raised.

Common situations: Selecting a GGUF or SDNQ quantized Z-Image checkpoint but the model manager resolves it to the checkpoint-loader class; registering a model with the wrong config type in the model record; a custom installer script instantiating the loader directly with a generic Checkpoint_Config_Base.

Related errors


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