{"record":{"id":"e6d4612c6478f0b9","repo":"invoke-ai/InvokeAI","slug":"unknown-ckpt-type-ckpt-type-r-valid-valid-ckp","errorCode":null,"errorMessage":"Unknown ckpt_type {ckpt_type!r}. Valid: {VALID_CKPT_TYPES}","messagePattern":"Unknown ckpt_type (.+?)\\. Valid: (.+?)","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/pid/_src/inference/checkpoint_registry.py","lineNumber":109,"sourceCode":"}\n# ZImage and ZImage-Turbo use Flux1's 16-ch VAE for both ckpt types → alias to\n# the flux entries. Keep explicit aliases (vs. duplicating) so updating \"flux\"\n# updates these backbones too.\nPID_CHECKPOINT_REGISTRY[(\"zimage_turbo\", \"2k\")] = PID_CHECKPOINT_REGISTRY[(\"flux\", \"2k\")]\nPID_CHECKPOINT_REGISTRY[(\"zimage\", \"2kto4k\")] = PID_CHECKPOINT_REGISTRY[(\"flux\", \"2kto4k\")]\nPID_CHECKPOINT_REGISTRY[(\"zimage_turbo\", \"2kto4k\")] = PID_CHECKPOINT_REGISTRY[(\"flux\", \"2kto4k\")]\n\n\ndef get_pid_checkpoint(backbone: str, ckpt_type: str = \"2k\") -> PIDCheckpoint:\n    \"\"\"Return the registered official PID checkpoint for `(backbone, ckpt_type)`.\n\n    `ckpt_type` defaults to `\"2k\"` so existing call sites keep their pre-2kto4k\n    behavior. Raises KeyError with the list of valid keys when the pair is\n    unknown — typical cause is asking for a `2kto4k` variant of a backbone\n    that doesn't ship one (rae / scale_rae).\n    \"\"\"\n    if ckpt_type not in VALID_CKPT_TYPES:\n        raise KeyError(f\"Unknown ckpt_type {ckpt_type!r}. Valid: {VALID_CKPT_TYPES}\")\n    try:\n        return PID_CHECKPOINT_REGISTRY[(backbone, ckpt_type)]\n    except KeyError as exc:\n        valid = \", \".join(sorted(f\"{b}+{t}\" for b, t in PID_CHECKPOINT_REGISTRY))\n        raise KeyError(f\"Unknown (backbone, ckpt_type)=({backbone!r}, {ckpt_type!r}). Valid: {valid}\") from exc\n\n\n__all__ = [\n    \"PIDCheckpoint\",\n    \"PID_CHECKPOINT_REGISTRY\",\n    \"VALID_CKPT_TYPES\",\n    \"get_pid_checkpoint\",\n]\n","sourceCodeStart":91,"sourceCodeEnd":123,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/pid/_src/inference/checkpoint_registry.py#L91-L123","documentation":"get_pid_checkpoint first validates ckpt_type against VALID_CKPT_TYPES. Passing any type outside that set (e.g. a typo or an unsupported resolution variant) raises a KeyError listing the valid types before the registry lookup happens.","triggerScenarios":"Calling get_pid_checkpoint(backbone, ckpt_type) with ckpt_type not in VALID_CKPT_TYPES — e.g. '4k' when only '2k' and '2kto4k' are valid, or an empty/None value from config.","commonSituations":"Upgrading code from pre-2kto4k versions where the default was implicit; typos like '2K' vs '2k'; passing a variant the user assumed exists (e.g. 2kto4k for rae/scale_rae backbones that don't ship one — that case instead hits the second KeyError).","solutions":["Use a ckpt_type listed in VALID_CKPT_TYPES (default '2k').","Fix the casing/typo — the check is case-sensitive exact string comparison.","Import VALID_CKPT_TYPES and validate or surface choices in your CLI/config before calling."],"exampleFix":"// before\nget_pid_checkpoint('rae', '2kto4k')  # or typo '2K'\n// after\nfrom invokeai.backend.pid._src.inference.checkpoint_registry import VALID_CKPT_TYPES\nget_pid_checkpoint('rae', '2k')  # ckpt_type in VALID_CKPT_TYPES","handlingStrategy":"validation","validationCode":"from invokeai.backend.pid._src.inference.checkpoint_registry import VALID_CKPT_TYPES\nassert ckpt_type in VALID_CKPT_TYPES, f'{ckpt_type!r} not in {VALID_CKPT_TYPES}'","typeGuard":"def is_valid_ckpt_type(ckpt_type: object) -> bool:\n    return isinstance(ckpt_type, str) and ckpt_type in VALID_CKPT_TYPES","tryCatchPattern":"try:\n    ckpt = get_pid_checkpoint(backbone, ckpt_type)\nexcept KeyError as e:\n    logger.error('Bad ckpt_type: %s', e)\n    ckpt = get_pid_checkpoint(backbone, '2k')  # safe default","preventionTips":["Always import VALID_CKPT_TYPES rather than hard-coding type strings.","Validate CLI/config enum values at startup, before any registry call.","Watch string casing — the check is exact and case-sensitive."],"tags":["keyerror","config","checkpoint","pid"],"backgroundTag":"invalid-enum-value","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}