{"record":{"id":"f929641a5db64d60","repo":"invoke-ai/InvokeAI","slug":"lora-lora-key-already-applied-to-transformer-f92964","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/z_image_lora_loader.py","lineNumber":65,"sourceCode":"        input=Input.Connection,\n        title=\"Z-Image Transformer\",\n    )\n    qwen3_encoder: Qwen3EncoderField | None = InputField(\n        default=None,\n        title=\"Qwen3 Encoder\",\n        description=FieldDescriptions.qwen3_encoder,\n        input=Input.Connection,\n    )\n\n    def invoke(self, context: InvocationContext) -> ZImageLoRALoaderOutput:\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.qwen3_encoder and any(lora.lora.key == lora_key for lora in self.qwen3_encoder.loras):\n            raise ValueError(f'LoRA \"{lora_key}\" already applied to Qwen3 encoder.')\n\n        # Warn on variant mismatch between LoRA and transformer.\n        lora_config = context.models.get_config(lora_key)\n        lora_variant = getattr(lora_config, \"variant\", None)\n        if lora_variant and self.transformer is not None:\n            transformer_config = context.models.get_config(self.transformer.transformer.key)\n            transformer_variant = getattr(transformer_config, \"variant\", None)\n            if transformer_variant and lora_variant != transformer_variant:\n                context.logger.warning(\n                    f\"LoRA variant mismatch: LoRA '{lora_config.name}' is for {lora_variant.value} \"\n                    f\"but transformer is {transformer_variant.value}. This may cause unexpected results.\"\n                )\n\n        output = ZImageLoRALoaderOutput()\n\n        # Attach LoRA layers to the models.","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/z_image_lora_loader.py#L47-L83","documentation":"The loader refuses to apply the same LoRA twice to the transformer input: if any entry in self.transformer.loras already has lora.key equal to the requested lora_key, a ValueError is raised. Duplicate LoRA application would double its weight/scale and corrupt the model, so it is treated as a graph-construction error rather than a warning.","triggerScenarios":"Calling ZImageLoRALoader where self.lora.key matches one of the LoRA entries already attached to the ZImageTransformerField passed as self.transformer (e.g. chaining two loader nodes with the same LoRA).","commonSituations":"Wiring multiple Z-Image LoRA loader nodes in series where the same LoRA is selected twice; duplicating nodes in the workflow editor without changing the LoRA; programmatic graph building appending the same LoRA id repeatedly.","solutions":["Remove the duplicate LoRA from one of the chained loader nodes (or from the transformer's existing loras list).","If you want a stronger effect, keep a single LoRA node and raise its weight instead of stacking duplicates.","In programmatic graphs, deduplicate by lora.key before appending to transformer.loras."],"exampleFix":"// before\nloader2.lora = same_key  # already in loader1.transformer.loras\n// after\nloader2.lora = different_lora_key  # or remove loader2 from the chain","handlingStrategy":"validation","validationCode":"existing = {l.lora.key for l in loader.transformer.loras} if loader.transformer else set()\nif loader.lora.key in existing:\n    raise ValueError(f\"LoRA {loader.lora.key} would be applied twice to the transformer\")","typeGuard":null,"tryCatchPattern":"try:\n    out = z_image_lora_loader.invoke(context)\nexcept ValueError as e:\n    if \"already applied to transformer\" in str(e):\n        context.logger.error(f\"{e} - remove the duplicate loader node or raise the weight instead.\")\n    else:\n        raise","preventionTips":["Use one loader node per unique LoRA key in a chain.","When duplicating nodes in the editor, change the LoRA selection immediately.","Deduplicate by key when building loras lists programmatically."],"tags":["lora","duplicate","z-image","graph"],"backgroundTag":"duplicate-lora-application","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}