{"record":{"id":"008f2368561bd986","repo":"invoke-ai/InvokeAI","slug":"lora-model-is-in-unsupported-flux-format","errorCode":null,"errorMessage":"LoRA model is in unsupported FLUX format","messagePattern":"LoRA model is in unsupported FLUX format","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/lora.py","lineNumber":167,"sourceCode":"                    model = lora_model_from_flux_onetrainer_bfl_state_dict(state_dict=state_dict)\n                elif is_state_dict_likely_in_flux_onetrainer_format(state_dict=state_dict):\n                    model = lora_model_from_flux_onetrainer_state_dict(state_dict=state_dict)\n                elif is_state_dict_likely_flux_control(state_dict=state_dict):\n                    model = lora_model_from_flux_control_state_dict(state_dict=state_dict)\n                elif is_state_dict_likely_in_flux_aitoolkit_format(state_dict=state_dict):\n                    model = lora_model_from_flux_aitoolkit_state_dict(state_dict=state_dict)\n                elif is_state_dict_likely_in_flux_xlabs_format(state_dict=state_dict):\n                    model = lora_model_from_flux_xlabs_state_dict(state_dict=state_dict)\n                elif is_state_dict_likely_in_flux_bfl_peft_format(state_dict=state_dict):\n                    if self._model_base == BaseModelType.Flux2:\n                        # FLUX.2 Klein uses Flux2Transformer2DModel (diffusers naming),\n                        # so we need to convert BFL keys to diffusers naming.\n                        model = lora_model_from_flux2_bfl_peft_state_dict(state_dict=state_dict, alpha=None)\n                    else:\n                        # FLUX.1 uses BFL Flux class, so BFL keys work directly.\n                        model = lora_model_from_flux_bfl_peft_state_dict(state_dict=state_dict, alpha=None)\n                else:\n                    raise ValueError(\"LoRA model is in unsupported FLUX format\")\n            else:\n                raise ValueError(f\"LoRA model is in unsupported FLUX format: {config.format}\")\n        elif self._model_base in [BaseModelType.StableDiffusion1, BaseModelType.StableDiffusion2]:\n            # Currently, we don't apply any conversions for SD1 and SD2 LoRA models.\n            model = lora_model_from_sd_state_dict(state_dict=state_dict)\n        elif self._model_base == BaseModelType.ZImage:\n            # Z-Image LoRAs use diffusers PEFT format with transformer and/or Qwen3 encoder layers.\n            # We set alpha=None to use rank as alpha (common default).\n            model = lora_model_from_z_image_state_dict(state_dict=state_dict, alpha=None)\n        elif self._model_base == BaseModelType.QwenImage:\n            model = lora_model_from_qwen_image_state_dict(state_dict=state_dict, alpha=None)\n        elif self._model_base == BaseModelType.Krea2:\n            # Krea-2 LoRAs use diffusers PEFT format targeting the Krea2 transformer (and optionally\n            # the Qwen3-VL text encoder). alpha=None → alpha=rank (common diffusers default).\n            model = lora_model_from_krea2_state_dict(state_dict=state_dict, alpha=None)\n        elif self._model_base == BaseModelType.Anima:\n            # Anima LoRAs use Kohya-style or diffusers PEFT format targeting Cosmos DiT blocks.\n            model = lora_model_from_anima_state_dict(state_dict=state_dict, alpha=None)","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/lora.py#L149-L185","documentation":"This ValueError is thrown when loading a FLUX-base LoRA whose state_dict does not match any supported FLUX key naming scheme (e.g. diffusers-style or BFL/PEFT keys), or when the model's recorded format field is not a supported FLUX LoRA format. The loader inspects key patterns to decide between diffusers and BFL conversion helpers (flux1 vs flux2); unrecognized keys/format fall through to this error.","triggerScenarios":"Loading a FLUX LoRA safetensors file whose keys use an unknown/legacy naming convention; a FLUX.2-style or other fork's LoRA that emits neither diffusers nor recognized BFL keys; config.format set to something unexpected for a FLUX LoRA; a truncated or hand-edited state dict.","commonSituations":"Downloading LoRAs from Civitai/Community sources trained with custom toolchains (e.g. older training scripts, ComfyUI-flavored exports) that use nonstandard keys; files renamed/converted with third-party scripts; using a LoRA trained for FLUX schnell/dev variants with exotic key layouts.","solutions":["Re-download the LoRA from its original source to rule out corruption or a bad conversion.","Convert the LoRA state dict to diffusers FLUX key naming with an official tool (e.g. ComfyUI's flux conversion scripts or diffusers conversion utilities) before installing.","Check config.format on the model record — it must be a supported FLUX LoRA format (e.g. LoraFormat.LyCORIS/Diffusers as accepted); reinstall the model to regenerate correct metadata.","Verify the LoRA was trained for FLUX.1 vs FLUX.2 and that your InvokeAI version supports that family; update InvokeAI if the format is newly released.","As a last resort, manually remap the state_dict keys to diffusers naming with a small conversion script."],"exampleFix":"// before (config points at a BFL/unknown-format file)\nconfig = ModelRecordBase.make_config(BaseModelType.Flux, ModelFormat.Lora, path='mystery_lora.safetensors')\n// after (convert to diffusers naming first, then install)\n# python convert script: remap keys, save as diffusers-format safetensors, then reinstall via model manager","handlingStrategy":"try-catch","validationCode":"from safetensors import safe_open\nwith safe_open(path, framework='pt', device='cpu') as f:\n    keys = list(f.keys())\nis_diffusers = any(k.startswith(('transformer.', 'lora_transformer.', 'diffusion_model.')) for k in keys)\nis_bfl = any('double_blocks' in k or 'single_blocks' in k for k in keys)\nif not (is_diffusers or is_bfl):\n    raise ValueError(f\"Unsupported FLUX LoRA key format, e.g. {keys[:3]}\")","typeGuard":"def is_supported_flux_lora_keys(keys: list[str]) -> bool:\n    return (any(k.startswith('lora_transformer.') or k.startswith('transformer.') for k in keys)\n            or any('double_blocks' in k or 'single_blocks' in k for k in keys))","tryCatchPattern":"try:\n    model = model_manager.load_model(lora_key, submodel_type=None)\nexcept ValueError as e:\n    if 'unsupported FLUX format' in str(e):\n        converted = convert_lora_keys_to_diffusers(lora_path)  # external conversion step\n        reinstall_model(converted)\n    else:\n        raise","preventionTips":["Prefer LoRAs explicitly labeled as diffusers-format for FLUX when downloading.","Inspect safetensors key names before installing an unknown-source FLUX LoRA.","Do not hand-edit or re-save safetensors files with ad-hoc scripts; use official conversion tools.","Check config.format after installation matches the actual file layout.","Keep InvokeAI updated so new FLUX LoRA formats (e.g. FLUX.2) are supported."],"tags":["python","valueerror","model-loader","invokeai","lora","flux","state-dict"],"backgroundTag":"unsupported-model-format","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}