{"record":{"id":"d2173250b0759384","repo":"invoke-ai/InvokeAI","slug":"pid-checkpoint-is-missing-len-missing-of-the-we","errorCode":null,"errorMessage":"PiD checkpoint is missing {len(missing)} of the weights required by PidNet; the file is incomplete and cannot be used as a PiD decoder: {missing[:5]}{_and_more(missing)}","messagePattern":"PiD checkpoint is missing (.+?) of the weights required by PidNet; the file is incomplete and cannot be used as a PiD decoder: (.+?)(.+?)","errorType":"exception","errorClass":"InvalidMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/pid_decoder.py","lineNumber":157,"sourceCode":"\n    Missing *and* unexpected keys are fatal here because both are fatal there, which is what makes\n    installation and loading accept the same set of files. A stricter installer cannot reject a file\n    that would have loaded: the loader already refuses everything rejected here.\n\n    `_LATENT_PROJ_KEY` is excluded from the shape comparison, and only from that: it is the one\n    parameter whose shape legitimately varies by backbone, and its variable dimensions each have a\n    dedicated check above with a dedicated message.\n    \"\"\"\n    # No \"this is a base PixDiT_T2I checkpoint\" special case, unlike `load_pid_decoder`: those weights\n    # carry no `lq_proj` key at all, so such a file never reaches here — `_looks_like_pid_decoder`\n    # has already turned it away, and with a better message.\n    # Both sorts take `key=str`: a bare checkpoint's keys need not all be strings (see\n    # `strip_net_prefix`), and sorting a mixed set raises TypeError — which the factory answers with\n    # the `Unknown_Config` registration these checks exist to prevent, so the crash fails as a silent\n    # accept rather than loudly. Only `unexpected` can hold one today; sorting both the same way keeps\n    # that from depending on which set is on which side of the subtraction.\n    if missing := sorted(contract.keys() - shapes.keys(), key=str):\n        raise InvalidMatchError(\n            f\"PiD checkpoint is missing {len(missing)} of the weights required by PidNet; the file is \"\n            f\"incomplete and cannot be used as a PiD decoder: {missing[:5]}{_and_more(missing)}\"\n        )\n\n    if unexpected := sorted(shapes.keys() - contract.keys(), key=str):\n        raise InvalidMatchError(\n            f\"PiD checkpoint has {len(unexpected)} keys PidNet does not expect, which `load_pid_decoder` \"\n            f\"rejects too: {unexpected[:5]}{_and_more(unexpected)}\"\n        )\n\n    mismatched = [(k, shapes[k], want) for k, want in contract.items() if k != _LATENT_PROJ_KEY and shapes[k] != want]\n    if mismatched:\n        k, got, want = mismatched[0]\n        raise InvalidMatchError(\n            f\"PiD checkpoint has {len(mismatched)} weights whose shape PidNet cannot accept \"\n            f\"(e.g. {k}: {got}, expected {want}); loading it would fail with a size mismatch\"\n        )\n","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/pid_decoder.py#L139-L175","documentation":"The checkpoint is compared against the exact key set `required_pid_net_shapes()` demands (mirroring `load_pid_decoder`). If contract keys are absent from the state dict, the file is incomplete and would leave weights uninitialized (loaders run under `skip_torch_weight_init`), so an `InvalidMatchError` lists the first 5 missing keys.","triggerScenarios":"`_raise_if_pid_net_contract_unmet` in `from_model_on_disk` finds `contract.keys() - shapes.keys()` non-empty — e.g. a file carrying only LQ weights but none of the 385 backbone weights, or a truncated download.","commonSituations":"Partially downloaded .pth from HuggingFace; manually assembled/stripped checkpoints; single-file install that lost part of a sharded set.","solutions":["Re-download the checkpoint and verify file size/checksum against the source","Install the complete model (all shards) from the original repo rather than copying individual files","Delete the broken file and reinstall via InvokeAI's model manager so integrity is handled for you"],"exampleFix":"# before: manually copied partial checkpoint\n$ cp model_ema_bf16.pth $INVOKEAI_ROOT/models/...   # incomplete\n// after: verify and re-download\n$ huggingface-cli download nvidia/PiD <path> --local-dir ...\n$ sha256sum -c expected_checksums.txt","handlingStrategy":"validation","validationCode":"from invokeai.backend.pid.decode import required_pid_net_shapes\nfrom invokeai.backend.pid.state_dict_utils import pid_net_shapes\nimport torch\nsd = torch.load(ckpt_path, map_location='cpu')\nmissing = required_pid_net_shapes().keys() - pid_net_shapes(sd).keys()\nif missing:\n    raise SystemExit(f'Incomplete PiD checkpoint, missing {len(missing)} weights, e.g. {sorted(missing, key=str)[:5]}')","typeGuard":"def is_complete_pid_decoder(sd: dict) -> bool:\n    from invokeai.backend.pid.decode import required_pid_net_shapes\n    from invokeai.backend.pid.state_dict_utils import pid_net_shapes\n    return not (required_pid_net_shapes().keys() - pid_net_shapes(sd).keys())","tryCatchPattern":"try:\n    install_model(path)\nexcept InvalidMatchError as e:\n    if 'is missing' in str(e) and 'PidNet' in str(e):\n        logger.error('Truncated/incomplete checkpoint, re-download: %s', e)\n    else:\n        raise","preventionTips":["Verify file size/checksum after downloading .pth files","Install all shards of a multi-file checkpoint together","Reinstall via the model manager instead of manually copying files"],"tags":["checkpoint","corrupt-file","missing-keys"],"backgroundTag":"checkpoint-missing-keys","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}