sgl-project/sglang · error · ValueError

No safetensors files found in {model_path}

Error message

No safetensors files found in {model_path}

What it means

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.

Source

Thrown at python/sglang/multimodal_gen/runtime/loader/utils.py:349

def load_safetensors_state_dict(model_path: str) -> dict[str, torch.Tensor]:
    """Load one safetensors checkpoint, including an indexed sharded set."""
    index_path = os.path.join(
        str(model_path), "diffusion_pytorch_model.safetensors.index.json"
    )
    safetensors_files = _list_safetensors_files(model_path)
    if os.path.exists(index_path):
        with open(index_path) as f:
            index = json.load(f)
        shard_names = sorted(set(index.get("weight_map", {}).values()))
        state_dict: dict[str, torch.Tensor] = {}
        for shard_name in shard_names:
            state_dict.update(
                safetensors_load_file(os.path.join(str(model_path), shard_name))
            )
        return state_dict

    if not safetensors_files:
        raise ValueError(f"No safetensors files found in {model_path}")
    if len(safetensors_files) != 1:
        raise ValueError(
            f"Found {len(safetensors_files)} safetensors files in {model_path} "
            "and no index to disambiguate them."
        )
    return safetensors_load_file(safetensors_files[0])


BYTES_PER_GB = 1024**3


def get_memory_usage_of_component(module) -> float | None:
    """
    returned value is in GB, rounded to 2 decimal digits
    """
    if not isinstance(module, nn.Module):
        return None
    if hasattr(module, "get_memory_footprint"):

View on GitHub (pinned to 0132848349)

Solutions

  1. Verify the path actually contains .safetensors files: ls <model_path>/*.safetensors
  2. Re-download the checkpoint if weights are missing
  3. If the checkpoint is pytorch_model.bin format, convert it to safetensors or point at a safetensors release of the model

Example fix

# before
--model /models/llama-config-only
# after
--model /models/llama-with-weights
Defensive patterns

Strategy: validation

Validate before calling

import glob

def has_safetensors(model_path) -> bool:
    return len(glob.glob(f"{model_path}/*.safetensors")) > 0

Prevention

When it happens

Trigger: load_safetensors_state_dict is called on a model_path that contains no *.safetensors files and no usable index.

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

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/f909e14824fbe8c1. Report an issue: GitHub.