{"record":{"id":"eabbbf08a3eac0c4","repo":"invoke-ai/InvokeAI","slug":"malformed-krea-2-lora-layer-layer-key-has-lor","errorCode":null,"errorMessage":"Malformed Krea-2 LoRA: layer '{layer_key}' has lora_A.weight but no matching lora_B.weight. The LoRA file is incomplete or corrupt.","messagePattern":"Malformed Krea-2 LoRA: layer '(.+?)' has lora_A\\.weight but no matching lora_B\\.weight\\. The LoRA file is incomplete or corrupt\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/patches/lora_conversions/krea2_lora_conversion_utils.py","lineNumber":320,"sourceCode":"        # the mixed-layout adapter explicitly instead.\n        if final_key in layers:\n            raise ValueError(\n                f\"Krea-2 LoRA has conflicting layers that normalize to the same target '{final_key}' \"\n                \"(e.g. both a 'transformer.' and a 'diffusion_model.' alias for one logical layer). \"\n                \"This mixed layout is unsupported - refusing to silently drop one of the layers.\"\n            )\n        layers[final_key] = any_lora_layer_from_state_dict(values)\n\n    return ModelPatchRaw(layers=layers)\n\n\ndef _get_lora_layer_values(\n    layer_key: str, layer_dict: dict[str, torch.Tensor], alpha: float | None\n) -> dict[str, torch.Tensor]:\n    \"\"\"Convert PEFT (lora_A/lora_B) layer values to internal (lora_down/lora_up) format.\"\"\"\n    if \"lora_A.weight\" in layer_dict:\n        if \"lora_B.weight\" not in layer_dict:\n            raise ValueError(\n                f\"Malformed Krea-2 LoRA: layer '{layer_key}' has lora_A.weight but no matching lora_B.weight. \"\n                \"The LoRA file is incomplete or corrupt.\"\n            )\n        values = {\n            \"lora_down.weight\": layer_dict[\"lora_A.weight\"],\n            \"lora_up.weight\": layer_dict[\"lora_B.weight\"],\n        }\n        if \"dora_scale\" in layer_dict:\n            values[\"dora_scale\"] = layer_dict[\"dora_scale\"]\n        if \"alpha\" in layer_dict:\n            values[\"alpha\"] = layer_dict[\"alpha\"]\n        if alpha is not None:\n            values[\"alpha\"] = torch.tensor(alpha)\n        return values\n    return layer_dict\n\n\n# Maps each recognized weight-key suffix to the canonical value-key used downstream. The PEFT/diffusers DoRA","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/patches/lora_conversions/krea2_lora_conversion_utils.py#L302-L338","documentation":"PEFT-format Krea-2 LoRA layers store the low-rank factorization as lora_A.weight plus lora_B.weight. This error means a layer has lora_A.weight but the required matching lora_B.weight is missing, so the pair cannot be converted to lora_down/lora_up format. The file is treated as incomplete or corrupt.","triggerScenarios":"lora_model_from_krea2_state_dict -> _get_lora_layer_values with a layer_dict containing 'lora_A.weight' but not 'lora_B.weight' for a given layer_key (e.g. a truncated download or a partially saved PEFT adapter).","commonSituations":"Interrupted downloads or incomplete checkpoint saves; PEFT adapters where only rank-A tensors were exported; manual slicing of state dicts that dropped lora_B tensors; mixed-format files where the B tensors use a different key spelling.","solutions":["Re-download or re-export the LoRA file completely and verify both lora_A.weight and lora_B.weight exist for every layer.","Check the file's keys and rename any misspelled lora_B tensors (e.g. 'lora_b.weight') to the expected 'lora_B.weight'.","If the source is a training run, finish saving the adapter (PEFT writes A and B together) and retry."],"exampleFix":"// before (corrupt layer)\n'transformer.blocks.0.attn.qkv.lora_A.weight': a\n// after (complete PEFT pair)\n'transformer.blocks.0.attn.qkv.lora_A.weight': a\n'transformer.blocks.0.attn.qkv.lora_B.weight': b","handlingStrategy":"validation","validationCode":"layer_keys = {k.rsplit('.', 2)[0] for k in state_dict if '.lora_A.weight' in k or '.lora_B.weight' in k}\nfor lk in layer_keys:\n    has_a = f'{lk}.lora_A.weight' in state_dict\n    has_b = f'{lk}.lora_B.weight' in state_dict\n    if has_a != has_b:\n        raise ValueError(f'incomplete PEFT pair at {lk}')","typeGuard":"def is_complete_peft_layer(layer_dict: dict[str, object]) -> bool:\n    return ('lora_A.weight' in layer_dict) == ('lora_B.weight' in layer_dict)","tryCatchPattern":"try:\n    model = lora_model_from_krea2_state_dict(state_dict)\nexcept ValueError as e:\n    if 'lora_A.weight but no matching lora_B.weight' in str(e):\n        logger.error('Corrupt/incomplete LoRA file: %s', e)\n        # re-download or repair the file before retrying\n    else:\n        raise","preventionTips":["Verify checksums/file sizes after downloading LoRA files.","Check both lora_A.weight and lora_B.weight exist for every PEFT layer before loading.","Never hand-trim state dicts without keeping A/B pairs together."],"tags":["lora","peft","corrupt-file","krea2"],"backgroundTag":"incomplete-checkpoint-file","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}