Repository navigation
SWF(bug): return error for overflowing safetensors header shapes - #89
Merged
Merged
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Summary
Malformed safetensors headers no longer panic or wrap the pre-flight OOM estimate: shape products, per-tensor byte counts, and cumulative totals in
estimate_load_bytes/estimate_has_fp8now use checked arithmetic and return an error before real safetensors validation. The spark-runtime OOM comparisons also usesaturating_addso a huge but representable estimate cannot wrap the reserve addition.Root cause: the estimate path computed
shape.iter().product(),numel * elem_bytes, and running totals with unchecked arithmetic. A header such as"shape":[u64::MAX,2]panicked in debug builds and could wrap to a small estimate in release builds beforesafetensors::SafeTensorsrejected the checkpoint.Test plan
Try it (CPU):
ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-runtime --lib weights::loader::tests::estimates_reject_overflowing_header_shapes -- --exact --nocapturemain, the same command panicked withattempt to multiply with overflowand failed.1 passed; fullATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-runtime --lib→585 passed; 0 failed; 11 ignored.cargo fmt --all -- --checkATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests -- -Dwarningsbash scripts/check-license-headers.sh(4283files checked,0invalid)typosNotes for reviewers
I kept the existing dtype fallback, shape-entry parsing, and CSF
decoded_len(...).unwrap_or(0)behavior unchanged to keep this scoped to the confirmed overflow path and preserve indexed-load handling of unrouted malformed CSF tensors. Devin Review's test-file and CSF findings are addressed in follow-up commits on this branch.CLA
Implemented in session Return error for overflowing safetensors header shapes
Review with Devin · Open in Devin Desktop