{"record":{"id":"e3c7b7ee9a78b963","repo":"invoke-ai/InvokeAI","slug":"model-does-not-look-like-a-krea-2-lora","errorCode":null,"errorMessage":"model does not look like a Krea-2 LoRA","messagePattern":"model does not look like a Krea-2 LoRA","errorType":"exception","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/lora.py","lineNumber":1016,"sourceCode":"        \"\"\"Krea-2 LoRAs have keys like transformer.text_fusion.* / transformer.transformer_blocks.* with\n        a lora_A/lora_B (or lora_down/lora_up) suffix. The text-fusion stage is unique to Krea-2.\"\"\"\n        state_dict = mod.load_state_dict()\n        # Require a *complete* lora_A/B (or lora_down/up) pair, not merely any lora/dora suffix: a file with\n        # only ``dora_scale`` and no A/B weights would pass a suffix check but fail later on missing weights.\n        if not (_has_krea2_lora_keys(state_dict) and _has_complete_lora_pair(state_dict)):\n            raise NotAMatchError(\n                \"model does not match Krea-2 LoRA heuristics (no complete lora_A/B or lora_down/up pair)\"\n            )\n        # Reject a file with an orphaned LoRA half (a valid layer plus a dangling lora_A/B/down/up); it\n        # would install here but fail later during LoRA conversion.\n        if not _lora_weight_keys_are_all_paired(state_dict):\n            raise NotAMatchError(\"Krea-2 LoRA has an incomplete lora_A/B (or lora_down/up) weight pair\")\n\n    @classmethod\n    def _get_base_or_raise(cls, mod: ModelOnDisk) -> BaseModelType:\n        if _has_krea2_lora_keys(mod.load_state_dict()):\n            return BaseModelType.Krea2\n        raise NotAMatchError(\"model does not look like a Krea-2 LoRA\")\n\n\nclass LoRA_LyCORIS_Anima_Config(LoRA_LyCORIS_Config_Base, Config_Base):\n    \"\"\"Model config for Anima LoRA models in LyCORIS format.\"\"\"\n\n    base: Literal[BaseModelType.Anima] = Field(default=BaseModelType.Anima)\n\n    @classmethod\n    def _validate_looks_like_lora(cls, mod: ModelOnDisk) -> None:\n        \"\"\"Anima LoRAs use Kohya-style keys targeting Cosmos DiT blocks.\n\n        Anima LoRAs have keys like:\n        - lora_unet_blocks_0_cross_attn_k_proj.lora_down.weight (Kohya format)\n        - diffusion_model.blocks.0.cross_attn.k_proj.lora_A.weight (diffusers PEFT format)\n        - transformer.blocks.0.mlp.layer_0.lora_A.weight (Anima-only MLP layer)\n\n        Uses the **strict** Cosmos-DiT detectors, which require an\n        Anima-exclusive subcomponent name (``mlp``, ``adaln_modulation``, or","sourceCodeStart":998,"sourceCodeEnd":1034,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/lora.py#L998-L1034","documentation":"The Krea-2 LoRA config's _get_base_or_raise returns BaseModelType.Krea2 only if _has_krea2_lora_keys finds Krea-2's distinctive modules in the state dict (text_fusion / time_mod_proj in diffusers naming, or the equivalent native/ComfyUI naming). If none of those key patterns match, it raises NotAMatchError with this message during base-model detection.","triggerScenarios":"Auto-probing a LoRA that has no transformer.text_fusion.*/transformer.transformer_blocks.* (or native-named equivalents) keys — i.e. any LoRA trained for another architecture that reaches the Krea-2 config class during format detection.","commonSituations":"Installing a Qwen/Flux/SDXL LoRA and expecting Krea-2; a Krea-2 LoRA exported with a key-naming scheme not yet covered by the installed InvokeAI version's heuristic; file renamed with 'krea' in the filename but weights actually target another base.","solutions":["Dump the state-dict keys (safetensors.safe_open -> keys()) and confirm which architecture the prefixes actually target.","Install the LoRA under the correct base-model config (let another config class claim it, or select the type manually).","If it really is a Krea-2 LoRA with unusual naming, update InvokeAI — the _has_krea2_lora_keys pattern list is expanded in newer releases.","Rename/wrap the export to use the standard diffusers naming (transformer.text_fusion.*, transformer.transformer_blocks.*) so the heuristic matches."],"exampleFix":"// before: relies on filename, probe rejects it\ninstaller.install(path=\"my_krea_style_lora.safetensors\")  # NotAMatchError\n// after: check actual key prefixes and pick the right config\nfrom safetensors import safe_open\nwith safe_open(\"my_krea_style_lora.safetensors\", framework=\"pt\") as f:\n    ks = list(f.keys())\nis_krea2 = any(\"text_fusion\" in k or \"time_mod_proj\" in k for k in ks)\ninstaller.install(path=\"my_krea_style_lora.safetensors\",\n                 base=\"krea2\" if is_krea2 else detect_base_from_keys(ks))","handlingStrategy":"validation","validationCode":"from safetensors import safe_open\n\ndef looks_like_krea2_lora(path):\n    with safe_open(path, framework=\"pt\") as f:\n        ks = list(f.keys())\n    return any(\"text_fusion\" in k or \"time_mod_proj\" in k for k in ks)\n\nif not looks_like_krea2_lora(\"model.safetensors\"):\n    print(\"not a Krea-2 LoRA; install under the correct base or update InvokeAI\")","typeGuard":"def is_krea2_lora_state_dict(keys: list[str]) -> bool:\n    return any(\"text_fusion\" in k or \"time_mod_proj\" in k for k in keys)","tryCatchPattern":"try:\n    installer.install(path=\"model.safetensors\")\nexcept NotAMatchError as e:\n    if \"does not look like a Krea-2 LoRA\" in str(e):\n        base = detect_base_from_keys(list_keys(\"model.safetensors\"))\n        installer.install(path=\"model.safetensors\", base=base)\n    else:\n        raise","preventionTips":["Trust key prefixes over filenames; a 'krea' in the filename means nothing to the probe.","Pre-flight keys with safetensors.safe_open and route to the matching base config yourself.","Keep InvokeAI updated so newly packaged Krea-2 exports are recognized.","Prefer config classes with an explicit base/type argument when auto-detection is unreliable."],"tags":["invokeai","model-manager","lora","krea2","not-a-match","model-install"],"backgroundTag":"lora-not-a-match","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}