sgl-project/sglang · critical · RuntimeError
Downloaded model files are still corrupted for {model_name_o
Error message
Downloaded model files are still corrupted for {model_name_or_path} after {max_retries} attempts. This may indicate a persistent issue with the model files on Hugging Face Hub or network problems. What it means
Raised by ci_download_with_validation_and_retry when downloads technically succeed but the downloaded model files fail integrity validation on every retry attempt. This points to corruption at the source (bad files on Hugging Face Hub) or persistent network corruption rather than a one-off bad transfer, since retries with cleanup did not help.
Source
Thrown at python/sglang/srt/model_loader/ci_weight_validation.py:844
) from e
# Validate downloaded files to catch corruption early
is_valid = _validate_weights_after_download(
hf_folder, allow_patterns, model_name_or_path
)
if is_valid:
return hf_folder
# Validation failed, corrupted files were cleaned up
if attempt < max_retries - 1:
log_info_on_rank0(
logger,
f"Retrying download for {model_name_or_path} "
f"(attempt {attempt + 2}/{max_retries})...",
)
else:
raise RuntimeError(
f"Downloaded model files are still corrupted for "
f"{model_name_or_path} after {max_retries} attempts. "
"This may indicate a persistent issue with the model files "
"on Hugging Face Hub or network problems."
)
# Should never reach here, but return hf_folder just in case
return hf_folder
def ci_validate_and_clean_hf_cache(model_path: str) -> None:
"""Drop corrupted safetensors from the HF cache before a non-SGLang load.
HFRunner calls transformers' from_pretrained() directly, which bypasses the
validation in this module; a corrupted cache surfaces as "EOF while parsing".
"""
from sglang.utils import is_in_ci
View on GitHub (pinned to 0132848349)
Solutions
- Verify the model repo on HF Hub (file sizes/sha256 vs repo listing) and report if the source is corrupted
- Clear the local HF cache completely (rm -rf ~/.cache/huggingface/hub/<model>) and re-download on a clean network
- Bypass proxies/VPN/antivirus that may corrupt transfers, or download on another machine and copy the cache
- If validation logic is stale (schema changed), update sglang or pin a known-good model revision
Defensive patterns
Strategy: retry
Validate before calling
from huggingface_hub import HfApi
info = HfApi().model_info(model_name_or_path, files_metadata=True)
for s in info.siblings:
if s.size and s.size % 2: # example sanity check
print('suspicious file size:', s.rfilename, s.size) Try / catch
try:
download_weights_from_hf(model, cache_dir)
except RuntimeError as e:
if 'still corrupted' in str(e):
shutil.rmtree(cache_dir, ignore_errors=True)
raise # surface: source corruption needs manual intervention
raise Prevention
- Pin exact model revisions (commit SHA) known to be intact
- Keep HF cache on reliable local disk; avoid cache over flaky network mounts
- Compare file hashes against the Hub listing after download
- Exclude model caches from antivirus scanning
When it happens
Trigger: Calling download_weights_from_hf where each attempt downloads files whose checksums/structure fail validation; _cleanup_incomplete_blobs + redownload loops finish with files still corrupted, so the RuntimeError is raised.
Common situations: A repo on HF Hub has corrupted or truncated blobs; a MITM proxy/CDN cache serves corrupted bytes; antivirus modifying files in the cache; or an outdated validation schema flagging valid files.
Related errors
- Download failed for {model_name_or_path} after {max_retries}
- Found {len(corrupted_files)} corrupted safetensors file(s).
- Failed to download Real-ESRGAN weights from HuggingFace repo
- Invalid Hugging Face {field_name}: {path!r}
- Weight URL pins revision {url_revision!r}, which conflicts w
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/a8eb1203440b54c1.
Report an issue: GitHub.