invoke-ai/InvokeAI · error · ValueError

LoRA "{lora_key}" already applied to Mistral encoder.

Error message

LoRA "{lora_key}" already applied to Mistral encoder.

What it means

Same duplicate-key guard as the transformer, but checked against self.mistral_encoder.loras. The dev loader can attach LoRAs to both the transformer and the Mistral text encoder; loading a LoRA with an already-present key into the encoder raises ValueError.

Source

Thrown at invokeai/app/invocations/flux2_dev_lora_loader.py:104

        input=Input.Connection,
    )

    def invoke(self, context: InvocationContext) -> Flux2DevLoRALoaderOutput:
        lora_key = self.lora.key
        if not context.models.exists(lora_key):
            raise ValueError(f"Unknown lora: {lora_key}!")

        lora_config = context.models.get_config(lora_key)

        # Reject variant-mismatched LoRAs regardless of which input they're wired to. A Klein
        # LoRA on a dev transformer/encoder is guaranteed to shape-error during denoise.
        _assert_dev_lora(context, lora_config)

        # Check for duplicate keys.
        if self.transformer and any(existing.lora.key == lora_key for existing in self.transformer.loras):
            raise ValueError(f'LoRA "{lora_key}" already applied to transformer.')
        if self.mistral_encoder and any(existing.lora.key == lora_key for existing in self.mistral_encoder.loras):
            raise ValueError(f'LoRA "{lora_key}" already applied to Mistral encoder.')

        output = Flux2DevLoRALoaderOutput()
        if self.transformer is not None:
            output.transformer = self.transformer.model_copy(deep=True)
            output.transformer.loras.append(LoRAField(lora=self.lora, weight=self.weight))
        if self.mistral_encoder is not None:
            output.mistral_encoder = self.mistral_encoder.model_copy(deep=True)
            output.mistral_encoder.loras.append(LoRAField(lora=self.lora, weight=self.weight))
        return output


@invocation(
    "flux2_dev_lora_collection_loader",
    title="Apply LoRA Collection - FLUX.2 [dev]",
    tags=["lora", "model", "flux", "flux2", "dev"],
    category="model",
    version="1.0.0",
    classification=Classification.Prototype,

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Remove the duplicate encoder LoRA loader node from the chain
  2. Increase the weight on the existing single encoder LoRA instead of adding another
  3. Deduplicate by key before building the chain: skip any lora whose key already exists in mistral_encoder.loras

Example fix

# before
enc = Flux2DevLoRALoaderInvocation(lora=loraA, mistral_encoder=enc).mistral_encoder
enc = Flux2DevLoRALoaderInvocation(lora=loraA, mistral_encoder=enc).mistral_encoder  # duplicate
# after
enc = Flux2DevLoRALoaderInvocation(lora=loraA, weight=1.2, mistral_encoder=enc).mistral_encoder
Defensive patterns

Strategy: validation

Validate before calling

key = loader.lora.key
if loader.mistral_encoder and any(e.lora.key == key for e in loader.mistral_encoder.loras):
    raise ValueError(f'{key} already applied to Mistral encoder')

Try / catch

try:
    out = loader.invoke(context)
except ValueError as e:
    if 'already applied to Mistral encoder' in str(e):
        encoder = skip_this_loader(loader.mistral_encoder)
    else:
        raise

Prevention

When it happens

Trigger: Chaining Flux2DevLoRALoaderInvocations where a LoRA already applied to the Mistral encoder is applied to the encoder again; same key fed to the mistral_encoder input twice.

Common situations: Copying an encoder loader node and leaving the same LoRA selected; looped graphs re-applying encoder LoRAs.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/5f6b0eaaa2c12cbc. Report an issue: GitHub.