invoke-ai/InvokeAI · error · NotAMatchError

base is {recognized_base}, not {expected_base}

Error message

base is {recognized_base}, not {expected_base}

What it means

IPAdapterModelConfig._validate_base compares the base model detected from the IP-Adapter state dict's cross-attention dimension with the config class's expected `base` default. If they differ (identity check on BaseModelType), NotAMatchError is raised. This ensures an SD1 IP-Adapter is not registered as an SD2 one, since the two share the same file layout.

Source

Thrown at invokeai/backend/model_manager/configs/ip_adapter.py:60

        raise_if_not_dir(mod)

        raise_for_override_fields(cls, override_fields)

        cls._validate_has_weights_file(mod)

        cls._validate_has_image_encoder_metadata_file(mod)

        cls._validate_base(mod)

        return cls(**override_fields)

    @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 _validate_has_weights_file(cls, mod: ModelOnDisk) -> None:
        weights_file = mod.path / "ip_adapter.bin"
        if not weights_file.exists():
            raise NotAMatchError("missing ip_adapter.bin weights file")

    @classmethod
    def _validate_has_image_encoder_metadata_file(cls, mod: ModelOnDisk) -> None:
        image_encoder_metadata_file = mod.path / "image_encoder.txt"
        if not image_encoder_metadata_file.exists():
            raise NotAMatchError("missing image_encoder.txt metadata file")

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

        try:

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Check the cross_attention_dim in the adapter's state dict and register it with the matching base (768=SD1, 1024=SD2).
  2. Download the IP-Adapter variant that matches your target base model.
  3. Use the correct InvokeAI IP-Adapter config class for that base.
  4. If the mapping is ambiguous (unsupported dims like 1280/2048), the model needs a dedicated config class; update InvokeAI.

Example fix

// before: SD2 base IP-Adapter being registered as SD1
config_class = MainIPAdapterConfig(base=BaseModelType.StableDiffusion1)
// after
config_class = MainIPAdapterConfig(base=BaseModelType.StableDiffusion2)  # cross_attention_dim == 1024
Defensive patterns

Strategy: validation

Validate before calling

sd = mod.load_state_dict()
dim = sd["ip_adapter"]["1.to_k_ip.weight"].shape[-1]
from invokeai.backend.model_manager import BaseModelType
expected = {768: BaseModelType.StableDiffusion1, 1024: BaseModelType.StableDiffusion2}[dim]
assert expected is config_class.model_fields["base"].default, f"adapter is {expected}, config expects {config_class.model_fields['base'].default}"

Type guard

def adapter_base_matches(sd, cfg_cls) -> bool:
    from invokeai.backend.model_manager import BaseModelType
    dim = sd["ip_adapter"]["1.to_k_ip.weight"].shape[-1]
    base = {768: BaseModelType.StableDiffusion1, 1024: BaseModelType.StableDiffusion2}.get(dim)
    return base is cfg_cls.model_fields["base"].default

Try / catch

try:
    record = from_model_on_disk(mod)
except NotAMatchError as e:
    if str(e).startswith("base is"):
        logger.warning("IP-Adapter base mismatch, trying other base config: %s", e)

Prevention

When it happens

Trigger: from_model_on_disk probing an IP-Adapter whose detected base (768 -> SD1, 1024 -> SD2 from ip_adapter.1.to_k_ip.weight shape) does not equal the config class's default base.

Common situations: Mixing up SD1 and SD2 IP-Adapter downloads; files renamed so the base can no longer be inferred from the name; probing with the wrong IP-Adapter config subclass.

Related errors


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