{"record":{"id":"769cb2acca9b937a","repo":"invoke-ai/InvokeAI","slug":"source-is-missing-model-parameters-sorted-inco","errorCode":null,"errorMessage":"{source} is missing model parameters: {sorted(incompatible_keys.missing_keys)[:10]}","messagePattern":"(.+?) is missing model parameters: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/wan.py","lineNumber":295,"sourceCode":"\n    Missing keys are the obvious error. Unexpected keys matter just as much here and\n    are far easier to miss: several Wan 2.2 derivatives are supersets of the plain\n    transformer — Fun-Camera adds ``control_adapter.*`` (6 keys), S2V adds\n    ``audio_injector``/``cond_encoder``/``frame_packer`` (165 keys), Animate adds\n    ``face_adapter``/``motion_encoder`` (127 keys). They match the probe, build a\n    correctly-shaped ``WanTransformer3DModel``, report zero missing keys, and then\n    generate with the entire branch they were built around silently absent.\n\n    ``configs.main._find_unsupported_wan_variant_marker`` turns away the families we\n    know by name; this is the generic backstop, so a derivative nobody has enumerated\n    yet produces an error instead of quietly degraded output.\n\n    Benign extras — bundled VAE/text-encoder weights and merged-LoRA residue — have\n    already been removed by ``_drop_benign_extra_keys``, so anything reaching here is\n    genuinely unplaceable.\n    \"\"\"\n    if incompatible_keys.missing_keys:\n        raise RuntimeError(f\"{source} is missing model parameters: {sorted(incompatible_keys.missing_keys)[:10]}\")\n\n    unexpected = [key for key in incompatible_keys.unexpected_keys if isinstance(key, str)]\n    if unexpected:\n        # Report the distinct top-level module names rather than hundreds of keys.\n        modules = sorted({key.split(\".\")[0] for key in unexpected})\n        raise RuntimeError(\n            f\"{source} has {len(unexpected)} weights that WanTransformer3DModel has nowhere to put \"\n            f\"(modules: {', '.join(modules[:8])}). This is a Wan variant with extra conditioning \"\n            \"branches — Animate, S2V, Fun-Camera and similar — which InvokeAI cannot run faithfully; \"\n            \"loading it anyway would silently ignore that conditioning.\"\n        )\n\n\ndef _tensor_shape(tensor: Any) -> tuple[int, ...]:\n    \"\"\"Logical shape of a tensor, unwrapping GGMLTensor's packed storage.\n\n    A GGMLTensor's ``.shape`` describes the packed quantized blob, not the weight,\n    so the logical dimensions live on ``.tensor_shape``.","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/wan.py#L277-L313","documentation":"After loading Wan single-file checkpoint weights, load_state_dict reports missing keys — tensors in the state dict that the model expects but the checkpoint lacks. Benign extras were already filtered out, so reaching this means the checkpoint genuinely does not contain the required parameters for the configured Wan architecture.","triggerScenarios":"_load_from_singlefile builds a WanTransformer3DModel from a checkpoint whose weights don't cover the expected modules (wrong variant/size checkpoint for the config); truncated or corrupted .safetensors/.pth file; mismatched key naming that prefix-stripping couldn't fix.","commonSituations":"Downloading a partial checkpoint (interrupted download); pairing a Wan 1.3B checkpoint with a 14B config or vice versa; community 'pruned' checkpoints with layers stripped; renamed keys the converter doesn't recognize.","solutions":["Re-download the checkpoint and verify its size/checksum against the source.","Ensure the model config (variant, parameter count) matches the actual checkpoint (e.g., 1.3B vs 14B vs A14B).","Check the message's key list to identify missing modules; obtain an unpruned/unmodified checkpoint if layers were stripped.","Update InvokeAI in case key-conversion/prefix-strip rules for your checkpoint naming were added."],"exampleFix":"// before: config says 14B, file is 1.3B checkpoint\nconfig = Main_Checkpoint_Wan_Config(path=wan_1_3b.safetensors, variant='14b')\n\n// after: matching variant\nconfig = Main_Checkpoint_Wan_Config(path=wan_1_3b.safetensors, variant='1.3b')","handlingStrategy":"validation","validationCode":"from safetensors import safe_open\n\ndef validate_wan_checkpoint(path, required_prefix='model.diffusion_model.'):\n    with safe_open(path, framework='pt') as f:\n        keys = list(f.keys())\n    if not any(required_prefix in k or k.startswith('patch_embedding') for k in keys):\n        raise ValueError(f\"{path} does not look like a Wan transformer checkpoint\")","typeGuard":null,"tryCatchPattern":"try:\n    model = loader.load_model(config, SubModelType.Transformer)\nexcept RuntimeError as e:\n    if 'is missing model parameters' in str(e):\n        handle_corrupt_or_mismatched_checkpoint(config, e)  # re-download / fix variant\n    else:\n        raise","preventionTips":["Verify download size/checksum before registering checkpoints.","Match model variant config (1.3B / 14B / A14B) to the actual checkpoint file.","Avoid 'pruned' community checkpoints with stripped layers for single-file loading.","Keep InvokeAI updated for the latest key-conversion rules."],"tags":["state-dict","checkpoint","model-loading","wan"],"backgroundTag":"state-dict-missing-keys","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}