{"record":{"id":"a8b641a24e13fda7","repo":"invoke-ai/InvokeAI","slug":"model-does-not-look-like-an-anima-lora","errorCode":null,"errorMessage":"model does not look like an Anima LoRA","messagePattern":"model does not look like an Anima LoRA","errorType":"exception","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/lora.py","lineNumber":1079,"sourceCode":"            return\n\n        raise NotAMatchError(\"model does not match Anima LoRA heuristics\")\n\n    @classmethod\n    def _get_base_or_raise(cls, mod: ModelOnDisk) -> BaseModelType:\n        \"\"\"Anima LoRAs target Cosmos DiT blocks (blocks.X.mlp, blocks.X.adaln_modulation,\n        blocks.X.cross_attn.q_proj, etc.).\n\n        Uses the strict Cosmos-DiT detectors to be mutually exclusive with\n        Wan-LoRA detection — see ``_validate_looks_like_lora`` for rationale.\n        \"\"\"\n        state_dict = mod.load_state_dict()\n        str_keys = [k for k in state_dict.keys() if isinstance(k, str)]\n\n        if has_cosmos_dit_kohya_keys_strict(str_keys) or has_cosmos_dit_peft_keys_strict(str_keys):\n            return BaseModelType.Anima\n\n        raise NotAMatchError(\"model does not look like an Anima LoRA\")\n\n\nclass LoRA_LyCORIS_Wan_Config(LoRA_LyCORIS_Config_Base, Config_Base):\n    \"\"\"Model config for Wan 2.2 LoRA models in LyCORIS format.\n\n    Wan LoRAs target ``WanTransformer3DModel`` blocks. The Wan 2.2 A14B family\n    is dual-expert (high-noise + low-noise) — LoRAs are typically trained\n    against one expert. ``expert`` records which one so the model loader\n    invocation can wire it to the correct ``loras`` / ``loras_low_noise`` list.\n    Many LoRAs are expert-agnostic (TI2V-5B family, or community LoRAs that\n    just don't tag the expert) — these get ``expert=None`` and are applied to\n    both experts by default.\n    \"\"\"\n\n    base: Literal[BaseModelType.Wan] = Field(default=BaseModelType.Wan)\n    expert: Literal[\"high\", \"low\"] | None = Field(\n        default=None,\n        description=\"For Wan 2.2 A14B dual-expert LoRAs: 'high' targets the high-noise expert, \"","sourceCodeStart":1061,"sourceCodeEnd":1097,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/lora.py#L1061-L1097","documentation":"NotAMatchError raised by LoRA_LyCORIS_Anima_Config._get_base_or_raise when a candidate LyCORIS LoRA's state-dict keys fail both strict Cosmos-DiT detectors (Kohya and PEFT/diffusers forms). Anima LoRAs target Cosmos DiT blocks (blocks.X.mlp, adaln_modulation, cross_attn.q_proj etc.); the strict detectors require one of those Anima-exclusive subcomponent names so detection stays mutually exclusive with Wan LoRAs. The error is part of InvokeAI's first-match-wins model probing: each config class raises it to say 'this file is not mine' so the probe can try the next class.","triggerScenarios":"Calling the model-install/probe path (e.g. ModelInstallService or _get_base_or_raise via _validate_base) on a file the router offers to LoRA_LyCORIS_Anima_Config whose state_dict contains no keys matching has_cosmos_dit_kohya_keys_strict or has_cosmos_dit_peft_keys_strict — e.g. a Wan, FLUX, or SD LoRA, or a Cosmos LoRA saved with loose/renamed key layouts lacking mlp/adaln_modulation/_proj-suffixed attention names.","commonSituations":"Downloading a Wan 2.2 or FLUX LoRA that gets routed into the LyCORIS Anima probe first; training a Cosmos-DiT LoRA with a script that emits non-standard or trimmed key names; loading a legacy/renamed checkpoint after a LoRA-conversion tool rewrote keys.","solutions":["Verify the file actually is an Anima (Cosmos DiT) LoRA; if it targets another architecture, it should be matched by a different config class — ensure the file name/type hints (lora_prefix, directory placement) route it correctly.","Inspect the state dict keys (python: safetensors.torch.load_file(...).keys()) and confirm they contain Anima-exclusive names like blocks.*.mlp, adaln_modulation, or cross_attn.*_proj with lora_down/lora_A suffixes.","If the LoRA is from a different trainer, re-export/convert it with the standard Kohya or diffusers PEFT key layout so the strict detectors match.","Check InvokeAI version — strict detectors were added to fix Anima/Wan cross-matching; update if you have an older or newer key-naming scheme mismatch."],"exampleFix":"// before: keys like 'lora_unet_cross_attn.q.lora_down.weight' (bare .q/.k/.v/.o => Wan-style)\n// after: convert to Anima/Cosmos names, e.g.\n// 'lora_unet_blocks_0_cross_attn.k_proj.lora_down.weight'\n// or diffusers form 'transformer.blocks.0.mlp.layer_0.lora_A.weight'","handlingStrategy":"validation","validationCode":"from safetensors.torch import load_file\nsd = load_file(path)  # or zip/torch load for .ckpt\nkeys = [k for k in sd.keys() if isinstance(k, str)]\nis_anima_lora = (\n    any(('mlp' in k or 'adaln_modulation' in k or k.rstrip().endswith(('_proj.lora_down.weight', '_proj.lora_A.weight'))) for k in keys)\n)\nif not is_anima_lora:\n    raise ValueError(f'{path} is not an Anima (Cosmos DiT) LoRA')","typeGuard":"def is_anima_lora_state_dict(keys: list[str]) -> bool:\n    return any(\n        ('mlp' in k or 'adaln_modulation' in k or '_proj' in k)\n        and (k.endswith(('lora_down.weight', 'lora_A.weight', 'lora_up.weight', 'lora_B.weight')))\n        for k in keys\n    )","tryCatchPattern":"from invokeai.backend.model_manager.errors import NotAMatchError\ntry:\n    config = install_model(path)\nexcept NotAMatchError as e:\n    logger.warning('Not an Anima LoRA: %s', e)\n    config = probe_with_next_config(path)  # fall through to Wan/FLUX/etc.","preventionTips":["Keep a key-listing snippet handy to inspect safetensors files before installing.","Only load Anima LoRAs trained with Kohya or diffusers PEFT layouts that preserve mlp/adaln_modulation/_proj names.","Keep InvokeAI updated — strict detectors evolve with new architectures.","Name LoRA files with their base model (e.g. anima_..., wan_...) to avoid misrouting expectations."],"tags":["model-manager","lora","model-detection","invokeai"],"backgroundTag":"model-format-not-matched","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}