{"record":{"id":"31ca58b384a21f71","repo":"invoke-ai/InvokeAI","slug":"base-is-recognized-base-not-expected-base","errorCode":null,"errorMessage":"base is {recognized_base}, not {expected_base}","messagePattern":"base is (.+?), not (.+?)","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/ip_adapter.py","lineNumber":60,"sourceCode":"        raise_if_not_dir(mod)\n\n        raise_for_override_fields(cls, override_fields)\n\n        cls._validate_has_weights_file(mod)\n\n        cls._validate_has_image_encoder_metadata_file(mod)\n\n        cls._validate_base(mod)\n\n        return cls(**override_fields)\n\n    @classmethod\n    def _validate_base(cls, mod: ModelOnDisk) -> None:\n        \"\"\"Raise `NotAMatch` if the model base does not match this config class.\"\"\"\n        expected_base = cls.model_fields[\"base\"].default\n        recognized_base = cls._get_base_or_raise(mod)\n        if expected_base is not recognized_base:\n            raise NotAMatchError(f\"base is {recognized_base}, not {expected_base}\")\n\n    @classmethod\n    def _validate_has_weights_file(cls, mod: ModelOnDisk) -> None:\n        weights_file = mod.path / \"ip_adapter.bin\"\n        if not weights_file.exists():\n            raise NotAMatchError(\"missing ip_adapter.bin weights file\")\n\n    @classmethod\n    def _validate_has_image_encoder_metadata_file(cls, mod: ModelOnDisk) -> None:\n        image_encoder_metadata_file = mod.path / \"image_encoder.txt\"\n        if not image_encoder_metadata_file.exists():\n            raise NotAMatchError(\"missing image_encoder.txt metadata file\")\n\n    @classmethod\n    def _get_base_or_raise(cls, mod: ModelOnDisk) -> BaseModelType:\n        state_dict = mod.load_state_dict()\n\n        try:","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/ip_adapter.py#L42-L78","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the cross_attention_dim in the adapter's state dict and register it with the matching base (768=SD1, 1024=SD2).","Download the IP-Adapter variant that matches your target base model.","Use the correct InvokeAI IP-Adapter config class for that base.","If the mapping is ambiguous (unsupported dims like 1280/2048), the model needs a dedicated config class; update InvokeAI."],"exampleFix":"// before: SD2 base IP-Adapter being registered as SD1\nconfig_class = MainIPAdapterConfig(base=BaseModelType.StableDiffusion1)\n// after\nconfig_class = MainIPAdapterConfig(base=BaseModelType.StableDiffusion2)  # cross_attention_dim == 1024","handlingStrategy":"validation","validationCode":"sd = mod.load_state_dict()\ndim = sd[\"ip_adapter\"][\"1.to_k_ip.weight\"].shape[-1]\nfrom invokeai.backend.model_manager import BaseModelType\nexpected = {768: BaseModelType.StableDiffusion1, 1024: BaseModelType.StableDiffusion2}[dim]\nassert expected is config_class.model_fields[\"base\"].default, f\"adapter is {expected}, config expects {config_class.model_fields['base'].default}\"","typeGuard":"def adapter_base_matches(sd, cfg_cls) -> bool:\n    from invokeai.backend.model_manager import BaseModelType\n    dim = sd[\"ip_adapter\"][\"1.to_k_ip.weight\"].shape[-1]\n    base = {768: BaseModelType.StableDiffusion1, 1024: BaseModelType.StableDiffusion2}.get(dim)\n    return base is cfg_cls.model_fields[\"base\"].default","tryCatchPattern":"try:\n    record = from_model_on_disk(mod)\nexcept NotAMatchError as e:\n    if str(e).startswith(\"base is\"):\n        logger.warning(\"IP-Adapter base mismatch, trying other base config: %s\", e)","preventionTips":["Download IP-Adapter variants matching your base model (SD1 vs SD2)","Cross-check cross_attention_dim in the state dict before registration","Keep original upstream filenames so base info isn't lost"],"tags":["ip-adapter","model-base-mismatch","invokeai"],"backgroundTag":"base-model-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}