invoke-ai/InvokeAI · info · NotAMatchError

base is {recognized_base}, not {expected_base}

Error message

base is {recognized_base}, not {expected_base}

What it means

Each main-model config class declares an expected base (e.g. SD1) and validates by calling its _get_base_or_raise on the state dict. If the probed base differs from the class's default base, from_model_on_disk raises NotAMatchError stating 'base is X, not Y'. This is part of the normal probe chain: it signals the model belongs to a different config class.

Source

Thrown at invokeai/backend/model_manager/configs/main.py:367

        cls._validate_looks_like_main_model(mod)

        cls._validate_base(mod)

        prediction_type = override_fields.pop("prediction_type", None) or cls._get_scheduler_prediction_type_or_raise(
            mod
        )

        variant = override_fields.pop("variant", None) or cls._get_variant_or_raise(mod)

        return cls(**override_fields, prediction_type=prediction_type, variant=variant)

    @classmethod
    def _validate_base(cls, mod: ModelOnDisk) -> None:
        """Raise `NotAMatch` if the model base does not match this config class."""
        expected_base = cls.model_fields["base"].default
        recognized_base = cls._get_base_or_raise(mod)
        if expected_base is not recognized_base:
            raise NotAMatchError(f"base is {recognized_base}, not {expected_base}")

    @classmethod
    def _get_base_or_raise(cls, mod: ModelOnDisk) -> BaseModelType:
        state_dict = mod.load_state_dict()

        key_name = "model.diffusion_model.input_blocks.2.1.transformer_blocks.0.attn2.to_k.weight"
        if key_name in state_dict and state_dict[key_name].shape[-1] == 768:
            return BaseModelType.StableDiffusion1
        if key_name in state_dict and state_dict[key_name].shape[-1] == 1024:
            return BaseModelType.StableDiffusion2

        key_name = "model.diffusion_model.input_blocks.4.1.transformer_blocks.0.attn2.to_k.weight"
        if key_name in state_dict and state_dict[key_name].shape[-1] == 2048:
            return BaseModelType.StableDiffusionXL
        elif key_name in state_dict and state_dict[key_name].shape[-1] == 1280:
            return BaseModelType.StableDiffusionXLRefiner

        raise NotAMatchError("unable to determine base type from state dict")

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Let the full probe chain run — this error from one class is expected when another class matches; ensure your InvokeAI version includes configs for the model's actual base.
  2. If you force base via override fields, make it match the checkpoint's true architecture.
  3. Verify the checkpoint is what you think it is (check attn2.to_k weight shapes: 768=SD1, 1024=SD2, 2048=SDXL).
  4. Update InvokeAI to the latest version to gain config classes for newer bases.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    cfg = Main_Checkpoint_SD1_Config.from_model_on_disk(mod)
except NotAMatchError as e:
    log.info('Not SD1 (%s); trying next config class', e)
    cfg = None

Prevention

When it happens

Trigger: Scanning a checkpoint whose detected base (from distinguishing keys like input_blocks attn2.to_k shapes) does not equal the config class default, e.g. an SD2 checkpoint being validated by Main_Checkpoint_SD1_Config.

Common situations: Importing SDXL/SD2 checkpoints into an older InvokeAI that lacks the matching config class; overrides forcing the wrong config family; miscategorized model folders.

Related errors


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