{"record":{"id":"d855c8f6f4ea073e","repo":"invoke-ai/InvokeAI","slug":"lora-lora-key-already-applied-to-transformer-d855c8","errorCode":null,"errorMessage":"LoRA \"{lora_key}\" already applied to transformer.","messagePattern":"LoRA \"(.+?)\" already applied to transformer\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/flux_lora_loader.py","lineNumber":72,"sourceCode":"        description=FieldDescriptions.clip,\n        input=Input.Connection,\n    )\n    t5_encoder: T5EncoderField | None = InputField(\n        default=None,\n        title=\"T5 Encoder\",\n        description=FieldDescriptions.t5_encoder,\n        input=Input.Connection,\n    )\n\n    def invoke(self, context: InvocationContext) -> FluxLoRALoaderOutput:\n        lora_key = self.lora.key\n\n        if not context.models.exists(lora_key):\n            raise ValueError(f\"Unknown lora: {lora_key}!\")\n\n        # Check for existing LoRAs with the same key.\n        if self.transformer and any(lora.lora.key == lora_key for lora in self.transformer.loras):\n            raise ValueError(f'LoRA \"{lora_key}\" already applied to transformer.')\n        if self.clip and any(lora.lora.key == lora_key for lora in self.clip.loras):\n            raise ValueError(f'LoRA \"{lora_key}\" already applied to CLIP encoder.')\n        if self.t5_encoder and any(lora.lora.key == lora_key for lora in self.t5_encoder.loras):\n            raise ValueError(f'LoRA \"{lora_key}\" already applied to T5 encoder.')\n\n        output = FluxLoRALoaderOutput()\n\n        # Attach LoRA layers to the models.\n        if self.transformer is not None:\n            output.transformer = self.transformer.model_copy(deep=True)\n            output.transformer.loras.append(\n                LoRAField(\n                    lora=self.lora,\n                    weight=self.weight,\n                )\n            )\n        if self.clip is not None:\n            output.clip = self.clip.model_copy(deep=True)","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/flux_lora_loader.py#L54-L90","documentation":"The FLUX LoRA loader invocation refuses to apply a LoRA whose model key is already present on the target model. InvokeAI tracks loaded LoRAs per-component (transformer, CLIP, T5) and raises ValueError to prevent double-applying weights, which would distort generation. It is a guard against duplicate LoRA application, not a load failure.","triggerScenarios":"Calling FluxLoRALoader.invoke (i.e., running a graph containing this node) when self.transformer is set and any entry in self.transformer.loras already has lora.key == lora_key — typically because the same FLUX LoRA node output is wired into the graph twice or the loader runs in a loop over the same key.","commonSituations":"Duplicating a LoRA loader node in the workflow canvas; a linear graph that applies the same LoRA at multiple strengths; programmatic graph construction that appends the same LoRA key twice.","solutions":["Remove the duplicate LoRA loader node or the duplicate edge so the LoRA key is applied only once","Ensure different LoRA keys are used when stacking LoRAs (each LoRA model must be a distinct model record)","If you intentionally want re-application, clear/replace the transformer between loads instead of reusing the loaded model","Update any custom graph-building code to deduplicate LoRA keys before invoking"],"exampleFix":"// before: two FluxLoRALoader nodes both referencing lora key 'my_flux_lora'\n// after: single FluxLoRALoader node; set weight as needed\nloader = FluxLoRALoader(lora=ModelIdentifierField(key='my_flux_lora'), weight=0.8)","handlingStrategy":"validation","validationCode":"keys = [l.lora.key for l in transformer.loras]\nassert lora_key not in keys, f\"LoRA {lora_key} already applied\"\nassert context.models.exists(lora_key), f\"Unknown lora: {lora_key}\"","typeGuard":"def is_not_yet_applied(transformer, lora_key: str) -> bool:\n    return not transformer or not any(l.lora.key == lora_key for l in transformer.loras)","tryCatchPattern":"try:\n    output = loader.invoke(context)\nexcept ValueError as e:\n    if 'already applied' in str(e):\n        output = None  # treat as already-loaded, skip\n    else:\n        raise","preventionTips":["Never wire the same LoRA loader node twice into one graph","Deduplicate LoRA keys in programmatic graph builders","Give each LoRA model a unique key in the Model Manager"],"tags":["lora","duplicate-model","flux","invokeai"],"backgroundTag":"duplicate-lora-application","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}