Fix validation to detect missing model files before loading#14253
Merged
Kangyan-Zhou merged 4 commits intomainfrom Dec 3, 2025
Merged
Fix validation to detect missing model files before loading#14253Kangyan-Zhou merged 4 commits intomainfrom
Kangyan-Zhou merged 4 commits intomainfrom
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
## Problem The current validation logic only checks files that are found by glob pattern matching. If a model's snapshot directory exists with an index file but actual weight files are missing (due to incomplete downloads or cache corruption), the validation passes and claims "Found local HF snapshot", then crashes with FileNotFoundError when trying to load the missing files. Example from CI: ``` [TP0] Found local HF snapshot for openai/gpt-oss-120b at /hf_home/hub/models--openai--gpt-oss-120b/snapshots/... FileNotFoundError: No such file or directory: .../model-00000-of-00014.safetensors ``` The issue is that glob only finds files that exist on disk. If files are missing entirely, they're never validated, so the system doesn't know they should exist. ## Solution Added `_check_index_files_exist()` function that: 1. Reads the safetensors index file (model.safetensors.index.json) 2. Extracts the complete list of required files from the weight_map 3. Verifies that ALL files in the weight_map actually exist on disk 4. Returns validation failure with specific missing filenames if any are absent This function is integrated into `_validate_sharded_model()` and runs before other validation checks. When files are missing, validation fails and triggers a re-download instead of crashing during load. ## Testing - Tested with simulated CI scenario (14-shard model with 1 missing file) - Validation correctly detects missing files and returns clear error message - Non-sharded models (no index file) are unaffected - All files present: validation passes as expected
c94974a to
56c6192
Compare
Collaborator
Author
|
/tag-and-rerun-ci |
Collaborator
Author
Local Testing VerificationTested this implementation locally by simulating the exact CI failure scenario. All tests passed. Test SetupCreated a test script (
Test Cases & Results
Example OutputSimulating the CI failure (missing CI Failure ReferenceThe original CI failure from this run: The |
ping1jing2
approved these changes
Dec 2, 2025
tom-jerr
pushed a commit
to tom-jerr/sglang
that referenced
this pull request
Dec 4, 2025
yingluosanqian
pushed a commit
to yingluosanqian/sglang
that referenced
this pull request
Dec 4, 2025
tonyluj
pushed a commit
to openanolis/sglang
that referenced
this pull request
Dec 5, 2025
tonyluj
pushed a commit
to openanolis/sglang
that referenced
this pull request
Dec 5, 2025
yuchengz816-bot
pushed a commit
to yuchengz816-bot/sglang
that referenced
this pull request
Dec 8, 2025
Kevin-XiongC
pushed a commit
to novitalabs/sglang
that referenced
this pull request
Dec 9, 2025
tonyluj
pushed a commit
to openanolis/sglang
that referenced
this pull request
Dec 12, 2025
tonyluj
pushed a commit
to openanolis/sglang
that referenced
this pull request
Dec 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The current validation logic only checks files that are found by glob pattern matching. If a model's snapshot directory exists with an index file but actual weight files are missing (due to incomplete downloads or cache corruption), the validation passes and claims "Found local HF snapshot", then crashes with FileNotFoundError when trying to load the missing files.
Example from CI:
The issue is that glob only finds files that exist on disk. If files are missing entirely, they're never validated, so the system doesn't know they should exist.
Solution
Added
_check_index_files_exist()function that:model.safetensors.index.json)weight_mapThis function is integrated into
_validate_sharded_model()and runs before other validation checks. When files are missing, validation fails and triggers a re-download instead of crashing during load.Testing
Related
Extends the validation work from #13729 and #13870, which added corruption detection but didn't check for missing files.