{"record":{"id":"40dcd9a01f025f76","repo":"invoke-ai/InvokeAI","slug":"model-looks-like-an-anima-lora-not-a-stable-diffu","errorCode":null,"errorMessage":"model looks like an Anima LoRA, not a Stable Diffusion LoRA","messagePattern":"model looks like an Anima LoRA, not a Stable Diffusion LoRA","errorType":"exception","errorClass":"NotAMatchError","httpStatus":null,"severity":"warning","filePath":"invokeai/backend/model_manager/configs/lora.py","lineNumber":651,"sourceCode":"        )\n\n        if not has_key_with_lora_prefix and not has_key_with_lora_suffix:\n            raise NotAMatchError(\"model does not match LyCORIS LoRA heuristics\")\n\n    @classmethod\n    def _get_base_or_raise(cls, mod: ModelOnDisk) -> BaseModelType:\n        if _get_flux_lora_format(mod):\n            if _is_flux2_lora(mod):\n                return BaseModelType.Flux2\n            return BaseModelType.Flux\n\n        state_dict = mod.load_state_dict()\n        str_keys = [k for k in state_dict.keys() if isinstance(k, str)]\n\n        # Rule out Anima LoRAs — their lora_te_ keys have shapes that\n        # lora_token_vector_length() misidentifies as SD2/SDXL.\n        if has_cosmos_dit_kohya_keys(str_keys) or has_cosmos_dit_peft_keys(str_keys):\n            raise NotAMatchError(\"model looks like an Anima LoRA, not a Stable Diffusion LoRA\")\n\n        # If we've gotten here, we assume that the model is a Stable Diffusion model\n        token_vector_length = lora_token_vector_length(state_dict)\n        if token_vector_length == 768:\n            return BaseModelType.StableDiffusion1\n        elif token_vector_length == 1024:\n            return BaseModelType.StableDiffusion2\n        elif token_vector_length == 1280:\n            return BaseModelType.StableDiffusionXL  # recognizes format at https://civitai.com/models/224641\n        elif token_vector_length == 2048:\n            return BaseModelType.StableDiffusionXL\n        # Some SDXL LoRAs (e.g. self-attention-only \"slider\" LoRAs) target only the UNet\n        # and lack the cross-attention / text-encoder keys that lora_token_vector_length()\n        # needs. Fall back to detecting SDXL from the UNet's deep transformer-block structure.\n        elif _state_dict_looks_like_sdxl_unet_lora(state_dict):\n            return BaseModelType.StableDiffusionXL\n        else:\n            raise NotAMatchError(f\"unrecognized token vector length {token_vector_length}\")","sourceCodeStart":633,"sourceCodeEnd":669,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/lora.py#L633-L669","documentation":"When detecting the base of a Stable Diffusion LoRA, `_get_base_or_raise` first rules out Anima LoRAs: their `lora_te_` text-encoder key shapes would make `lora_token_vector_length()` misreport the base as SD2/SDXL. If Cosmos-DiT Kohya or PEFT key patterns are found, the model is identified as an Anima LoRA and `NotAMatchError` is raised so the SD LoRA config classes reject it.","triggerScenarios":"`from_model_on_disk` on an SD-family LoRA probe where the state dict contains `has_cosmos_dit_kohya_keys` or `has_cosmos_dit_peft_keys` patterns (Anima LoRA weights) — i.e. importing an Anima LoRA through the Stable Diffusion LoRA config path.","commonSituations":"Autoimport folder containing Anima LoRAs alongside SD LoRAs; downloading an Anima LoRA believing it is SD1.5/SDXL-compatible; a converted Anima LoRA retaining Cosmos-DiT key naming.","solutions":["Confirm the LoRA's source model — if it's Anima, use it only with Anima checkpoints / a config that supports it","Re-export or convert the Anima LoRA to standard SD/SDXL LoRA key format if it was mislabeled","Remove the Anima LoRA from the SD LoRA import path and register it under the correct model type","Upgrade InvokeAI to a version with dedicated Anima LoRA support"],"exampleFix":"// before: importing an Anima (Cosmos-DiT keys) file as SD LoRA\nSD_LoRA_Config.from_model_on_disk(anima_lora_dir)  # NotAMatchError\n// after: use a config/matcher for Anima, or convert keys to lora_te_/lora_unet_ SD format\nAnima_LoRA_Config.from_model_on_disk(anima_lora_dir)","handlingStrategy":"validation","validationCode":"from invokeai.backend.model_manager.util.lora_conversions import has_cosmos_dit_kohya_keys, has_cosmos_dit_peft_keys\nsd = mod.load_state_dict()\nkeys = [k for k in sd.keys() if isinstance(k, str)]\nif has_cosmos_dit_kohya_keys(keys) or has_cosmos_dit_peft_keys(keys):\n    print(\"Anima LoRA — do not import as SD LoRA\")","typeGuard":"def is_anima_lora(keys: list[str]) -> bool:\n    from invokeai.backend.model_manager.util.lora_conversions import has_cosmos_dit_kohya_keys, has_cosmos_dit_peft_keys\n    return has_cosmos_dit_kohya_keys(keys) or has_cosmos_dit_peft_keys(keys)","tryCatchPattern":"try:\n    cfg = StableDiffusionLoRAConfig.from_model_on_disk(mod)\nexcept NotAMatchError as e:\n    if \"Anima\" in str(e):\n        print(\"use Anima-compatible tooling or convert the LoRA\")","preventionTips":["Keep Anima LoRAs out of SD autoimport folders","Check key naming (Cosmos-DiT patterns) before import","Convert Anima LoRAs to SD key format if SD use is intended"],"tags":["lora","anima","sd","key-detection"],"backgroundTag":"model-base-detection-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}