invoke-ai/InvokeAI · error · ValueError

LLLite module '{m.lllite_name}' was trained for in_features=

Error message

LLLite module '{m.lllite_name}' was trained for in_features={m.in_dim}, but the target Linear has in_features={target.in_features}

What it means

LLLite (ControlNet-LLLite for Anima) modules are trained against a specific input dimension. Before binding each LLLite module to a target layer, apply_to() verifies that the resolved target nn.Linear's in_features matches the module's trained in_dim; a mismatch means the adapter cannot multiply against the target weights. The library throws ValueError to prevent silently applying an incompatible adapter.

Source

Thrown at invokeai/backend/anima/control_net_lllite.py:521

            m.cond_emb = cx

    def clear_cond_image(self) -> None:
        self.set_cond_image(None)

    def set_multiplier(self, multiplier: float) -> None:
        self.multiplier = multiplier
        for m in self.lllite_modules:
            m.multiplier = multiplier

    def apply_to(self, transformer: nn.Module) -> None:
        """Swap the forward of each target Linear in ``transformer``. Idempotent."""
        self.restore()
        for m in self.lllite_modules:
            target = self._resolve_target(transformer, m.lllite_name)
            if not isinstance(target, nn.Linear):
                raise TypeError(f"LLLite target for '{m.lllite_name}' is {type(target).__name__}, expected nn.Linear")
            if target.in_features != m.in_dim:
                raise ValueError(
                    f"LLLite module '{m.lllite_name}' was trained for in_features={m.in_dim}, but the "
                    f"target Linear has in_features={target.in_features}"
                )
            m.bind(target)

    def restore(self) -> None:
        """Undo :meth:`apply_to`. Safe to call when not applied.

        LIFO contract: each bind saves the forward that was CURRENT at bind
        time, so when multiple adapters are stacked on one transformer they
        must be restored in reverse apply order. Restoring an earlier adapter
        first would delete a later adapter's wrapper and re-pin the earlier
        one's saved forward.
        """
        for m in self.lllite_modules:
            m.unbind()

    @staticmethod

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Use a LLLite checkpoint trained for the exact base transformer you are loading (matching config/hidden size).
  2. Check the target layer width: print target.in_features and compare with the adapter's in_dim metadata to confirm which model each was built for.
  3. Verify model names/paths in the graph aren't mixing checkpoints from different model revisions.
  4. Re-train or regenerate the LLLite adapter against the current base model if you must use the new transformer.

Example fix

// before
lllite.apply_to(transformer_large)  # adapter trained for small model
// after
transformer = load_anima_transformer("small")  # matches lllite.in_dim
lllite.apply_to(transformer)
Defensive patterns

Strategy: validation

Validate before calling

target = transformer.blocks[idx].ff.net[0].proj
assert isinstance(target, torch.nn.Linear) and target.in_features == lllite.in_dim

Type guard

def is_compatible_lllite_target(m, t: torch.nn.Module) -> bool:
    return isinstance(t, torch.nn.Linear) and t.in_features == m.in_dim

Try / catch

try:
    lllite.apply_to(transformer)
except ValueError as e:
    if "in_features" in str(e):
        logger.error("LLLite/base model dimension mismatch: %s", e)
    raise

Prevention

When it happens

Trigger: Calling apply_to(transformer) when the transformer's resolved target layer for a module name (e.g. blocks[N].ff.net.0.proj) has an in_features different from the LLLite module's in_dim — typically because the base model checkpoint and the LLLite adapter were trained for different model sizes.

Common situations: Loading a LLLite ControlNet trained for one Anima variant and applying it to a differently-sized transformer (different hidden width); using an adapter checkpoint from an older/newer model revision; typos resolving to a different layer with a different width.

Related errors


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