Skip to content

train 1124065029: #2415 #2781 #2808 (CI only) - #4845

Closed
ashhart wants to merge 27 commits into
mainfrom
lead/train-1124065029
Closed

ashhart wants to merge 27 commits into
mainfrom
lead/train-1124065029

Conversation

@ashhart

@ashhart ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

CI for a landing train: #2415 #2781 #2808 stacked on main in that order. Nothing merges from this PR: each PR above lands on its own once this tip is green, and this PR is then closed.

wojo and others added 27 commits November 24, 2026 06:50
…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 (#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 (#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 (#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 #2528's chain).
…t one rank, without pages or with host pages

The switch for #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 #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 (#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.
… main does

image_decoder.zig pulls in geometry.zig, which on main reads core.safetensors, and image_decoder_test.zig runs in
test-h3-geometry, whose module imports core alone, so the decoder's files read st from core.safetensors.

The tool also writes PNGs with MOSS-Image's writer, whose test reads core/picture/png.zig by path, and a file may sit
in one module of a build only. So the tool's core is h3_decoder_core.zig, one module holding safetensors, core's
pictures and that writer, in place of picture_writer.zig; it resamples through core.picture.
…load's io, and H3's Metal tools in h3_metal.zig

Main moved H3's safetensors import into the core module (h3_core in metal_targets.zig, core in h3_host.zig). This
series came from before that move: tf-h3-image imported safetensors and checkpoint_fixture modules of their own. It
now imports core and reads both from it, since a file may sit in one module of a build only and core holds both.
Main's h3.Model.load also takes the process's io now, so tf-h3-image passes init.io as tf-h3-dit does.

Main's metal_targets.zig is at the 600-line cap, so tf-h3-image's target, and main's tf-h3-dit beside it, move to
h3_metal.zig with the H3 modules they share (and the kernel sources they take); metal_targets.zig calls it in one
line (589 lines). The steps and their modules are otherwise unchanged.
…trations and ten planted controls; four kernels reserve their group sizes
…istrations and fourteen planted controls; hp_attention's padded last key is a known finding
…infinite last value stays infinite; its contract entries lose their known finding and gain a control
Format only: combine the existing mixed-kernel predicates after main filled the runner. The short-circuit and append behavior are unchanged.
@ashhart ashhart closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants