invoke-ai/InvokeAI · error · NotAMatchError

missing pytorch_lora_weights.bin or pytorch_lora_weights.saf

Error message

missing pytorch_lora_weights.bin or pytorch_lora_weights.safetensors

What it means

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.

Source

Thrown at invokeai/backend/model_manager/configs/lora.py:1282

            case 2048:
                return BaseModelType.StableDiffusionXL
            case _:
                # Some SDXL LoRAs (e.g. self-attention-only "slider" LoRAs) target only the
                # UNet and lack the cross-attention / text-encoder keys that
                # lora_token_vector_length() needs. Fall back to detecting SDXL from the
                # UNet's deep transformer-block structure.
                if _state_dict_looks_like_sdxl_unet_lora(state_dict):
                    return BaseModelType.StableDiffusionXL
                raise NotAMatchError(f"unrecognized token vector length {token_vector_length}")

    @classmethod
    def _get_weight_file_or_raise(cls, mod: ModelOnDisk) -> Path:
        suffixes = ["bin", "safetensors"]
        weight_files = [mod.path / f"pytorch_lora_weights.{sfx}" for sfx in suffixes]
        for wf in weight_files:
            if wf.exists():
                return wf
        raise NotAMatchError("missing pytorch_lora_weights.bin or pytorch_lora_weights.safetensors")


class LoRA_Diffusers_SD1_Config(LoRA_Diffusers_Config_Base, Config_Base):
    base: Literal[BaseModelType.StableDiffusion1] = Field(default=BaseModelType.StableDiffusion1)


class LoRA_Diffusers_SD2_Config(LoRA_Diffusers_Config_Base, Config_Base):
    base: Literal[BaseModelType.StableDiffusion2] = Field(default=BaseModelType.StableDiffusion2)


class LoRA_Diffusers_SDXL_Config(LoRA_Diffusers_Config_Base, Config_Base):
    base: Literal[BaseModelType.StableDiffusionXL] = Field(default=BaseModelType.StableDiffusionXL)


class LoRA_Diffusers_FLUX_Config(LoRA_Diffusers_Config_Base, Config_Base):
    base: Literal[BaseModelType.Flux] = Field(default=BaseModelType.Flux)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Ensure the directory contains pytorch_lora_weights.safetensors (or .bin); re-download the repo with git lfs pull or via huggingface hub download.
  2. 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.
  3. Check the file is not a Git LFS pointer (tiny size, 'version https://git-lfs' text) and re-download if so.
  4. Verify the directory layout: <model_dir>/pytorch_lora_weights.safetensors directly inside, not nested a level deeper.

Example fix

// before
my-lora/
  model.safetensors   # unexpected filename
// after
my-lora/
  pytorch_lora_weights.safetensors
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
d = Path('my-lora')
if not ((d / 'pytorch_lora_weights.safetensors').exists() or (d / 'pytorch_lora_weights.bin').exists()):
    raise ValueError(f'{d} is not a Diffusers LoRA dir: missing pytorch_lora_weights.*')

Type guard

def is_diffusers_lora_dir(path) -> bool:
    p = Path(path)
    return p.is_dir() and any((p / f'pytorch_lora_weights.{ext}').exists() for ext in ('safetensors', 'bin'))

Try / catch

try:
    result = model_manager.scan_model(path)
except NotAMatchError as e:
    if 'pytorch_lora_weights' in str(e):
        print('Directory lacks Diffusers LoRA weight file; check the download/LFS')
else:
    use(result)

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/bafec5c30a1b1da5. Report an issue: GitHub.