sgl-project/sglang · error · EntryNotFoundError
{exc}
Error message
{exc} What it means
hf_hub_download wraps a ModelScope NotExistError into EntryNotFoundError to keep the Hugging Face-compatible exception contract: the requested file does not exist in the given repository. This mirrors huggingface_hub.EntryNotFoundError so callers can handle missing files uniformly across hubs.
Source
Thrown at python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py:1161
local_dir: Optional[Union[str, Path]] = None,
**kwargs,
) -> str:
"""Unified hf_hub_download that supports both Hugging Face Hub and ModelScope."""
if envs.SGLANG_USE_MODELSCOPE.get():
from modelscope import model_file_download
from modelscope.hub.errors import NotExistError
try:
return model_file_download(
model_id=repo_id,
file_path=filename,
local_dir=str(local_dir) if local_dir is not None else None,
**kwargs,
)
except NotExistError as exc:
# Keep the Hugging Face-compatible exception contract used by
# maybe_download_model_index for repositories without model_index.json.
raise EntryNotFoundError(str(exc)) from exc
else:
from huggingface_hub import hf_hub_download as _hf_hub_download
return _hf_hub_download(
repo_id=repo_id,
filename=filename,
local_dir=local_dir,
**kwargs,
)
def snapshot_download(
repo_id: str,
local_dir: Optional[Union[str, Path]] = None,
ignore_patterns: Optional[Union[list[str], str]] = None,
allow_patterns: Optional[Union[list[str], str]] = None,
local_files_only: bool = False,
max_workers: int = 8,View on GitHub (pinned to 0132848349)
Solutions
- Verify the exact filename (and subfolder) exists in the repo with huggingface-cli ls-files or the web UI
- If the file is optional, catch EntryNotFoundError and fall back to the next candidate
- Use the correct repo variant (e.g. the diffusion repo rather than the base LLM repo)
- If the file is sharded, resolve the shard list from the index instead of a single filename
Example fix
// before
f = hf_hub_download(repo_id, "model_index.json")
// after
try:
f = hf_hub_download(repo_id, "model_index.json")
except EntryNotFoundError:
f = None # not a diffusers-style repo Defensive patterns
Strategy: try-catch
Validate before calling
from huggingface_hub import HfApi
files = set(HfApi().list_repo_files(repo_id))
if filename not in files:
# choose fallback before calling Try / catch
try:
path = hf_hub_download(repo_id, filename)
except EntryNotFoundError:
path = fallback_resolution(repo_id) Prevention
- Probe optional files with try/except EntryNotFoundError
- List repo files once and cache the result
- Double-check subfolder paths for sharded weights
When it happens
Trigger: Calling hf_hub_download (directly or via get_is_diffusion_model, download_and_cache_hf_file, resolve_transformer_safetensors_to_load) with a repo_id/filename combination where the file is absent — e.g. looking for model_index.json in a non-diffusers repo, or a wrong filename/subfolder.
Common situations: Probing repos for optional files (model_index.json, config.json) with try/except, wrong subfolder paths for sharded weights, renamed files upstream, repos that are pure transformers vs diffusers layouts.
Related errors
- No cached files for {repo_id} match {allow_patterns or '**/*
- Weight file {source.filename!r} was not found in {source.rep
- No model weights found in {path} (expected model.safetensors
- metal shader source not found: {metal_src}
- Prompt text file not found: {path}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/32e283532c29f11e.
Report an issue: GitHub.