Repository navigation
windows: a released checkpoint step's pages leave the working set - #3866
Conversation
d16889b to
f231c7a
Compare
f231c7a to
6cfe3fd
Compare
|
Thank you @ElderOrb. The release hook is confined to Windows, the cold-cache port test passes 30/30, lean is unchanged and CI is green. We agree no token can change, since a trimmed page is one the load has already uploaded. A served checkpoint load on a Windows GPU box is still needed to see the working-set drop and soft refaults; we were unable to run that here. Nothing else is needed from you.
|
6cfe3fd to
26d89af
Compare
|
Thanks @ElderOrb. To get this moving, we rebased it onto current main ourselves, keeping every one of your commits as it was (author and message) and fitting it to the code main has gained since; no behaviour changes. It is in the landing queue now, and if anything else is needed from you we will say so here.
|
26d89af to
fdec2f4
Compare
The tower's tensors load as plain BF16 [n, k] matrices for cuBLASLt: fc1 and fc3 stacked into one gate|up projection, and the patch weight flattened to 588 columns and zero-padded to 592 so its rows meet the library's alignment. Every vision_tower tensor is consumed, the device bytes count the padding, and a failed load drains its uploads before any buffer is freed. -- 2.54.0 (Apple Git-157) -- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
The drain test called settle directly, so dropping the errdefer in load, or registering it before the tower's own errdefer, would stay green. A host test now runs load on a sparse checkpoint against a fake device whose first upload's wait fails: the buffers must go only after the context proved the copies done. The sparse checkpoint helper moves to its own test file so the tower's tests can share it. -- 2.54.0 (Apple Git-157) -- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
The recipe now declares the tower, so the dense engine's tower variant serves dots.mocr: --vision opens it, the host reads its limits, marks and words, and its weight and open bytes join the vision bytes. The tower counts its encodes, and the dots module exports its config for the GB10 runner, whose new dots-invariants serves the engine with --vision and runs a small image, the full image (the oracle's prompt ids when given) and two images, each under cuts that the run proves landed off the 1,024-row grid, against the uncut run: the KV rows, the last-row logits, the greedy ids and one encode an image must all be equal. Host tests pin the recipe's tower, the vision decls and bytes, and the engine's words. -- 2.43.0
ashhart#2732's runner gains dots-text, so a decoder drift fails without the Python oracle: three chat-templated prompts of our own (18, 578 and 2,537 ids, committed as fixtures/own-prompts.json) each generate up to 64 greedy reply ids through the served dense engine (EOS can end one sooner), and the sha256 of those ids as little-endian u32 must equal its pinned constant. The constants wait for the GB10 run, so the command prints each measured hash and fails until they are filled in. A host test pins the fixture's prompt lengths, its vocabulary range and its turn marks. -- 2.43.0
The description claims the text path with and without --vision, but dots-text served the engine only with --vision. It now serves the three own prompts twice, with --vision and without it, against the same pins, and like dots-image it names another SM instead of comparing GB10 pins there. -- 2.43.0
The fixture's ids could not be regenerated from the tree. The fixtures README now names their source text, our own ownprompts.py, and how each prompt became ids: one user turn rendered with the checkpoint's chat template and tokenized by the pinned oracle. -- 2.43.0
-- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
-- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
-- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
-- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
…t under 1.2.9 -- 2.43.0
safetensors.File.release asks Linux for the pages of a range it has finished with (madvise MADV_DONTNEED) and drops the file's page-cache pages. Windows has neither: the pages of a checkpoint a load has uploaded stay in the process's working set, and on a unified-memory host, where the device's memory is the system's, they crowd the allocations that come next out of the budget. The trim is the process's whole set, so it is taken once a step rather than once a shard: core's Checkpoint.release and releaseExcept, and the qwen3_5 loader's per-layer release. The pages go to the standby list, where a later read faults them back softly, so a trim that is too eager costs a refault and never a byte. platform/working_set.zig is the call, next to the other Win32 declarations, behind the sys module every module already imports; it is a no-op elsewhere, where the per-range advice already covers this.
fdec2f4 to
a74544e
Compare
|
Thank you @ElderOrb. 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
On Windows, a checkpoint load's released pages stayed in the process's working set:
safetensors.File.releaseasks Linux for the pages of a range it has finished with (madvise(MADV_DONTNEED)) and drops the file's page-cache pages, and neither call has a Windows counterpart. After this, a release also trims the process's working set, so the pages a load has uploaded and finished with leave it instead of crowding the device's allocations out of a unified-memory budget.#2490is the measurement that surfaced it, not the work it belongs to.main(0900b484e). One commit,6cfe3fdbb.atc overlap --json: not run.atc 0.9.1refuses this checkout's board withatc: Invalid .github/atc.json, so neitherboard,checknoroverlapanswers here. The schema in.github/atc.jsonis the repository's own and unchanged by this commit. Both files this touches fall in thecorearea (zig/src/core/, andzig/src/platform/is unclaimed).Checks on this head
6cfe3fdbb(branchcheckpoint-workset, base0900b484e).python3 tools/zig/lean_check.py, on the base and on this head: 221 on the base, 221 on this head, 0 new (tools/zig/lean_new.pyprintslean: 0 problems, 0 on the base, 0 new). The 221 are inherited and unchanged.zig build test --summary all→ exit 0, all steps succeeded.zig build test-windows-port-host --summary allon a cold cache (ZIG_GLOBAL_CACHE_DIRpointed at an empty directory, so nothing was replayed) → 30/30 tests passed, 14/14 steps.zig fmt --check build.zig zig→ exit 0.git diff --check→ exit 0.fmt,pytest,zig,zig-b,zig-windows,zig-macos-dev-tools,release-paths (ubuntu-24.04)andbenchmark-clientson both Ubuntu and Windows succeed;host-nightly-linuxandhost-nightly-macosare skipped by design for a non-nightly push, so 10 of 12 ran and 10 passed.atc overlap --json—atc 0.9.1cannot parse this checkout's.github/atc.json(above).working_set.release()returns immediately unlessbuiltin.os.tag == .windows, so those targets compile the same code they did, and nothing in them calls it on a non-Windows target.Receipt
This changes when pages leave a process's working set on Windows. It adds no arithmetic, reads no weight and reorders no sum, so no token can change: a trimmed page is one the load has already uploaded, and it faults back softly from the standby list if it is read again. The test below is the exactness claim I can make without a Windows GPU.
zig 0.17.0, commit6cfe3fdbbwith base0900b484e, host tests only, no GPU and no checkpoint.core/Checkpoint.releaseandcore/Checkpoint.releaseExcept(every family and backend that reads through core's loader —flashnext/hip/engine.zig:170is the one livereleaseExceptcaller), andfamilies/qwen3_5/weights/checkpoint.zig's per-layerrelease, which the HIP loader calls once per layer (qwen3_5/backend/hip/model/weights.zig:226,234).corerelease tests, which still pass on a non-Windows host through the early return.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: n/a — no token can change, as argued above. The structural claim is tested instead:releasetwice on a buffer the process holds leaves every byte as it was (zig/src/platform/working_set_test.zig), which is the property that makes the trim safe to call under a live load.tools/bench_openai.py: n/a. Decode runs after the load, and by then the load's pages are released on both sides; the change moves pages at load time only.Checklist
working_set_test.zigrefuses to compile before the change (sys.working_setdoes not exist) and skips by name off Windows."draft": false, a resumed prompt equals a fresh one, and concurrent equals solo — unchanged by construction: no token path is touched.