{"record":{"id":"f909e14824fbe8c1","repo":"sgl-project/sglang","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":"python/sglang/multimodal_gen/runtime/loader/utils.py","lineNumber":349,"sourceCode":"def load_safetensors_state_dict(model_path: str) -> dict[str, torch.Tensor]:\n    \"\"\"Load one safetensors checkpoint, including an indexed sharded set.\"\"\"\n    index_path = os.path.join(\n        str(model_path), \"diffusion_pytorch_model.safetensors.index.json\"\n    )\n    safetensors_files = _list_safetensors_files(model_path)\n    if os.path.exists(index_path):\n        with open(index_path) as f:\n            index = json.load(f)\n        shard_names = sorted(set(index.get(\"weight_map\", {}).values()))\n        state_dict: dict[str, torch.Tensor] = {}\n        for shard_name in shard_names:\n            state_dict.update(\n                safetensors_load_file(os.path.join(str(model_path), shard_name))\n            )\n        return state_dict\n\n    if not safetensors_files:\n        raise ValueError(f\"No safetensors files found in {model_path}\")\n    if len(safetensors_files) != 1:\n        raise ValueError(\n            f\"Found {len(safetensors_files)} safetensors files in {model_path} \"\n            \"and no index to disambiguate them.\"\n        )\n    return safetensors_load_file(safetensors_files[0])\n\n\nBYTES_PER_GB = 1024**3\n\n\ndef get_memory_usage_of_component(module) -> float | None:\n    \"\"\"\n    returned value is in GB, rounded to 2 decimal digits\n    \"\"\"\n    if not isinstance(module, nn.Module):\n        return None\n    if hasattr(module, \"get_memory_footprint\"):","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/loader/utils.py#L331-L367","documentation":"The loader found zero .safetensors files in the model directory. It requires exactly one shard file (or an index describing many), so an empty directory is an immediate error.","triggerScenarios":"load_safetensors_state_dict is called on a model_path that contains no *.safetensors files and no usable index.","commonSituations":"Wrong --model path (points at a config-only or empty dir), download that fetched JSON/tokenizer files but not weights, or weights stored in .bin/.pth format only.","solutions":["Verify the path actually contains .safetensors files: ls <model_path>/*.safetensors","Re-download the checkpoint if weights are missing","If the checkpoint is pytorch_model.bin format, convert it to safetensors or point at a safetensors release of the model"],"exampleFix":"# before\n--model /models/llama-config-only\n# after\n--model /models/llama-with-weights","handlingStrategy":"validation","validationCode":"import glob\n\ndef has_safetensors(model_path) -> bool:\n    return len(glob.glob(f\"{model_path}/*.safetensors\")) > 0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assert the model dir contains *.safetensors before calling load_safetensors_state_dict","Prefer official safetensors releases over .bin-only checkpoints"],"tags":["safetensors","missing-weights","model-path"],"backgroundTag":"model-weights-not-found","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}