{"record":{"id":"241290a7b08771b0","repo":"invoke-ai/InvokeAI","slug":"no-safetensors-files-found-in-model-path","errorCode":null,"errorMessage":"No safetensors files found in {model_path}","messagePattern":"No safetensors files found in (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/quantization/sdnq/loaders.py","lineNumber":217,"sourceCode":"    SDNQ stores quantized weights with associated scale, zero_point (optional),\n    and SVD correction matrices (optional). This loader creates SDNQTensor\n    wrappers that provide on-the-fly dequantization.\n\n    Args:\n        model_path: Path to safetensors file or directory containing model files.\n        compute_dtype: Dtype for dequantized computation (default: bfloat16).\n\n    Returns:\n        State dict with SDNQTensor wrappers for quantized weights and\n        regular tensors for non-quantized weights.\n    \"\"\"\n    # Determine which safetensors file(s) hold the weights. For larger models (FLUX.2 Klein 9B,\n    # FLUX.2 dev, ...) the transformer is sharded across multiple ``*-NNNNN-of-MMMMM.safetensors``\n    # files; we merge all of them into one state_dict before grouping.\n    if model_path.is_dir():\n        safetensors_files = sorted(model_path.glob(\"*.safetensors\"))\n        if not safetensors_files:\n            raise ValueError(f\"No safetensors files found in {model_path}\")\n        config_path = model_path / \"quantization_config.json\"\n    else:\n        safetensors_files = [model_path]\n        config_path = model_path.parent / \"quantization_config.json\"\n\n    # Load quantization config if available\n    quant_config = _parse_quantization_config(config_path)\n\n    # Get group_size from config (default: 128 for SDNQ)\n    # Note: group_size=0 in config means per-tensor quantization or it needs to be inferred\n    config_group_size = quant_config.get(\"group_size\", 128)\n\n    # Build a reverse map for dynamic-mixed-precision models. SDNQ stores\n    # ``modules_dtype_dict`` as ``{dtype_name: [list of layer keys]}``; we flip it to\n    # ``{layer_key: dtype_name}`` for O(1) lookup during the per-tensor type inference.\n    per_tensor_dtype_map: dict[str, str] = {}\n    modules_dtype_dict = quant_config.get(\"modules_dtype_dict\") or {}\n    if isinstance(modules_dtype_dict, dict):","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/quantization/sdnq/loaders.py#L199-L235","documentation":"sdnq_sd_loader expects either a directory containing *.safetensors shard(s) or a single .safetensors file. When given a directory with no safetensors files, it raises ValueError because there are no weights to load.","triggerScenarios":"Passing model_path as a directory that contains only config/JSON files (no *.safetensors), e.g. a diffusers-style folder of .bin weights, an empty folder, or a wrong path.","commonSituations":"Downloading a repo without the safetensors weights (LFS not fetched, so pointer text files only); pointing at a config-only directory; path typo selecting the wrong subfolder.","solutions":["Point model_path at the folder containing the .safetensors weight file(s) or at the file itself","Re-download with git lfs / proper download tool so *.safetensors files actually exist","Verify the path with ls: it must contain at least one *.safetensors file"],"exampleFix":"// before\nloader = sdnq_sd_loader(Path(\"models/flux2-transformer/config-only-dir\"))\n// after\nloader = sdnq_sd_loader(Path(\"models/flux2-transformer\"))  # contains *.safetensors shards","handlingStrategy":"validation","validationCode":"from pathlib import Path\npath = Path(model_path)\nif path.is_dir() and not list(path.glob(\"*.safetensors\")):\n    raise FileNotFoundError(f\"{path} has no *.safetensors weights\")\nmodel = load_sdnq(path)","typeGuard":"def has_safetensors(p: Path) -> bool:\n    return p.is_file() and p.suffix == \".safetensors\" or (p.is_dir() and any(p.glob(\"*.safetensors\")))","tryCatchPattern":"try:\n    model = _load_sdnq_transformer(path)\nexcept ValueError as e:\n    if \"No safetensors\" in str(e):\n        re_download_weights(path)\n    raise","preventionTips":["Confirm *.safetensors files exist before constructing loader paths","Use LFS-aware downloads so weight files are real data, not Git pointer stubs","Prefer pointing at the model root directory rather than config subfolders"],"tags":["valueerror","file-not-found","model-loading"],"backgroundTag":"model-weights-file-not-found","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}