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

  1. Verify the model repo on HF Hub (file sizes/sha256 vs repo listing) and report if the source is corrupted
  2. Clear the local HF cache completely (rm -rf ~/.cache/huggingface/hub/<model>) and re-download on a clean network
  3. Bypass proxies/VPN/antivirus that may corrupt transfers, or download on another machine and copy the cache
  4. 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

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


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