sgl-project/sglang · critical · FileNotFoundError

No model weights found in {path} (expected model.safetensors

Error message

No model weights found in {path} (expected model.safetensors or pytorch_model.bin)

What it means

When building the MiMo audio tokenizer, sglang loads weights from model.safetensors or pytorch_model.bin inside the model directory; if neither file exists it raises FileNotFoundError. The path is resolved from the loaded model's model_path (downloading via huggingface_hub if needed), so this means the local directory lacks any weight file.

Source

Thrown at python/sglang/srt/models/mimo_audio.py:1293

    ) -> MiMoAudioTokenizer:
        """Load MiMoAudioTokenizer manually to avoid new-transformers compat issues."""
        import json

        from safetensors.torch import load_file

        config_path = os.path.join(path, "config.json")
        with open(config_path) as f:
            config_dict = json.load(f)
        config = MiMoAudioTokenizer.config_class(**config_dict)
        model = MiMoAudioTokenizer(config)
        safetensors_path = os.path.join(path, "model.safetensors")
        bin_path = os.path.join(path, "pytorch_model.bin")
        if os.path.exists(safetensors_path):
            state_dict = load_file(safetensors_path, device="cpu")
        elif os.path.exists(bin_path):
            state_dict = torch.load(bin_path, map_location="cpu", weights_only=True)
        else:
            raise FileNotFoundError(
                f"No model weights found in {path} "
                "(expected model.safetensors or pytorch_model.bin)"
            )
        state_dict = _remap_audio_tokenizer_state_dict(state_dict)
        model.load_state_dict(state_dict, strict=False)
        model = model.to(device=device, dtype=torch.bfloat16)
        model.eval()
        model.requires_grad_(False)
        return model

    def apply_input_local_transformer(
        self, speech_embeddings: torch.Tensor
    ) -> torch.Tensor:
        return self.input_local_transformer(
            inputs_embeds=speech_embeddings,
            return_dict=True,
            is_causal=not self.audio_input_full_attention,  # for SDPA
        ).last_hidden_state  # [T//group_size, group_size, input_local_dim]

View on GitHub (pinned to 0132848349)

Solutions

  1. Point --model-path at a complete MiMo audio tokenizer snapshot containing model.safetensors or pytorch_model.bin
  2. Clear the incomplete HF cache (rm -rf ~/.cache/huggingface/hub/<repo>) and re-download so snapshot_download completes
  3. If the checkpoint is sharded, merge shards or name the output as model.safetensors before loading

Example fix

# before
ls /models/mimo-audio/  # config.json only
# after
huggingface-cli download <mimo-audio-repo> --local-dir /models/mimo-audio
ls /models/mimo-audio/  # config.json model.safetensors
Defensive patterns

Strategy: validation

Validate before calling

import os
path = model_path
ok = os.path.exists(os.path.join(path, "model.safetensors")) or os.path.exists(os.path.join(path, "pytorch_model.bin"))
assert ok, f"no single-file weights in {path}"

Type guard

def has_single_file_weights(path: str) -> bool:
    return os.path.isfile(os.path.join(path, "model.safetensors")) or os.path.isfile(os.path.join(path, "pytorch_model.bin"))

Try / catch

try:
    tok = load_mimo_audio_tokenizer(model_path)
except FileNotFoundError as e:
    raise RuntimeError(f"audio tokenizer incomplete at {model_path}; re-download") from e

Prevention

When it happens

Trigger: The MiMo model path points to a directory containing only config/shards (e.g. sharded safetensors with index but no single model.safetensors), or a partially downloaded/corrupted snapshot cache. Raises after snapshot_download when files still aren't present.

Common situations: Interrupted HF downloads leaving an incomplete cache; locally exported checkpoints saved as sharded files (model-00001-of-...safetensors) rather than single-file; wrong --model-path pointing at a config-only dir.

Related errors


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