{"record":{"id":"8b5449f4cd3564eb","repo":"invoke-ai/InvokeAI","slug":"lora-lora-key-already-applied-to-qwen3-encoder","errorCode":null,"errorMessage":"LoRA \"{lora_key}\" already applied to Qwen3 encoder.","messagePattern":"LoRA \"(.+?)\" already applied to Qwen3 encoder\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/anima_lora_loader.py","lineNumber":68,"sourceCode":"        title=\"Anima 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) -> AnimaLoRALoaderOutput:\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        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        output = AnimaLoRALoaderOutput()\n\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.qwen3_encoder is not None:\n            output.qwen3_encoder = self.qwen3_encoder.model_copy(deep=True)\n            output.qwen3_encoder.loras.append(\n                LoRAField(\n                    lora=self.lora,\n                    weight=self.weight,\n                )","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/anima_lora_loader.py#L50-L86","documentation":"The Anima LoRA loader also guards the Qwen3 text encoder against double application. It scans self.qwen3_encoder.loras and raises if a LoRA with the same key is already present. Duplicate patches on the encoder would double the LoRA's influence on text embeddings.","triggerScenarios":"Invoking AnimaLoRALoader when the qwen3_encoder sub-model's loras list already contains an entry with lora.key equal to self.lora.key — typically from invoking the loader twice on the same encoder state.","commonSituations":"Chaining two LoRA loader invocations that both include the same LoRA; workflows where the encoder output is looped back through the loader; duplicated nodes in an imported workflow.","solutions":["Remove the duplicate LoRA entry/connection targeting the Qwen3 encoder.","Ensure each unique LoRA key appears in only one loader invocation per graph run.","If accumulation is intended, skip loading when the key is already present instead of invoking the loader again."],"exampleFix":"// before\nenc_loader = AnimaLoRALoader(qwen3_encoder=prev_enc, lora=my_lora)  # key already in prev_enc.loras\n// after\nif my_lora.key not in [l.lora.key for l in prev_enc.loras]:\n    enc_loader = AnimaLoRALoader(qwen3_encoder=prev_enc, lora=my_lora)\nelse:\n    qwen3_encoder = prev_enc  # already applied","handlingStrategy":"validation","validationCode":"existing = {l.lora.key for l in qwen3_encoder.loras}\nif lora.key in existing:\n    raise ValueError(f'LoRA \"{lora.key}\" already applied to Qwen3 encoder.')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deduplicate LoRA selectors by key before wiring them into the encoder loader.","Feed loader outputs forward through the graph rather than re-invoking loaders on the same state.","When importing workflows, scan for repeated LoRA keys across loader nodes."],"tags":["lora","duplicate","qwen3","invokeai"],"backgroundTag":"duplicate-resource-application","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}