Repository navigation
Conversation
|
Thanks @jschmied for C1 and for the planted controls behind every test. The admission logic reads well. When a family has no
This also needs #2415 to land first.
|
|
Thanks @jschmied. That identifies the disk store as #1411 and clarifies the #1411 → #2415 → C1 order, so no duplicate disk-store PR is needed. The other asks remain open as you noted: integrate retirement through the class-aware free path with one-/two-class tests, keep the no-hook admission path cheap, settle the refusal counter, and meet the file-size and current-main equality checks after the parents are ready. The existing #2415-relative receipts remain credited within that scope.
|
|
On The regression reserves one page in its owner class, takes it, retires it at reader token 18, then settles 17 and 18 in order. Before 18 the page stays out of the free stack. At 18, the class should regain one free page and one promise. Using main's retirement module as-is, that last class-free assertion failed. Both Igor Lessio - AIFLOW LABS |
a203fd1 to
9137646
Compare
9137646 to
a15cf1b
Compare
|
I checked #4466 at zig build test-kv-pool test-kv-safety-host test-glm-ring-host \
test-gradient-serving check-native-cuda-host -Dcpu=apple_m1 -j4 --summary allBoth runs passed all 30 steps and all 190 tests on M5 Max with Zig 0.17.0. The combined run passed the serving pins and compiled the Linux ARM64 CUDA native executable. The owner-class pool checks and GLM ring checks here use host fixtures. Igor Lessio - AIFLOW LABS |
|
I reran the checks on the new official train #4479 at zig build test-kv-pool test-kv-safety-host test-glm-ring-host test-gradient-serving check-native-cuda-host test-qwen35-hip-host test-native-hip-host test-draft-hip-host check-native-hip-host -Dhip=true -Dcpu=apple_m1 -j4 --summary allThis is the exact published train with no scratch edits. The checks use host fixtures. Igor Lessio - AIFLOW LABS |
|
I reproduced both red Linux GLM KV-split tests on the current Setting only zig build test-review-glm-kv-split -Dhip=true -Dcpu=apple_m1 \
-Doptimize=ReleaseSafe -j2 --summary allThe original trial separately passed 337 selected host tests with two skips and compiled both native CUDA and HIP. The one-line fixture adjustment leaves production code untouched. The head also trial-merges cleanly into Igor Lessio - AIFLOW LABS |
a15cf1b to
fb13fdd
Compare
|
I independently checked zig build test-kv-pool test-glm-regions-host test-glm-pages-host test-glm-snapshots-host test-glm-prompt-settings-host check-native-cuda-host -Dcpu=apple_m1 -Doptimize=safe -j3 --summary allThe trial merge into main zig build test-kv-pool test-glm-regions-host test-glm-pages-host test-glm-snapshots-host test-glm-prompt-settings-host test-env-defaults-host check-native-cuda-host check-native-hip-host -Dhip=true -Dcpu=apple_m1 -Doptimize=safe -j3 --summary allI also ran Igor Lessio - AIFLOW LABS |
fb13fdd to
00fb151
Compare
…re each byte sits in its lease The rows store's view of a GLM kept state, without the store: the words (format, position, head rows, ring bases, KDA copy bits), the KDA prefix, each DSA layer's latent rows, scales and whole pools by position, its rings and pools in progress as the state's own, the head's caches at a whole verify window (rows past the head's own read as zeros), then the tail. Copies run a page of the lease at a time. Nothing is wired to --learn-conversations yet.
…state on disk Rank 0's engine thread leases, fills, reads and seals each rank's copy through the follow link (cuda_disk_ranks: blank, put, take, seal, prefixes). The store's image is rank 0's image followed by each other rank's prefix, the one part a rank holds alone; the rest are the same bytes on every rank, checked at start by the identity probe. A blank state is refused by restore until its seal. A blank whose disk step fails on the link gives rank 0's lease back, and its id goes on the dropped list, so the next step drops it on any rank the step reached; the id is not used again. An NCCL failure there already ends every rank (the liveness lines), but a CUDA error in the step's launch or upload returns to the disk read, which tries one shorter state and then prefills while the server goes on. cuda_disk_ranks_test.zig runs the steps on host memory with a fake link: that failed blank, a blank state refusing bytes past its words and front until sealed (DiskOrder), each BadStep a follower refuses before its states or the link, and each other rank's shared bytes taken past its prefix and compared to rank 0's (RanksDiffer, in ranks.same, which the probe calls). attach's refusals of the shared store and of more ranks than prefix_buf holds (KvShareWithLearnConversations, TooManyRanks) have their own test in cuda_glm_disk.zig. link and prefix_buf stay process-wide: the process serves one model. With TF_GLM_KV_LIVE_HALF=1 a keep holds one KDA half and the disk image both, so GLM refuses --learn-conversations with it by name at startup (cuda_refusal.zig); the test that pinned GLM refusing --learn-conversations outright now pins that it takes the flag alone and refuses it beside live-half keeps. Rank 0's link becomes the disk steps' link in `follow.Link.lead` (which also sets whether the other ranks begin asleep), at TP only, and `Link.deinit` clears it, so cuda_native.zig stays at its 600 lines. cuda_disk_ranks_test.zig: one rank leaves the steps local, two set the link, another link's deinit leaves it, its own clears it; the test fails with the clear removed.
…sk state into that storage A family whose kept states live in preallocated storage it reuses (GLM's snapshot pages on CUDA) and cannot trim never had a disk read chosen: the selection counted its spare storage as fixed and its kept states as not reclaimable, so no state ever fit. Such a family's room for a read is now its spare storage plus what evicting unborrowed states frees, and a read is ready once the family says its spare storage takes the state, as a keep's admission already asks. Families with trim, or without reused storage, are unchanged.
…t, as before The disk read's early admission for a family whose spare storage takes the state now applies only to a family without trim, as the selection's capacity already does. A family with trim, such as Flash Next's or Qwen3.8-27B's pools on Metal, makes room for a read by trimming its spare storage and evicting, exactly as it did before, and a new test pins that its read stays within the budget when its reuses answers yes.
…he state's rows An index ring based at `base` holds the rows from `base` up to the state's position, and the image keeps at most a ring's rows of each. The seal now checks the words' main base against the state's position and the head's base against its rows, so an image whose words name a ring that starts past them, or too far back to be held, is refused before the blank state is made whole.
…/O worker GLM's store uses The write-behind gave GLM's store its own I/O worker, while the grid test wrote on the test's thread (sync_writes). It now runs on each, drained by write.drain, so a worker path that loses the grid's chunk starts fails the test.
…rn-conversations alone keeps its states Since ashhart#1413 CUDA serves --spill-gib and --checkpoint-slots, and --learn-conversations admits GLM, so --learn-conversations --spill-gib (or --checkpoint-slots) opened GLM and ignored the flag: its disk store writes every rank's part between passes and stages nothing at eviction. GLM now refuses both by name. Its store's spill stays off, since an eviction would gather on rank 0 mid-pass while the other ranks wait in the gate's all-reduce. docs/api.md lists every CUDA family that keeps states on disk.
…he shared-store refusal names TF_KV_SHARE - A kept state's device pages are read out with cuda.memory.download, which stages through the pinned buffer on an integrated GPU (ashhart#2103, ashhart#2289), as every other synchronous readback does; the copy back in stays a direct HtoD. - The refusal beside share_pages names TF_KV_SHARE, the switch behind it since ashhart#2211, in its message and comment. - The disk image test's driver answers cuCtxGetDevice and cuDeviceGetAttribute (a discrete card).
…e owner, and a read refuses another by name The image's words gain three: the ranks that wrote it, its layout and the rank that owns its latent rows. Every image is unsplit so far (every rank holds every row): it records this server's world, layout 0 and no owner. A read refuses words of another world (DiskWorld) or another layout, or an owner its layout does not have (DiskLayout), before the blank state is sealed. The words are 72 bytes, the seal step 18 words. ashhart#1431's split states fill the layout and owner without another format. A disk read forgets a state's file refused as DiskWorld or DiskLayout after one recall, as it does one refused as DiskWords (rows_read.refused); rows_refusal_test.zig's cases include both.
… attach, so a long state is staged whole cuda_glm_disk.attach opened the store with rows.Rows.open, which keeps the 1 GiB default staging permit and skips the floor rows.attach applies (the longest state's charge, within the RAM store's budget). At about 18.5 KiB a token that stopped every state past roughly 55K tokens: `imprint: saving 124928 tokens skipped (StagingFull)`, whatever --learn-gib said, and a long conversation was recomputed cold after a restart (found by crystal8194 on ashhart#1411). attach now goes through rows.attach, as Qwen 3.5 27B does, with `longest` the capacity's whole pools (`image.longest`, the last position `parts` takes; rows.attach falls back to the default when pricing it fails, so the position matters). Spill stays off and the slots unset, as before. The start-up line gains the permit: "a save stages up to N MiB". Tests: - test-cuda-disk-open-host: GLM's own open over a store of 18,944-byte tokens. A 124,928-token state's charge is past the 1 GiB default and within the permit, which is the longest state's charge; with a RAM store too small to keep the state the permit stays the default. It fails with the floor gone (the permit is 1 GiB). It prices the permit a save's stage step asks; it does not write 2.3 GiB. - The GLM set: `longest` is a position the store's parts take at capacities on and off a pool's edge, and the next pool past it is refused.
…id from one class, and one class is today's pool A pool can hold W owner classes (Pool.initClasses, Layout.classes): page ids c, c + W, c + 2W ... form class c, each on its own free stack, as DeepSeek's sessions pool books ids by residue (pg = local*W + r). A lease names its class (Lease.owner) and every id it takes, adopts or shares is of that class; a promise fails when its class lacks the pages, though another has them. The owner rule lives in one function: roomiest, the class with the most available pages, the lowest on ties (ashhart#1313's). fitsAny answers as a promise from it would. planClasses floors a plan's pages to a multiple of the classes and refuses a class that holds less than one stream's window (ClassTooSmall); plan's error set is unchanged, and at one class planClasses is plan for the same budget, the cache's slots and slots_only (ashhart#2358) included. The class book lives in kv_pool_classes.zig (planClasses, the per-class counts, roomiest, fitsAny and the stacks' push and pop, and the class tests' imports); kv_pool.zig keeps the fields and names them, and promise and hold keep main's reclaim walk (ashhart#2528's chain) as it is: the class test comes after it. Above one class, runs are refused (claimRun null, coverRun as cover), since a run spans every class, and so is a reclaim store: joinReclaim returns OwnerClasses, since a store's eviction frees pages of any class and a promise needs its own class's. Nothing joins one there today (GLM refuses TF_KV_SHARE with the split); the refusal keeps it so. One class is today's pool, id for id and in the same order: init is initClasses(..., 1), and a scripted run of promise, cover, trim, finish, hold and release gives the trace main records (pinned by its hash). kv_pool_trace_test.zig goes past that script on one class: 400 seeded steps on 32 pages through adopt, share, drop, runs, reclaims and a shuffled stack, every operation taking effect, its store joining as any store does (joinReclaim), its hash recorded on main's kv_pool.zig (ddd2df8, again on 9c9bf54, and on f03e5aa, after ashhart#2528's chain).
…t one rank, without pages or with host pages The switch for ashhart#1431's per-rank latent book: unset, 0 or off (the default) and 1 or on; any other value is refused naming the choices. Every rank resolves it inside the watched start, after TF_KV_PAGES: one rank is KvSplitNeedsRanks (checked first, since auto pages are off there), pages off or fp8 windows KvSplitNeedsPages, TF_GLM_KV_HOST KvSplitOnHost, and TF_KV_SHARE KvSplitShare (the store's pages come from any owner's class). The fingerprint carries it (layout 21), so ranks started with different values stop with kv_split named. Nothing books by owner yet: this commit only reads, agrees and refuses. Its rows: environment.zig checks the same four words as a glm row, when GLM's CUDA family opens on every rank, so a typo never stops another family (docs/environment.md; cuda_env_test.zig), and profile.zig registers it beside TF_GLM_KV_HOST for glm5_next, identical, 1 and on reported as set, evidence ashhart#2415, since it changes how pages are booked and how many streams fit (docs/profiles.md).
…s lie in two regions, each with its own table The pool's arena is the same bytes, laid out as two regions: every page's pooled keys first, a pooled part apart, then every page's latent rows, a latent part apart. Both strides come from the weights (the DSA layers and the head times a cache's part), so a thin model's pages are laid out alike. Each paged sequence gets a second table after its first (State.ltable), and Caches a second (pkt): the latent launches (lat_write, the dense and sparse chunks, and dsa_tokens' rows) take the latent table and stride, the pooled-key launches (pool_keys, scores) the pooled table and stride. No kernel or launch is new. attend refuses a pooled table without its own stride before it launches. Every rank still holds every row, so the latent table holds the same ids: TF_KV_POISON fills both parts of a page, and kept states copy the same bytes. Off, every launch argument, table write and fill is as before.
…wner's class, sent with begin and checked by every rank With the switch on, the pool has an owner class a rank (Layout.classes = TF_GLM_WORLD). Rank 0 picks a stream's owner when it opens, by the pool's rule (the class with the most available pages, the lowest on ties), and takes every page from that class; admission asks whether that class holds the request. begin carries the owner in its unused depth word, and every other rank checks each id is of it before it maps anything (ResidueMismatch, or BadStep for an owner past the classes). The pool step carries the switch, and a rank whose own differs refuses it (RankMismatch). Every rank refuses a pool whose class holds less than one stream's window (ClassTooSmall), and the plan floors the pages to a multiple of the classes and refuses such a class with its numbers; it plans from the budget main's plan builds, the cache's `slots` and slots_only (ashhart#2358) included. A request longer than a class is refused by name, never requeued. The lane cost cache keys its prices on the switch (keyShape's split word): under it the timing stream books its pages from a class. Every rank still holds every latent row, so the owner is bookkeeping only for now; the start-up line says so, and the idle line counts each class. Off, there is one class: ids, admission, begin and the pool step are as before.
…r classes, each prompt on one, the classes in turn The check resolves the switch as serving does (cuda_start.splitting, refused by name at one rank) and, with it on, makes an owner class a rank of two windows and a page over each. Each prompt's paged stream and the stream that shuffles its pages open on the same class, k % W for prompt k, so every class serves and its pages still come out of order (jumps counted by W). Every stream is compared with its twin on a whole window, byte for byte, and every class must be idle after. Off, the check is as before.
…th regions of every leased page, once A paged sequence on two regions (every page's pooled keys first, then every page's latent rows) and one on interleaved pages, both on ten ids out of order, at a length whose latent rows and pooled keys reach every page, with and without the MTP head. The split plan's paged pieces, counted on a map of the pages, read every leased page in both regions, each row's bytes exactly once, and nothing else (no overlap, none missed); the rows are placed from the geometry alone, not from the state's fields. With the same rows in both layouts (every row on every rank), the split plan's bytes, in its order, equal the interleaved plan's and so do the lengths. Both tests fail when the pooled parts step by the latent stride (x.ps) or the latent parts by the pooled one. glm_snapshot_host.zig is at 600 lines, so the tests have their own file in the same step.
…links, Header bytes and all, to a follower's loop Rank 0 is a Leader on the pages' fake engine with a Link on host memory: Leader.pool and Leader.beginOn encode through Link.send's put path (tf_glm_put_words run on the host, word for word) and a host NCCL that keeps each broadcast. The pool step's 64 bytes carry the switch in flags, and begin's carry the lease's owner in depth, with its ids after; off, both are byte for byte the headers main sends (flags 0, depth 0). A second rank decodes them in follow itself, through Link.receive: its pool books an owner class a rank, and slot 1 maps rank 0's ids under that owner. A begin whose owner on the wire is not its ids' class is refused (ResidueMismatch) with nothing mapped, and a follower started without the switch refuses the pool step (RankMismatch) and makes no pool. Mutants, each alone: begin's depth left 0, the pool's flag dropped, the follower's begin calling map (owner 0) and its pool step ignoring the flag; each fails at least one of the three tests. The pages' split test's Fake is made pub for it.
…ions, each with a control given the other table No launch is new, so glm_cuda_records.zig is unchanged; what the split changes is the geometry the eight paged launches meet. contract_glm_pages.zig gains Geometry: in an arena of n pages, every page's pooled keys first (2 x 32,768 bytes apart), then every page's latent rows (2 x 524,288 apart), the second cache tested. With regions on, tf_glm_lat_write and tf_glm_chunks_16/32 (dense and sparse) take the latent region's table and stride, tf_glm_dsa_tokens rows of that stride (1,024 a page, not 1,088), and tf_glm_pool_keys and tf_glm_scores the pooled region's. Off, every argument and byte is as before. contract_glm_regions.zig's Set holds the eight cases at either geometry; contract_tests.zig registers the eight on two regions (2 lines), and Controls now holds both sets as controls (8 -> 16). A region control gives each launch the other region's table, a second shuffle of the same pages that differs at every entry (sparse chunks: token rows read through it), so its rows land on or come from other pages. glm-index-check gains a paged case at the pooled stride (12 x 32,768, which tf_glm_index_scores' fast path takes) with a latent table of its own for the token lists. docs/kernel-contract.md says so. Host tests (test-glm-page-contract-host, 3 -> 5): sixteen controls, the last eight on two regions; a disabled control in either set is refused; the region cases register apart from the interleaved ones at the same served shapes as their controls; the regions fill the interleaved arena exactly, pooled keys first, and off places everything as before; a region control's table differs at every entry (1-11 pages, 64 seeds each). Mutants, each caught: the fix-up of equal entries dropped, the latent rows placed at the first cache, Set ignoring regions, the region controls not planted. The GPU gates (each case green, each control red) are not run here; the contract's body cross-builds for aarch64-linux with empty images (-Dfatbins, -Dcontract-controls), which is what analyzes it.
Main's retired pages now return through the owner classes' push, so a class's free count stays true. With one class the stack is the same, id for id. The rank agreement's layout goes to 23: main's 22 has draft_split and this series adds kv_split. claimAt moves to kv_pool_classes.zig to keep kv_pool.zig within 600 lines.
GLM's state arena moves to cuda_state_arena.zig, and one cache-default test moves beside the other capacity tests. Neither changes behavior.
…sen once inside the reservation Admit.need gives the pages a request needs a class (kv_classes.Need: one, or a spread for admission only). The lane host tests it in its ledger beside the family's fits, and refuses a request past a whole class by name even while other streams run. Gate.want takes a class, so a promise passes its class's test with the pool's bytes inside it. Pool.reserve picks the owner (a resumed prefix's class, else the roomiest) inside the reservation, and a failed one leaves the owner and every count as they were. No multi-class reclaim: joinReclaim still refuses above one class. At one class every answer is ashhart#2415's: the ledger-counted pool trace hash is the one ashhart#2415 records.
…ane busy, no class hook refused, one notice a reservation A request past a whole owner class is refused at takeJob before a lane is asked for (lane_host_admit.refused), not only once one frees; requests waiting for a read or a prefix cut, or already cancelled, are left to their own path. Ledger.ofPages refuses a pool of several classes without the class hook (NoClassHook) instead of reading the whole pool as each class, and a resume's class the pool lacks never fits and is refused. Pool.reserve is one pool change: a failed reservation notifies once, with the owner already restored. One class: no answer changes.
00fb151 to
ec4aea0
Compare
|
Thanks @jschmied. The class-aware
That test pins the original bug where direct free-stack writes updated the total count without updating the owner class. The current production path looks corrected; this request is for the missing regression, not another runtime change.
|
…ts owner class, one and two classes
|
@ashhart Added the regression in
Planted controls, each red, then green with the file restored (
|
|
Thanks @jschmied. The new regression covers one and two classes, including class 1, pending settlement and immediate return. It answers the remaining test request, and the runtime/accounting fixes are present. We still need current-main default reply hashes and GLM split, concurrent/solo and resumed/fresh results. The older served table compares with the parent. We will handle the main integration, preserving its newer page-free and disk-transfer behavior.
|
Roadmap #2444, P1 item C1, as agreed in issuecomment-6936659313. Base: #2415 (wojo's
up-kvsplit2, now at5af6a50f86, carried here as rebased onto main). This PR is the top six commits: C1, the review fixes, ashhart's three rebase commits and the retire→settle regression. Head706ae4ba6563cbe7c6f657048d45dbc7211e1d9d. It lands after #2415. Design: issuecomment-6928646545.Review (2026-11-24): retire→settle by owner class
Head
706ae4ba6563cbe7c6f657048d45dbc7211e1d9d, one test-only commit on ashhart'sec4aea0f43. That head is his rebase plus "rebase: keep no-hook admission cheap". No runtime change.kv_pool_class_test.zig:240runs throughPool.initClassesat one and two classes; with two, the page belongs to class 1. The test reserves and takes one page, retires it at reader token 18, and settles 17, then 18. After 18, the owner class has one more free page, the lease and the class each hold one promise again, and the next take returns the same id from that class. A second retire after 18 covers the immediatefreeOrPendpath.kv_pool_retire.zigsettleandfreeOrPend), each red, then green once restored:settle: 6 fail, including the new test;settle: only the new test fails;freeOrPend: 7 fail, including the new test.test-kv-pool124/124;zig fmt --checkandgit diff --checkclean;tools/pr_check.py0 errors, lean 165 = 165. Full x86 CI set: green (test-host test test-golden test-kernel-contract test-server-security test-pull-security fuzz-cortheon check-release-paths2455/2455 steps, 24966 passed, 157 skipped;check-native-cuda-host compile-cuda-tests17/17; lean 0 new).cuda_disk_image.zigand others) that landed after the rebase. It has not been rebased; that waits for your ask.Rebase (2026-11-22)
Head
00fb1516d2ceb61236186e6f9c55133c622a1af9, rebased onto maine6094de132on the user's request. Before that, ashhart rebased it tofb13fdde6dfor train #4479, which is now closed. Both of ashhart's commits are kept: "rebase: adapt admission and launch recording hooks" and "rebase: keep lane_host at 600 lines". The whole stack moved as one: #1411's and #2415's commits as #2415 carries them (#2415 head5af6a50f86), then C1.families/glm/cuda_env_test.zig. Main'sTF_GLM_INDEX_SPLITstays inadded, and this stack'sTF_GLM_KV_SPLITkeeps its ownsplitsrow beside it. Both have their tests, and the count test adds both lists.fb13fdde6d's base, main touched one file of C1's diff,native/cuda.zig. Those changes are the load-time pool read (poolCached, no page drop before a GB10 load) and do not touch theAdmitwiring. No admission, pool or ledger file moved, and no.cuchanged. Because the only conflict is in a test list, the host tests below are the evidence for this head. The device and served rows below are carried.00fb1516d2(GB10 host, Zig 0.17.0):test-kv-pool test-kv-safety-host test-glm-ring-host test-glm-regions-host test-glm-pages-host test-gradient-serving check-native-cuda-host test-glm-rev25-host test-glm-admission-host test-glm-snapshots-hostgave 45/45 steps and 271/271 tests. Also clean:zig fmt --check,git diff --check, andtools/pr_check.py --base origin/main(0 errors, lean 165 = 165, 0 new).a203fd1af0(base GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415af17f6c8fc). AIFlowML checkedfb13fdde6don M5 Max (issuecomment-7076532350): 183/183 tests and the ARM64 CUDA server compiled. The planted-control logs and the full CI set (golden, cuda-host, x86) are also froma203fd1af0. GLM TP=2 still needs your pair.Review fixes (
a203fd1af0, a new commit on top of3c648fed3c)Each finding was first shown by a test that fails on
3c648fed3c(red-c1/r2-confirm-3c648fed3c.log). Each fix is then green, and each new test is red again against its planted control (rows r1-r3 below).pickreturned null once the lanes were full, soneverwas not asked. With one lane and one long stream,one(9)on classes of 8 stayed queued until that stream ended. NowtakeJobfirst asksadmit.refused(lane_host_admit.zig:26) under the host lock, whether or not a lane is free. That pass skips requests that wait for a disk read or a prefix cut, and requests already named incancels. The refusal is the sametoo_big_classpath as before, before any promise or copy. WithoutAdmit.need,pastClassis false at once, so every family except GLM, and GLM at one class, answers as before. Test:kv_classes_host_test.zig:172.Ledger.ofPagesnow returnsNoClassHookfor a pool of several classes without the hook (kv_ledger.zig:36;countPoolnames it too), andkv_classes.classhas no whole-pool fallback. Aone.inpast the pool's classes (kv_classes.zig:40) never fits, andneverNeednames it, so it is refused, not indexed. Test:kv_classes_test.zig:298.reservesetl.ownerand calledpromise. That call is a whole pool change, so its notice fired before the owner was restored.reserveis now one outer pool change (kv_pool_classes.zig:61), and the notice fires once, after the rollback. Test:kv_classes_test.zig:272, an observer that recordsl.ownerat notice time.What it does
core/kv_classes.zig(new, 86 lines):Need=one{n, in}(allnpages from one class;inset when a resumed prefix fixed the class) orspread{k0, k1}(logical page k in class k mod W, DeepSeek's span).spreadis admission-only in P1: a lease still holds oneownerandtakepops from it. AlsowantIn,fitsNeed,neverNeed, all read through the ledger.Gate.wanttakes(class, n)(kv_pool.zig:210,:305).promisemakes one test, its class's, with the pool's bytes inside it (kv_pool.zig:379).holddoes the same (:391).nullis the whole pool, whichfitsandreclaimForuse as before.Pool.reserve(kv_pool_classes.zig:56) chooses the owner inside the reservation, once. It takes the class of the pages the lease already holds, else the resumed prefix's class (in), elseroomiest. It then promises in the same call. If that fails, the owner and every count stay as they were, and the whole reservation is one pool change, so the change notice fires once, after the promise or the rollback. A lease never moves class (BadClass). GLM'sopenOwned(families/glm/cuda_pages.zig:223-234) now passesnullinstead of choosingroomiest()beforepromise. A resume's adopted pages fix the class, and adopted pages from two classes are refused withResidueMismatch. Before, adopting into aroomiestlease of another class hitowned()'s panic.cap/availablethrough a newCounted.classhook (kv_ledger.zig:22). The hook is null at one class, andlane_host_ledger.countsets it above one class (lane_host_ledger.zig:36);Ledger.ofPagesrefuses several classes without it (NoClassHook,kv_ledger.zig:36).Admit.needis optional (engine_api.zig:251). When set, admission asksfitsNeedbeside the family'sfits(lane_host_admit.zig:69,lane_host_ledger.zig:105). GLM sets it (kvNeed,families/glm/cuda_native.zig:124, wired atnative/cuda.zig:442). No other family does.never(lane_host_ledger.zig:85) now returns why. A need larger than a whole class is refused withtoo_big_class("…exceed one whole KV owner class (TF_GLM_KV_SPLIT)…") atlane_host.zig:360. It fires even while other jobs hold pages and every lane is busy (lane_host_admit.zig:26, asked beforepickatlane_host.zig:356); before,neverfired only with nothing outstanding. GLM'sPages.fits(cuda_pages.zig:196) no longer answers true for such a request; the lane host refuses it before any promise. GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415'scuda_pages_split_test.zig:278asserted the oldfits == true, so it now asserts!fits.openstill returnsClassTooSmallfor it.joinReclaimstill refuses above one class (kv_pool.zig:400-401, unchanged). Above one class,fitsNeedcounts no reclaimable pages, so admission's answer is exactly whatreservewill do. The interleaved test checks this at every step.Not here, as agreed: rank classes (DeepSeek's per-rank
usable) and host frames (#1501/#1522) wait for their first user. HIP'spages.Idswaits for P7. No kernel, Metal or HIP change.kv_pool.zigstays at 600 lines.Host tests, each red against a planted control
All in
zig build test-kv-pool(80/80 green on the head). Tests 1, 2, 4, 6, inv and rb are in the pool+ledger module; 3 and 5 run through a realLaneHostover the fake target, with the pool counted in its ledger. The control is the fault planted at the cited line. Receipts are inred-c1/, one log a control, and each one fails exactly the test named.kv_classes_test.zig:42classes of 6 and 2 available,one(7)waits, though 8 are freefitsNeedreturns true past the bytes test (kv_classes.zig:61)kv_classes_test.zig:61W=2 spread needing {3, 2}, class 1 at 1 available, waitskv_classes_host_test.zig:160one(9)against a class of 8 is refused at once by name while another stream runs, with nothing promised or taken for it; at one class of 16 the same request runsneverNeedon totals (kv_classes.zig:80); (b) refused only when idle (lane_host_ledger.zig:92)kv_classes_test.zig:78each class's census is idle after takes, trims and finishesshrinkskips the class count (kv_pool.zig:505)kv_classes_host_test.zig:180a head that needs class 0 (fixed) lets a later class-1 request go first, never reaches a failing reservation, and runs once class 0 has roomlane_host_ledger.zig:107)kv_classes_test.zig:264one class counted in a ledger with bytes beside it: 3000 seeded steps, every count andfits/wantanswer hashed. Hash0xf005c622d55ebd68was recorded by the same walk on #2415's headaf17f6c8fc(promisethere,reservehere). At each stepfitsNeed(one(k)) == fits(k),wantIn(0, k) == want(k)andneverNeed == nullkv_pool.zig:415, asksninstead ofwant)kv_classes_test.zig:124interleaved two-class sequences (W=2 and W=3, 3 seeds, 600 steps, a bytes lease beside). After every step: class promises sum to the pool's promised count, and no class promises more than it holds free. A lease's ids are all of its class. For a new lease,fitsNeedpredictsreserveexactly. A failed reservation leaves every count and the owner unchangedpromiseskips the class count (kv_pool.zig:381)kv_classes_test.zig:175a failed reservation, a cancel mid-stream and a requeue (promised, nothing taken) each leave every count and the owner as they werereservekeeps the failed owner (kv_pool_classes.zig:65)kv_classes_host_test.zig:172lanes=1, one long stream holds the lane:one(9)against a class of 8 is refused by name before that stream is cancelled, nothing promised or taken for itpick(lane_host.zig:356)kv_classes_test.zig:298two classes without the class hook:ofPagesgivesNoClassHook; a resume's class 2 on a pool of two never fits andneverNeednames itkv_ledger.zig:36); (b) no class bound (kv_classes.zig:45)kv_classes_test.zig:272a failed reservation notifies once, and the observer sees the owner already restoredreserve(kv_pool_classes.zig:61)#2415's own pinned hashes are unchanged and green on this head:
kv_pool_trace_test.zig(0x9289b00642a64c9) andkv_pool_class_test.zig(0x6a51e5e6ca5c61f6).One class changes nothing
Every comparison here is against #2415's head, not against main, because this PR is stacked on #2415. #2415 itself conflicts with main (CHANGELOG, docs,
engine_api.zig,kv_pool.zig). The review commit adds one more, inlane_host_admit.zig: main's newholdand ourrefusedsit at the same place, and both stay. Once #2415 lands or is rebased, we will rebase this branch on it and rerun every row.wantIn(0, n)iswant(n), theCounted.classhook is null,neverNeedis null, andfitsNeed(one(n))isPool.fits(n). Test 6 checks all of these at every step, and its hash equals GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415's..cuchange.zig build fatbins -Dnvcc -Dsm=121on GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415's head and ona203fd1af0(and before on3c648fed3c): 114 of 114 fatbinscmp-equal. The native binaries differ (md56b8834cbon GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415,eb79fbe4on3c648fed3c,9bc5e4b6ona203fd1af0).--parallel 4 --context 8192, 8 concurrent greedy chats of 400 tokens, page cache dropped before each start): 9 cells, base binary6b8834cbvs head binaryeb79fbe4:promised 0, free 132 == total 132bothTF_KV_SHARE=8promised 0, free == totalbothTF_QWEN_KV_PAGES=256 TF_QWEN_KV_SHARE=32free 51 == total 51; slots free 55 + held 9 == 64bothfree 68 == total 68(head printed it twice*)free 132 == total 132bothTENSORFOLD_DORY_KV_PAGES=1free 128 == total 128bothTF_FLASHNEXT_KV_PAGES=25672 of 72 replies are hash-identical. The hash covers reasoning and content, and every reply has more than 100 characters.
* These follow the free memory read at load, not the binary. We reran these three cells in A-B-B-A order (head first, then base first). #2415's own binary gave Gemma-share pools of 2197, 2198 and 2205 pages, a Spark2.5 cache of 50.1 or 50.0 GiB, and the mid-run idle census once or twice. Each head figure fell inside that spread, and replies were identical in every run. C1 changes no planning code. Receipts:
runs/c1-gate2,runs/c1-gate3a,runs/c1-gate3b.Review fixes, served (
runs/c1r2-gate): the C1 binary before the fixes (eb79fbe4,3c648fed3c) vs9bc5e4b6(a203fd1af0), same flags. Each server answered greedy and seeded (temperature 0.8, top_p 0.95, a seed a prompt) at c=1 (4 chats in turn) and at c=4 (8 chats, 4 at once), 24 replies of 400 tokens:72 of 72 replies are hash-identical (reasoning and content hashed, every reply over 1400 characters). In each arm, the c=1 reply to a prompt also equals its c=4 reply, greedy and seeded. * This is the free memory read at load again; the A-B-B-A above showed the same spread on #2415's own binary.
Verification on the head
Head
a203fd1af0, merge base #2415'saf17f6c8fc:test-kv-pool80/80.test test-golden: 699/699 steps, 8056 passed, 52 skipped.test-cuda-host: 393/393 steps, 982 passed, 11 skipped.test-kernel-contract,test-server-security,test-pull-security,fuzz-cortheon: green.-Dtarget=x86_64-linux-gnu)check-native-cuda-hostandcompile-cuda-tests: green.-Dfixed-cpu):test test-golden test-kernel-contract test-server-security test-pull-security fuzz-cortheon check-release-paths728/728 steps, 9611 passed, 69 skipped;check-native-cuda-host compile-cuda-tests16/16;zig fmt --checkclean.test-hostis not on this branch: it came to main after GLM on CUDA: the latent split's per-rank page book and owner (TF_GLM_KV_SPLIT, #1431 part 1; stacked on #1411) #2415's merge base223da7659b, so it runs once the stack is rebased.tools/pr_check.py: 0 errors.zig fmt --check,git diff --check: clean.3c648fed3citself.Proposed CHANGELOG line (for you to place)
Pool.reservepicks a lease's owner class once, inside the reservation (a resumed prefix's class first). A request is admitted only when its class holds its pages, and a request past a whole class is refused by name even while other streams run. One class behaves exactly as before.For your two-GB10 pair
Please compare #2415 (
af17f6c8fc) with this head under GLM TP=2, withTF_GLM_KV_SPLITunset and set:too_big_classwhile others run, also with every lane busy;ResidueMismatch, not a panic;free + 0 of cap.With the flag unset, token hashes and the startup line should be identical. We have one GB10, so GLM TP=2 was not run here.