{"record":{"id":"bafec5c30a1b1da5","repo":"invoke-ai/InvokeAI","slug":"missing-pytorch-lora-weights-bin-or-pytorch-lora-w","errorCode":null,"errorMessage":"missing pytorch_lora_weights.bin or pytorch_lora_weights.safetensors","messagePattern":"missing pytorch_lora_weights\\.bin or pytorch_lora_weights\\.safetensors","errorType":"exception","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/lora.py","lineNumber":1282,"sourceCode":"            case 2048:\n                return BaseModelType.StableDiffusionXL\n            case _:\n                # Some SDXL LoRAs (e.g. self-attention-only \"slider\" LoRAs) target only the\n                # UNet and lack the cross-attention / text-encoder keys that\n                # lora_token_vector_length() needs. Fall back to detecting SDXL from the\n                # UNet's deep transformer-block structure.\n                if _state_dict_looks_like_sdxl_unet_lora(state_dict):\n                    return BaseModelType.StableDiffusionXL\n                raise NotAMatchError(f\"unrecognized token vector length {token_vector_length}\")\n\n    @classmethod\n    def _get_weight_file_or_raise(cls, mod: ModelOnDisk) -> Path:\n        suffixes = [\"bin\", \"safetensors\"]\n        weight_files = [mod.path / f\"pytorch_lora_weights.{sfx}\" for sfx in suffixes]\n        for wf in weight_files:\n            if wf.exists():\n                return wf\n        raise NotAMatchError(\"missing pytorch_lora_weights.bin or pytorch_lora_weights.safetensors\")\n\n\nclass LoRA_Diffusers_SD1_Config(LoRA_Diffusers_Config_Base, Config_Base):\n    base: Literal[BaseModelType.StableDiffusion1] = Field(default=BaseModelType.StableDiffusion1)\n\n\nclass LoRA_Diffusers_SD2_Config(LoRA_Diffusers_Config_Base, Config_Base):\n    base: Literal[BaseModelType.StableDiffusion2] = Field(default=BaseModelType.StableDiffusion2)\n\n\nclass LoRA_Diffusers_SDXL_Config(LoRA_Diffusers_Config_Base, Config_Base):\n    base: Literal[BaseModelType.StableDiffusionXL] = Field(default=BaseModelType.StableDiffusionXL)\n\n\nclass LoRA_Diffusers_FLUX_Config(LoRA_Diffusers_Config_Base, Config_Base):\n    base: Literal[BaseModelType.Flux] = Field(default=BaseModelType.Flux)\n\n","sourceCodeStart":1264,"sourceCodeEnd":1300,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/lora.py#L1264-L1300","documentation":"Diffusers LoRAs are stored as directories, and this config class expects the weights inside a file named pytorch_lora_weights.bin or pytorch_lora_weights.safetensors. When scanning a directory that is neither a FLUX-style LoRA nor contains one of those weight files, _get_weight_file_or_raise raises NotAMatchError because the directory cannot be a Diffusers LoRA.","triggerScenarios":"Pointing the model manager / scan API at a directory lacking pytorch_lora_weights.{bin,safetensors} — e.g. a single-file LoRA given as a directory path, a partially extracted download, or a repo with differently named weight files (model.safetensors, lora_weights.safetensors).","commonSituations":"Downloading a Diffusers LoRA repo but omitting LFS files so pytorch_lora_weights.safetensors is a pointer stub or missing; renaming the weight file manually; pointing at the wrong subfolder of a repo.","solutions":["Ensure the directory contains pytorch_lora_weights.safetensors (or .bin); re-download the repo with git lfs pull or via huggingface hub download.","If you have a single-file LoRA (.safetensors at top level), scan the file path itself rather than wrapping it in a directory, or use a LoRA config format that accepts single files.","Check the file is not a Git LFS pointer (tiny size, 'version https://git-lfs' text) and re-download if so.","Verify the directory layout: <model_dir>/pytorch_lora_weights.safetensors directly inside, not nested a level deeper."],"exampleFix":"// before\nmy-lora/\n  model.safetensors   # unexpected filename\n// after\nmy-lora/\n  pytorch_lora_weights.safetensors","handlingStrategy":"validation","validationCode":"from pathlib import Path\nd = Path('my-lora')\nif not ((d / 'pytorch_lora_weights.safetensors').exists() or (d / 'pytorch_lora_weights.bin').exists()):\n    raise ValueError(f'{d} is not a Diffusers LoRA dir: missing pytorch_lora_weights.*')","typeGuard":"def is_diffusers_lora_dir(path) -> bool:\n    p = Path(path)\n    return p.is_dir() and any((p / f'pytorch_lora_weights.{ext}').exists() for ext in ('safetensors', 'bin'))","tryCatchPattern":"try:\n    result = model_manager.scan_model(path)\nexcept NotAMatchError as e:\n    if 'pytorch_lora_weights' in str(e):\n        print('Directory lacks Diffusers LoRA weight file; check the download/LFS')\nelse:\n    use(result)","preventionTips":["Download HF repos with git lfs or the hub client so weights are real files","Never rename pytorch_lora_weights.* after download","Scan single-file LoRAs as files, not wrapped directories","Check file sizes to catch LFS pointer stubs"],"tags":["lora","diffusers","missing-file"],"backgroundTag":"missing-model-weight-file","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}