{"record":{"id":"fd3fb215da8a6e73","repo":"invoke-ai/InvokeAI","slug":"multiple-weight-files-found-for-this-model-ps","errorCode":null,"errorMessage":"Multiple weight files found for this model: {ps}. Please specify the intended file using the 'path' argument","messagePattern":"Multiple weight files found for this model: (.+?)\\. Please specify the intended file using the 'path' argument","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/model_on_disk.py","lineNumber":170,"sourceCode":"        # Normalize PEFT named-adapter keys (e.g. `lora_A.default.weight` → `lora_A.weight`).\n        # Pattern is LoRA-specific, so this is a no-op for non-LoRA state dicts.\n        from invokeai.backend.patches.lora_conversions.peft_adapter_utils import normalize_peft_adapter_names\n\n        state_dict = normalize_peft_adapter_names(state_dict)\n\n        self._state_dict_cache[path] = state_dict\n        return state_dict\n\n    def resolve_weight_file(self, path: Optional[Path] = None) -> Path:\n        if not path:\n            weight_files = list(self.weight_files())\n            match weight_files:\n                case []:\n                    raise ValueError(\"No weight files found for this model\")\n                case [p]:\n                    return p\n                case ps if len(ps) >= 2:\n                    raise ValueError(\n                        f\"Multiple weight files found for this model: {ps}. \"\n                        f\"Please specify the intended file using the 'path' argument\"\n                    )\n        return path\n","sourceCodeStart":152,"sourceCodeEnd":175,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/model_on_disk.py#L152-L175","documentation":"resolve_weight_file() scans a model's directory on disk for candidate weight files. When it finds two or more, it cannot guess which one is intended, so it raises ValueError listing all candidates and asking the caller to disambiguate via the 'path' argument of the model-import config.","triggerScenarios":"Importing or loading a ModelOnDisk whose directory contains >= 2 weight files (e.g. model.safetensors plus a checkpoint subdir or duplicate .safetensors/.ckpt), which makes `weight_files` match the `case ps if len(ps) >= 2` branch. Called via load_state_dict() or metadata().","commonSituations":"Downloading a repo that ships both fp16 and fp32 safetensors variants; a repo with both .safetensors and .ckpt/.bin files; resuming a partially re-downloaded model that left duplicate weights; manually copying extra checkpoints into the model folder.","solutions":["Set the 'path' field in the model's install/import config to the exact relative path of the intended weight file.","Remove or move the unwanted duplicate weight files out of the model directory.","If the duplicates are download artifacts, delete the model and re-download it cleanly."],"exampleFix":"// before: import config with no path, folder has model.safetensors and model-fp16.safetensors\nModelInstaller().install(path_or_url, config)\n// after\nconfig = StableDiffusionDiffusersConfig(path='model.safetensors')\nModelInstaller().install(path_or_url, config)","handlingStrategy":"validation","validationCode":"from pathlib import Path\nWEIGHT_EXTS = {'.safetensors', '.ckpt', '.pt', '.pth', '.bin'}\nweight_files = [p for p in Path(model_dir).rglob('*') if p.suffix.lower() in WEIGHT_EXTS]\nif len(weight_files) > 1:\n    raise ValueError(f'Choose one weight file: {weight_files}')","typeGuard":"def has_single_weight_file(d: Path) -> bool:\n    exts = {'.safetensors', '.ckpt', '.pt', '.pth', '.bin'}\n    files = [p for p in d.rglob('*') if p.is_file() and p.suffix.lower() in exts]\n    return len(files) == 1","tryCatchPattern":null,"preventionTips":["Always set the 'path' field in import config when a model folder contains multiple weight files.","Keep one weight file per model directory; move variants elsewhere.","Use safetensors-only sources to reduce duplicate-format downloads."],"tags":["model-loading","config","ambiguous-path"],"backgroundTag":"ambiguous-model-weight-file","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}