invoke-ai/InvokeAI · error · ValueError

LoRA "{lora_key}" already applied to transformer.

Error message

LoRA "{lora_key}" already applied to transformer.

What it means

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).

Source

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

        title="Mistral Encoder",
        description=FieldDescriptions.mistral_encoder,
        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",

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Remove the duplicate LoRA loader node from the chain, keeping one instance with the desired weight
  2. If you intended a stronger effect, increase the weight on the single loader instead of adding a second copy
  3. Filter chain inputs by key before invoking: keep loras whose keys are unique

Example fix

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

Strategy: validation

Validate before calling

key = loader.lora.key
if any(existing.lora.key == key for existing in transformer.loras):
    raise ValueError(f'{key} already applied to transformer')

Try / catch

try:
    out = loader.invoke(context)
except ValueError as e:
    if 'already applied to transformer' in str(e):
        transformer = skip_this_loader(transformer)  # drop duplicate node
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: Duplicating a loader node without changing the selected LoRA; unintentionally connecting the same LoRA field into multiple loader nodes in one chain.

Related errors


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