{"record":{"id":"b969594e91200998","repo":"invoke-ai/InvokeAI","slug":"lllite-module-name-is-missing-key-down-key","errorCode":null,"errorMessage":"LLLite module '{name}' is missing key '{down_key}'","messagePattern":"LLLite module '(.+?)' is missing key '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/anima/control_net_lllite.py","lineNumber":446,"sourceCode":"        module_names: set[str] = set()\n        for key in state_dict:\n            head, dot, _tail = key.partition(\".\")\n            if dot and MODULE_NAME_PATTERN.match(head):\n                module_names.add(head)\n        if not module_names:\n            raise ValueError(\"State dict contains no LLLite modules (no 'lllite_dit_blocks_*' keys).\")\n\n        def sort_key(name: str) -> tuple[int, int]:\n            match = MODULE_NAME_PATTERN.match(name)\n            assert match is not None\n            return int(match.group(1)), _SUFFIX_ORDER.index(match.group(2))\n\n        sorted_names = sorted(module_names, key=sort_key)\n        module_specs: list[tuple[str, int]] = []\n        for name in sorted_names:\n            down_key = f\"{name}.down.weight\"\n            if down_key not in state_dict:\n                raise ValueError(f\"LLLite module '{name}' is missing key '{down_key}'\")\n            module_specs.append((name, state_dict[down_key].shape[1]))\n\n        conv1_weight = state_dict[f\"{_SAVED_COND_PREFIX}conv1.weight\"]\n        conv3_weight = state_dict[f\"{_SAVED_COND_PREFIX}conv3.weight\"]\n        proj_weight = state_dict[f\"{_SAVED_COND_PREFIX}proj.weight\"]\n        resblock_indices = {\n            m.group(1) for m in (re.match(rf\"^{_SAVED_COND_PREFIX}resblocks\\.(\\d+)\\.\", k) for k in state_dict) if m\n        }\n        has_aspp_keys = any(k.startswith(f\"{_SAVED_COND_PREFIX}aspp.\") for k in state_dict)\n\n        use_aspp = _meta_bool(meta, \"lllite.use_aspp\", has_aspp_keys)\n        aspp_dilations_meta = meta.get(\"lllite.aspp_dilations\")\n        if use_aspp and aspp_dilations_meta:\n            aspp_dilations = tuple(int(d) for d in aspp_dilations_meta.split(\",\") if d.strip())\n        else:\n            aspp_dilations = ASPP_DEFAULT_DILATIONS\n\n        model = cls(","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/anima/control_net_lllite.py#L428-L464","documentation":"Each LLLite module in the v2 format must provide '<name>.down.weight', from which the input dimension (in_dim) is derived. from_state_dict raises ValueError when a discovered module name lacks this key, meaning the checkpoint is incomplete or the keys were renamed inconsistently.","triggerScenarios":"State dict contains e.g. 'lllite_dit_blocks_0_up.weight' but not 'lllite_dit_blocks_0_down.weight' — due to partial saves, manual key edits, or mixed-format exports.","commonSituations":"Interrupted training saves, checkpoints pruned or converted by third-party scripts that dropped keys, or hand-merged safetensors files.","solutions":["Verify the key exists: assert f\"{name}.down.weight\" in sd for every module name.","Re-export or re-save the checkpoint with the full training script.","Restore missing keys from an earlier complete checkpoint.","If intentionally pruning modules, remove ALL keys for that module name so it isn't discovered."],"exampleFix":"# before\nnames = discover_names(sd)\nspecs = [(n, sd[f\"{n}.up.weight\"].shape[1]) for n in names]  # wrong key\n# after\nfor n in names:\n    assert f\"{n}.down.weight\" in sd, f\"missing {n}.down.weight\"\nspecs = [(n, sd[f\"{n}.down.weight\"].shape[1]) for n in names]","handlingStrategy":"validation","validationCode":"def validate_lllite_state_dict(state_dict: dict) -> None:\n    names = {\n        k.partition(\".\")[0]\n        for k in state_dict\n        if \".\" in k and k.partition(\".\")[0].startswith(\"lllite_dit_blocks_\")\n    }\n    missing = [n for n in sorted(names) if f\"{n}.down.weight\" not in state_dict]\n    if missing:\n        raise ValueError(f\"modules missing '{'{}.down.weight'}' key: {missing}\")","typeGuard":"def module_is_complete(name: str, sd: dict) -> bool:\n    return f\"{name}.down.weight\" in sd","tryCatchPattern":"try:\n    cnet = ControlNetLLLiteDiT.from_state_dict(sd, metadata)\nexcept ValueError as e:\n    if \"is missing key\" in str(e):\n        raise ValueError(f\"checkpoint is incomplete/corrupt: {e}; re-download or re-export\") from e\n    raise","preventionTips":["Never hand-prune individual keys from a LLLite checkpoint; drop whole modules instead.","Verify saves completed (atomic write / tmp-then-rename in trainers).","Validate required keys after any third-party conversion.","Keep a known-good checksum per model artifact."],"tags":["controlnet","checkpoint","missing-keys","validation"],"backgroundTag":"missing-checkpoint-keys","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}