{"record":{"id":"be9eb04cbc9714c0","repo":"invoke-ai/InvokeAI","slug":"lora-lora-key-already-applied-to-clip-encoder","errorCode":null,"errorMessage":"LoRA \"{lora_key}\" already applied to CLIP encoder.","messagePattern":"LoRA \"(.+?)\" already applied to CLIP encoder\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/flux_lora_loader.py","lineNumber":74,"sourceCode":"    )\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)\n            output.clip.loras.append(\n                LoRAField(","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/flux_lora_loader.py#L56-L92","documentation":"Same duplicate-guard as the transformer check, but for the CLIP text encoder component. The loader detects that the given LoRA key is already attached to self.clip.loras and raises ValueError before applying again. Double-applying a LoRA to CLIP would double the text-embedding delta.","triggerScenarios":"invoke() runs with self.clip set and any lora in self.clip.loras already has key == lora_key — same LoRA fed to the CLIP encoder path twice in one graph execution.","commonSituations":"Wired the same LoRA loader output into both a FLUX LoRA field and a CLIP LoRA field expecting separate applications; graphs built programmatically that append the CLIP-targeted loader twice.","solutions":["Remove the duplicate loader/edge targeting the CLIP encoder","Use a distinct LoRA model key if you actually intend a different LoRA on CLIP","Rebuild the graph so CLIP-side LoRA application happens exactly once","Check node connections in the InvokeAI canvas for accidental double-links"],"exampleFix":"// before\nclip_loader = FluxLoRALoader(lora=lora_key, weight=0.7)  # same lora_key used again downstream\n// after\nsingle_loader = FluxLoRALoader(lora=lora_key, weight=0.7)  # reuse its output instead of loading again","handlingStrategy":"validation","validationCode":"clip_keys = [l.lora.key for l in clip.loras] if clip else []\nassert lora_key not in clip_keys, f\"LoRA {lora_key} already on CLIP\"","typeGuard":"def clip_lora_free(clip, lora_key: str) -> bool:\n    return not clip or not any(l.lora.key == lora_key for l in clip.loras)","tryCatchPattern":"try:\n    output = loader.invoke(context)\nexcept ValueError as e:\n    if 'already applied to CLIP' in str(e):\n        output = None  # skip, already loaded on CLIP\n    else:\n        raise","preventionTips":["Check CLIP-side connections for double-linked LoRA nodes","Reuse an existing loader output instead of loading the same key again","Keep one loader per (lora, component) pair"],"tags":["lora","duplicate-model","clip","flux","invokeai"],"backgroundTag":"duplicate-lora-application","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}