{"record":{"id":"ff25738527deb153","repo":"invoke-ai/InvokeAI","slug":"lora-lora-key-already-applied-to-transformer-ff2573","errorCode":null,"errorMessage":"LoRA \"{lora_key}\" already applied to transformer.","messagePattern":"LoRA \"(.+?)\" already applied to transformer\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/flux2_dev_lora_loader.py","lineNumber":102,"sourceCode":"        title=\"Mistral Encoder\",\n        description=FieldDescriptions.mistral_encoder,\n        input=Input.Connection,\n    )\n\n    def invoke(self, context: InvocationContext) -> Flux2DevLoRALoaderOutput:\n        lora_key = self.lora.key\n        if not context.models.exists(lora_key):\n            raise ValueError(f\"Unknown lora: {lora_key}!\")\n\n        lora_config = context.models.get_config(lora_key)\n\n        # Reject variant-mismatched LoRAs regardless of which input they're wired to. A Klein\n        # LoRA on a dev transformer/encoder is guaranteed to shape-error during denoise.\n        _assert_dev_lora(context, lora_config)\n\n        # Check for duplicate keys.\n        if self.transformer and any(existing.lora.key == lora_key for existing in self.transformer.loras):\n            raise ValueError(f'LoRA \"{lora_key}\" already applied to transformer.')\n        if self.mistral_encoder and any(existing.lora.key == lora_key for existing in self.mistral_encoder.loras):\n            raise ValueError(f'LoRA \"{lora_key}\" already applied to Mistral encoder.')\n\n        output = Flux2DevLoRALoaderOutput()\n        if self.transformer is not None:\n            output.transformer = self.transformer.model_copy(deep=True)\n            output.transformer.loras.append(LoRAField(lora=self.lora, weight=self.weight))\n        if self.mistral_encoder is not None:\n            output.mistral_encoder = self.mistral_encoder.model_copy(deep=True)\n            output.mistral_encoder.loras.append(LoRAField(lora=self.lora, weight=self.weight))\n        return output\n\n\n@invocation(\n    \"flux2_dev_lora_collection_loader\",\n    title=\"Apply LoRA Collection - FLUX.2 [dev]\",\n    tags=[\"lora\", \"model\", \"flux\", \"flux2\", \"dev\"],\n    category=\"model\",","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/flux2_dev_lora_loader.py#L84-L120","documentation":"The dev LoRA loader collects applied LoRAs by key to prevent double-application. If the incoming lora_key already exists in self.transformer.loras, invoke() raises ValueError rather than stacking the same LoRA twice (which would double its effective weight or patch twice).","triggerScenarios":"Wiring two Flux2DevLoRALoaderInvocations in a chain where both load a LoRA with the same model key onto the transformer; looping a graph that re-applies the same LoRA each iteration.","commonSituations":"Duplicating a loader node without changing the selected LoRA; unintentionally connecting the same LoRA field into multiple loader nodes in one chain.","solutions":["Remove the duplicate LoRA loader node from the chain, keeping one instance with the desired weight","If you intended a stronger effect, increase the weight on the single loader instead of adding a second copy","Filter chain inputs by key before invoking: keep loras whose keys are unique"],"exampleFix":"# before\nx = Flux2DevLoRALoaderInvocation(lora=loraA, transformer=x).transformer\nx = Flux2DevLoRALoaderInvocation(lora=loraA, transformer=x).transformer  # duplicate\n# after\nx = Flux2DevLoRALoaderInvocation(lora=loraA, weight=1.2, transformer=x).transformer","handlingStrategy":"validation","validationCode":"key = loader.lora.key\nif any(existing.lora.key == key for existing in transformer.loras):\n    raise ValueError(f'{key} already applied to transformer')","typeGuard":null,"tryCatchPattern":"try:\n    out = loader.invoke(context)\nexcept ValueError as e:\n    if 'already applied to transformer' in str(e):\n        transformer = skip_this_loader(transformer)  # drop duplicate node\n    else:\n        raise","preventionTips":["Deduplicate LoRA keys when chaining loader nodes","Adjust weight on one loader rather than stacking duplicates","When copying loader nodes, immediately change the selected LoRA"],"tags":["lora","duplicate","validation"],"backgroundTag":"duplicate-lora-application","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}