Repository navigation
checkpoint_metal: clamp pread chunks to INT_MAX - #4433
Closed
markyu0401 wants to merge 1 commit into
Closed
markyu0401 wants to merge 1 commit into
markyu0401 wants to merge 1 commit into
Conversation
Darwin's pread(2) rejects nbyte > INT_MAX with EINVAL, so reading a large single-shard safetensors file (such as an 18+ GiB checkpoint where each of the 8 parallel read threads requests >2 GiB) fails with error.ShortRead. Delegate readAll to a bounded loop clamped to std.math.maxInt(i32), and add a host-only unit test exercising multi-chunk reads and EOF detection.
This was referenced Nov 21, 2026
Author
|
Closing in favor of #4435, which fixes the same macOS |
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.
What this changes
Clamps each
pread(2)call incheckpoint_metal.zig(readAll) tostd.math.maxInt(i32). Before: loading a large single-shard safetensors file (such as an 18+ GiB checkpoint where each of the 8readParallelthreads requests >2 GiB) fails on macOS/Darwin withEINVALand surfaces aserror.ShortRead. After:readAlldelegates toreadAllBounded(..., std.math.maxInt(i32))and loops across bounded chunks until the full slice is read, with a host-only unit test covering multi-chunk reads anderror.ShortReadon EOF.thinkingmachines/Inkling-2-Minicheckpoint on macOS; no existing issue forcheckpoint_metalpreadINT_MAXclamping).main(69e4d0f04).atc overlap --json: ran againstupstream/main(69e4d0f04) on 2026-11-21 —changedFiles: 1,conflict: "clean"across#4387,#3859, and#3379(complete: falsedue tootherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit).Checks on this head
c2eda27ad00ac77e02b4bfd2e3cf7fc854544528python3 tools/zig/lean_check.py, on the base and on this head: 165 on base (69e4d0f04), 165 on head (c2eda27ad), 0 new findings (python3 tools/pr_check.py --base upstream/main->0 error(s), 1 warning(s)for the missing PR-numberedCHANGELOG.mdUnreleased bullet).git diff --checkclean;python3 tools/pr_check.py --base upstream/main0 errors.zig fmt --check build.zig zigandzig build testwere not run locally on this host because Zig 0.17.0 is not installed in this environment; waiting for GitHub Actions CI (zig-fmtandno-gpu) on this PR head.Receipt
n/a — checkpoint file I/O bugfix only; does not modify inference kernels, scheduling, sampling, or arithmetic (loaded tensor bytes are unchanged).
Checklist