sgl-project/sglang · error · LocalEntryNotFoundError

No cached files for {repo_id} match {allow_patterns or '**/*

Error message

No cached files for {repo_id} match {allow_patterns or '**/*'}

What it means

snapshot_download with local_files_only=True found a cached snapshot directory but no files inside it match the allow_patterns, so it raises LocalEntryNotFoundError. This is the offline-cache equivalent of a missing repo/file set: the cache exists but lacks the needed artifacts.

Source

Thrown at python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py:1201

    if envs.SGLANG_USE_MODELSCOPE.get():
        from modelscope import snapshot_download as _ms_snapshot_download

        # ModelScope validates cached files on every online snapshot request and
        # has no force_download argument. Dropping it preserves the caller's
        # intended online revalidation without leaking Hub-specific kwargs.
        kwargs.pop("force_download", None)
        ms_kwargs = {
            "model_id": repo_id,
            "local_dir": str(local_dir) if local_dir is not None else None,
            "ignore_patterns": ignore_patterns,
            "allow_patterns": allow_patterns,
            "local_files_only": local_files_only,
            "max_workers": max_workers,
        }
        ms_kwargs.update(kwargs)
        local_path = _ms_snapshot_download(**ms_kwargs)
        if local_files_only and not _snapshot_has_files(local_path, allow_patterns):
            raise LocalEntryNotFoundError(
                f"No cached files for {repo_id} match {allow_patterns or '**/*'}"
            )
        return local_path
    else:
        from huggingface_hub import snapshot_download as _hf_snapshot_download

        hf_kwargs = {
            "repo_id": repo_id,
            "local_dir": local_dir,
            "ignore_patterns": ignore_patterns,
            "allow_patterns": allow_patterns,
            "local_files_only": local_files_only,
            "max_workers": max_workers,
            "etag_timeout": 60,
        }
        hf_kwargs.update(kwargs)
        return _hf_snapshot_download(**hf_kwargs)

View on GitHub (pinned to 0132848349)

Solutions

  1. Broaden allow_patterns to match the actual layout (use '**/*.safetensors' or include subfolders)
  2. Re-download online once to fully populate the cache, then rerun offline
  3. Inspect the cached snapshot dir (ls ~/.cache/huggingface/hub/models--.../snapshots/*/) to see what's actually there
  4. Clear the corrupt/partial snapshot and re-pull if the cache is incomplete

Example fix

// before
path = snapshot_download(repo_id, allow_patterns=["*.safetensors"], local_files_only=True)
// after
path = snapshot_download(repo_id, allow_patterns=["**/*.safetensors", "*.json"], local_files_only=True)
Defensive patterns

Strategy: validation

Validate before calling

import glob, os
snap = local_cache_dir  # known snapshot path
if not glob.glob(os.path.join(snap, "**/*.safetensors"), recursive=True):
    raise RuntimeError("cache incomplete; run online download first")

Try / catch

try:
    p = snapshot_download(repo_id, allow_patterns=pats, local_files_only=True)
except LocalEntryNotFoundError:
    p = snapshot_download(repo_id, allow_patterns=pats)  # online fill

Prevention

When it happens

Trigger: Running with local_files_only=True (offline mode / HF_HUB_OFFLINE=1) when the cache was populated with a narrower allow_patterns set, a partial/interrupted download, or the patterns simply don't match the repo layout (e.g. '*.safetensors' when weights are in a subfolder).

Common situations: Air-gapped or offline inference boxes, CI caching only tokenizer files, glob patterns missing subdirectories (need '**/*.safetensors'), stale cache from an earlier partial pull.

Related errors


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