{"record":{"id":"1edba92ca38a83b9","repo":"invoke-ai/InvokeAI","slug":"lllite-module-m-lllite-name-was-trained-for-in","errorCode":null,"errorMessage":"LLLite module '{m.lllite_name}' was trained for in_features={m.in_dim}, but the target Linear has in_features={target.in_features}","messagePattern":"LLLite module '(.+?)' was trained for in_features=(.+?), but the target Linear has in_features=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/anima/control_net_lllite.py","lineNumber":521,"sourceCode":"            m.cond_emb = cx\n\n    def clear_cond_image(self) -> None:\n        self.set_cond_image(None)\n\n    def set_multiplier(self, multiplier: float) -> None:\n        self.multiplier = multiplier\n        for m in self.lllite_modules:\n            m.multiplier = multiplier\n\n    def apply_to(self, transformer: nn.Module) -> None:\n        \"\"\"Swap the forward of each target Linear in ``transformer``. Idempotent.\"\"\"\n        self.restore()\n        for m in self.lllite_modules:\n            target = self._resolve_target(transformer, m.lllite_name)\n            if not isinstance(target, nn.Linear):\n                raise TypeError(f\"LLLite target for '{m.lllite_name}' is {type(target).__name__}, expected nn.Linear\")\n            if target.in_features != m.in_dim:\n                raise ValueError(\n                    f\"LLLite module '{m.lllite_name}' was trained for in_features={m.in_dim}, but the \"\n                    f\"target Linear has in_features={target.in_features}\"\n                )\n            m.bind(target)\n\n    def restore(self) -> None:\n        \"\"\"Undo :meth:`apply_to`. Safe to call when not applied.\n\n        LIFO contract: each bind saves the forward that was CURRENT at bind\n        time, so when multiple adapters are stacked on one transformer they\n        must be restored in reverse apply order. Restoring an earlier adapter\n        first would delete a later adapter's wrapper and re-pin the earlier\n        one's saved forward.\n        \"\"\"\n        for m in self.lllite_modules:\n            m.unbind()\n\n    @staticmethod","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/anima/control_net_lllite.py#L503-L539","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use a LLLite checkpoint trained for the exact base transformer you are loading (matching config/hidden size).","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.","Verify model names/paths in the graph aren't mixing checkpoints from different model revisions.","Re-train or regenerate the LLLite adapter against the current base model if you must use the new transformer."],"exampleFix":"// before\nlllite.apply_to(transformer_large)  # adapter trained for small model\n// after\ntransformer = load_anima_transformer(\"small\")  # matches lllite.in_dim\nlllite.apply_to(transformer)","handlingStrategy":"validation","validationCode":"target = transformer.blocks[idx].ff.net[0].proj\nassert isinstance(target, torch.nn.Linear) and target.in_features == lllite.in_dim","typeGuard":"def is_compatible_lllite_target(m, t: torch.nn.Module) -> bool:\n    return isinstance(t, torch.nn.Linear) and t.in_features == m.in_dim","tryCatchPattern":"try:\n    lllite.apply_to(transformer)\nexcept ValueError as e:\n    if \"in_features\" in str(e):\n        logger.error(\"LLLite/base model dimension mismatch: %s\", e)\n    raise","preventionTips":["Store the base model id/hash alongside the LLLite checkpoint and assert equality before apply_to.","Check target.in_features against adapter metadata at load time.","Never mix adapter checkpoints across model revisions."],"tags":["pytorch","shape-mismatch","controlnet"],"backgroundTag":"shape-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}