Repository navigation
Metal loader: a checkpoint span of 16 GiB or more loads (each pread capped at 1 GiB) - #4435
Conversation
|
#4433 opened four minutes before this one with the same clamp. I searched for an existing report before starting and it was not up yet, so this is a duplicate by accident, not a competing fix. What this one adds over #4433:
I am glad to close this in favour of #4433 and offer the test there, or to keep this one. Whichever you prefer. |
|
I independently reproduced the oversized read on an M5 Max (macOS 27.2, Zig 0.17.0). I extracted
A trial merge into Rebase recheck. The new head Igor Lessio - AIFLOW LABS |
dad62b9 to
f953d4f
Compare
|
Thanks @sethforprivacy. This is the loader fix Inkling 2 Mini's released single-file checkpoint (19.5 GB) needs on every Mac, and @AIFlowML's independent repro matches it. The red checks are from a 21 Nov run while main itself was red (the pytest PyYAML outage, fixed by #4469). We've put it in our landing queue, which re-runs CI on today's main.
|
f953d4f to
e2c46b4
Compare
|
Thank you @sethforprivacy. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
What this changes
Before: the Metal loader stops with
ShortReadon a checkpoint span of 16 GiB or more, because it reads the span in eight preads and macOS refuses a pread of more than INT_MAX bytes. After: each pread asks for at most 1 GiB, so the span loads; the bytes read are the same.Inkling 2 Mini is the first checkpoint to reach this:
thinkingmachines/Inkling-2-Miniis one 19.5 GB safetensors file, andaddFileSelectedreads itsmodel.llm.span (about 17.6 GiB) as eight parts of 2.2 GiB.atc overlap --json: not run, ATC is not installed on the machine that pushes. Checked by hand withgit merge-treeagainst Inkling 2 Mini on CUDA and Metal #4387 and Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337, the two open pull requests I know to touch this file's callers: both merge cleanly with this branch.Checks on this head
dad62b9cf9, on main69e4d0f04f. The code and the test aree08a88fd68, which the checks below ran on;dad62b9cf9adds only the Unreleased line.python3 tools/zig/lean_check.py, on the base and on this head: 165 and 165, 0 new (lean_new.py).tools/pr_check.py --base origin/main --pr 4435ondad62b9cf9: 0 errors, 0 warnings.zig build test test-golden -Dcpu=apple_m1on this head: 961 of 965 steps succeed and 3 fail, the same 3 as on main (Zig's cache replays unchanged test binaries, so this run's counts cover only the rebuilt ones: 2,157 of 2,205 tests passed, 46 skipped, 2 failed). The new test,core.checkpoint_metal.test.a span longer than one pread may ask for is read whole, passes.max_preadset tomaxInt(usize)): the new test fails,readAllreturningShortReadon a 2 GiB + 4 KiB span.families.deepseek_v41.metal.vision.test.the release's vision_config parses to the defaultsin two test binaries (expectederror.UnsupportedVision, founderror.ZeroHeads), and the link checktensorfold-native links its own memcpy.zig build test test-golden -Dcpu=apple_m1on69e4d0f04fitself gives the same ones: 961 of 965 steps, 16,969 of 17,118 tests passed, 147 skipped, 2 failed, andtest-golden324/337 and 69/69 equal with 0 unexpected on both.zig fmt --check build.zig zigandgit diff --check: clean.Receipt
core/checkpoint_metal.zig(addFile,addFileSelected,addFileSplit,Checkpoint.read,Stage.read).dad62b9cf9, Zig 0.17.0, Xcode's Metal toolchain, Mac Studio M5 Ultra (256 GB), macOS 27.0,thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: n/a, the loader reads the same bytes. On Inkling 2 Mini on CUDA and Metal #4387's branch with this change applied, the Mini checkpoint loads (18.2 GiB resident) where it stopped withthe native Inkling 2 Mini engine cannot load this checkpoint (ShortRead).tools/bench_openai.py: n/a, not reached.The new test maps 2 GiB + 4 KiB of anonymous memory and reads a sparse file of that size into it, so it touches about 2 GiB while it runs and nothing on disk. It skips if the file or the mapping cannot be made.
Checklist