Repository navigation
Conversation
core/state_walk.zig: a family's live parts in order, walked onto kept bytes (one buffer or pages leased from a kv_pool) through one backend copy hook. GLM CUDA's Plan parts, page lease and Pool.move are the core's; the copies are main's (dst, src, length and order).
snapshot.copy and spill build their parts over Walk(Ref, Ref.at); the hook is the copy_u32 dispatch they used. Kept bytes stay in the state's buffer.
|
Thanks @jschmied. The copy oracle, the same 1.6 million copies in the same order over 20,000 plans, pins the walk well. Here are the GLM resume gates, main's binary against this PR's, greedy, with At TP=2 on two GB10s:
On a Mac with a GLM checkpoint: resumed equal to cold, a spilled state restored equal to fresh, and two streams resuming at once, each equal to its solo reply. You don't have these checkpoints, so we'll run the GB10 cells; that job is being written. It stays a draft until then. It also conflicts with #2181 on |
|
Thanks @jschmied. #2211 has since moved GLM's page-sharing prompts to Two small things while it waits on the GLM resume gates:
For the record, #2211 changes our 5 Nov gate list in three places:
#2181 hasn't landed yet, so that conflict is still ahead for whichever lands second. |
What this changes
Today about 25 snapshot files each have their own packing loop. Each one splits its live pieces where the pages
end and copies them, on CUDA, on Metal and on HIP. This PR moves that loop into
coreand puts GLM on it, on bothbackends. Nothing changes in kernels, flags or allocation, and the copies are main's.
Two commits on main
8094ec962:bc41d9861core: one walk for kept prompt states, GLM CUDA's snapshot pages on it980f9a9c5glm metal: kept-state copies and spills through the core walkIssue: Refs Metal: KV pages from the core pool #1293 (step 4, the walk first).
Stacked on: main
8094ec962, two commits.atc overlap --json: one conflict, glm:TF_GLM_KV_LIVE_HALF=1keeps the live half of the KDA state alone in a kept prompt state #2181 (volfco,TF_GLM_KV_LIVE_HALF) onglm/cuda_snapshot_layout.zig. Whichever lands second rebases; the walk'sPartlist takes a live-half part the same way. Every other shared file merges cleanly.What moves to core (
core/state_walk.zig, 164 lines with tests)Walk(Live, at)works over any live address: CUDA device pointers (Device) or MetalRefs.Part{live, len, span, page, from}is one live region.spanandpagedescribe a sequence on pages;fromskips the pages a page-sharing store already holds.each(parts, ids, kept, ctx, hook)copies every part in order. It splits each one where a live page or akept page ends, then calls
hook(live, kept, n).Keptis where the kept bytes go: one buffer, or pages leased from a corekv_pool.Pool(
lease,rounded,page).The GLM pilot
cuda_snapshot_layout.zig,cuda_snapshot_pages.zig,kept.zig):Plan's parts arestate_walk.Device.Part.Pool.takeislease, andPool.moveiseachwith acuMemcpyDtoDAsynchook.TF_KV_SHAREwithTF_KV_PAGES=on(prompt rows held as the store's pages) is the descriptor starting atfrom.snapshot.zig):copyandspillbuild their parts overWalk(Ref, Ref.at).copy_u32dispatch these functions alreadyused.
Checks on this head
Head commit:
980f9a9c5.Lean checker on the base and on this head: 425 and 425, 0 new.
Copy oracle (GB10): main's
Pool.moveloop (fromcuda_snapshot_pages.zigbefore this PR) against the corewalk on 20,000 random plans (paged and unpaged parts, shuffled lease ids, both directions). Every copy is the same
(dst, src, n) in the same order: 1,601,972 copies, 1,211,205,736,238 bytes, hash
3311f711a06ed690.GB10, on
980f9a9c5:test-glm-snapshots-host20/20, including the byte-for-byte restores through the host-RAM pages and throughshuffled sequence pages.
test-glm-expiry27/27,test-learn-recovery503/503 (550/550 in that build).zig build testRC 0;test-kernel-contract test-golden test-server-security test-pull-security fuzz-cortheonRC 0 (server-security 24/24);
git diff --checkclean; lean 0 new (425 on the base, 425 on the head).Mac (M3 Pro), on
980f9a9c5:zig build test669/669 steps, 9,033 of 9,099 tests passed, 66 skipped, 0 failed.check-glm-restore-hostpasses (main'sglm/vision.zigimport error is gone since16f200f7d), and so dotest-glm-expiryand 36 moretest-/check-/compile-glm*host steps, among them scheduling 48/48, disk-charge47/47, snapshots 20/20 and window-contract 19/19.
CI: the no-GPU set above is green on the GB10.
Not run, and why: neither box has a GLM checkpoint, so the checkpoint gates did not run:
The equivalence rests on the copy oracle and the host restores above.
Receipt
8094ec962+ this PR; Zig 0.17.0; GB10 (sm_121, CUDA 13.0) and an M3 Pro.TF_KV_SHAREpages) and on Metal (copy and spill). The host gates and the copy oracle ran; the checkpoint paths could not.token_shawithout a GLM checkpoint.Next (order from the RFC)
joinandkv_prompts.Blobas a kept layout.TF_KV_SHARE.Decided on #1293:
joinwill be opt-in per family, in step 1 of the order above. A family that turns it on is gated on "bytes equaland resumed equal to fresh" rather than "copies equal".
The GLM resume gates are still open: neither of my boxes has a GLM checkpoint. As you suggested, we'll work out
that check from here.