{"record":{"id":"23cfac7671c48e35","repo":"invoke-ai/InvokeAI","slug":"unsupported-lora-format-state-dict-keys","errorCode":null,"errorMessage":"Unsupported lora format: {state_dict.keys()}","messagePattern":"Unsupported lora format: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/patches/layers/utils.py","lineNumber":35,"sourceCode":"    # https://github.com/KohakuBlueleaf/LyCORIS/tree/8ad8000efb79e2b879054da8c9356e6143591bad/lycoris/modules\n    if \"dora_scale\" in state_dict:\n        return DoRALayer.from_state_dict_values(state_dict)\n    elif \"lora_up.weight\" in state_dict:\n        # LoRA a.k.a LoCon\n        return LoRALayer.from_state_dict_values(state_dict)\n    elif \"hada_w1_a\" in state_dict:\n        return LoHALayer.from_state_dict_values(state_dict)\n    elif \"lokr_w1\" in state_dict or \"lokr_w1_a\" in state_dict:\n        return LoKRLayer.from_state_dict_values(state_dict)\n    elif \"diff\" in state_dict:\n        # Full a.k.a Diff\n        return FullLayer.from_state_dict_values(state_dict)\n    elif \"on_input\" in state_dict:\n        return IA3Layer.from_state_dict_values(state_dict)\n    elif \"w_norm\" in state_dict:\n        return NormLayer.from_state_dict_values(state_dict)\n    else:\n        raise ValueError(f\"Unsupported lora format: {state_dict.keys()}\")\n","sourceCodeStart":17,"sourceCodeEnd":36,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/patches/layers/utils.py#L17-L36","documentation":"any_lora_layer_from_state_dict sniffs a state dict's keys to decide which LoRA layer class to build (LoRALayer, IA3Layer, NormLayer, FullLayer). If none of the known key signatures (e.g. 'lora_down.weight'/'lora_up.weight', 'on_input', 'w_norm') are present, it raises ValueError naming the actual keys found. This means the per-layer state dict is not in any LoRA format InvokeAI recognizes.","triggerScenarios":"Calling any_lora_layer_from_state_dict (directly or via lora_model_from_flux_* converters or _make_layer_patch) with a per-layer dict whose keys match no known pattern - e.g. missing 'lora_down.weight'/'lora_A.weight' prefixes, or an arbitrary dict passed in.","commonSituations":"Loading a LoRA trained/saved in an unsupported format or by a tool InvokeAI doesn't convert (wrong exporter, PEFT vs Kohya key naming mismatch), or hand-assembled state dicts with typos in key names.","solutions":["Inspect the printed keys in the message and compare them to the recognized signatures in invokeai/backend/patches/layers/utils.py; rename or convert keys to a supported format.","Use the correct converter function for the LoRA's source format (flux_control, flux_diffusers, flux_kohya, flux_onetrainer, flux_xlabs) instead of feeding raw keys.","Re-export the LoRA from the training tool in a standard (diffusers/PEFT or Kohya) format."],"exampleFix":"// before\nlayer = any_lora_layer_from_state_dict({\"down.weight\": w, \"up.weight\": u})  # ValueError\n// after\nlayer = any_lora_layer_from_state_dict({\"lora_down.weight\": w, \"lora_up.weight\": u})","handlingStrategy":"validation","validationCode":"KNOWN = {\"lora_down.weight\", \"lora_A.weight\", \"on_input\", \"w_norm\"}\nif not (set(layer_sd) & KNOWN):\n    raise ValueError(f\"pre-check: layer not a supported LoRA layer: {sorted(layer_sd)}\")","typeGuard":"def is_supported_lora_layer(sd: dict) -> bool:\n    keys = set(sd)\n    return bool(keys & {\"lora_down.weight\", \"lora_A.weight\", \"on_input\", \"w_norm\"})","tryCatchPattern":"try:\n    layer = any_lora_layer_from_state_dict(sd)\nexcept ValueError as e:\n    logger.error(\"Unsupported LoRA layer keys: %s\", e)\n    layer = None","preventionTips":["Always convert third-party LoRAs through the matching flux_*_lora_conversion_utils before applying patches.","Log state-dict keys on failure to compare against recognized signatures.","Pin InvokeAI version known to support the trainer format you use."],"tags":["lora","state-dict","key-format","valueerror"],"backgroundTag":"unsupported-lora-format","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}