{"record":{"id":"ab47482cf3060c4e","repo":"sgl-project/sglang","slug":"found-len-safetensors-files-safetensors-files-i","errorCode":null,"errorMessage":"Found {len(safetensors_files)} safetensors files in {model_path} and no index to disambiguate them.","messagePattern":"Found (.+?) safetensors files in (.+?) and no index to disambiguate them\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/loader/utils.py","lineNumber":351,"sourceCode":"    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\"):\n        usage = module.get_memory_footprint() / BYTES_PER_GB\n    else:","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/loader/utils.py#L333-L369","documentation":"Multiple .safetensors files exist in the directory but there is no index file (model.safetensors.index.json) saying how tensors map to shards, so the loader cannot decide which file to load. It refuses to guess because picking arbitrarily would yield wrong or partial weights.","triggerScenarios":"load_safetensors_state_dict finds len(safetensors_files) > 1 and no disambiguating index.","commonSituations":"User drops an extra safetensors file (e.g. an fp8 variant or an adapter) into a single-shard model dir; downloaded a sharded model whose index file was skipped; consolidated + sharded files mixed.","solutions":["Point --model at a directory containing exactly one .safetensors file plus its index","Remove/move the stray safetensors file that does not belong","Re-download the full checkpoint so model.safetensors.index.json is restored"],"exampleFix":"# before\nmodels/llama/ (model-00001-of-02.safetensors, model-00002-of-02.safetensors, stray.safetensors, no index)\n# after\nmodels/llama/ (model-00001-of-02.safetensors, model-00002-of-02.safetensors, model.safetensors.index.json)","handlingStrategy":"validation","validationCode":"import glob, os\n\ndef unambiguous_checkpoint(model_path) -> bool:\n    files = glob.glob(f\"{model_path}/*.safetensors\")\n    return len(files) == 1 or os.path.exists(\n        os.path.join(model_path, \"model.safetensors.index.json\")\n    )","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never drop extra safetensors variants into a model directory","Keep one model variant per directory; use separate dirs for fp8/bf16 copies"],"tags":["safetensors","sharding","ambiguous-checkpoint"],"backgroundTag":"ambiguous-model-checkpoint","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}