Skip to content

CI receipt: portable session tests on the corrected stack - #12

Draft
cwschroeder wants to merge 26 commits into
upstream/main-20261016-c7137bbfrom
fix/sessions-portable-nvme-test
Draft

cwschroeder wants to merge 26 commits into
upstream/main-20261016-c7137bbfrom
fix/sessions-portable-nvme-test

Conversation

@cwschroeder

@cwschroeder cwschroeder commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

CI receipt for exact commit dcdc30c9e79046ccfd7605bed34dccb04b5c259d, with the session stack at 2cf61d3c over upstream main c7137bb3. The delivery PR is jayleaton#3 against stack/04-sessions; its workflows require approval in that fork.

This PR runs the same current-head checks in Christian's fork, including the Linux session/NVMe tests. The only change above JJ's current stack is the OS guard on the Linux NVMe lane test. Do not merge this CI receipt into the fork's main branch.

Real Mac results so far: session target 8 passed, 1 Linux-only skip; whole-tree host build 162/162 steps, 2009 passed and 8 skipped; native build 45/45; whole-tree formatting clean; lean 527 inherited findings on the base and candidate, zero new. Server goldens pass 4/4 steps; fuzz passes 3/3 steps and 8/8 tests. Zig 0.17.0, M5 Max, macOS 26.6.2. No model-serving or transport receipt is claimed.

jayleaton and others added 26 commits October 15, 2026 08:06
…alls them.

graph_cache.Cache captures one executable graph per caller-named key and replays it when the key comes back; ranks agree on every capture, eviction and fallback through an Agree hook, and a memory floor turns misses eager.
arena.Arena sub-allocates DeviceBuffer.alloc from a few large chunks (VMM or plain cuMemAlloc) through memory.setHook; borrowed spans and pointers it does not own are freed as before.
…; CUresult names fall back to a table when the driver cannot answer.

cuFuncGetName is optional (CUDA 12.3+), so an older driver still opens. During
the exit's teardown cuGetErrorName fails too, which printed
CUDA_ERROR_DEINITIALIZED as "CUDA_ERROR_UNKNOWN_CODE (4)"; code 4 now says the
process is exiting.
Use CUDA device attribute 110 for GPUDirect RDMA with VMM support. Attribute 126 reports the memory sync domain count and can incorrectly enable the RDMA allocation flag. Add a regression for the external ABI contract.
…r stays under the max, a max of 0 is eager

- A capture whose agreement throws, or whose insert runs out of memory, no longer leaks its executable: the map's
  slot is reserved before the capture, and the executable is owned here until the insert, which cannot fail.
- A host map that cannot grow counts as no room in the existing room vote, so every rank declines that miss together.
- `min_keep` is clamped to `max`, so under the memory floor the cap never rises above the configured max. A max of 0
  runs every step eagerly, with no collective.
- A cap lowered to 0 under the floor goes back to max once every rank has room, instead of staying eager for good.
- Hits make no collective: with `Agree` set, keys, settings and fingerprint changes must already match on every rank.
  The docs now say so: the fingerprint changes at the same step on every rank, and `fingerprintOf` is for one rank.

Co-authored-by: Jonathan Regan-Beasley <[email protected]>
The arena's `live` (small ranges) and `large` (own chunks) maps drop an entry on every free and gain one on every
allocation for the life of the process. std's tombstones never clear, so in time they take every free slot, and each
allocation, free and miss then probes the whole map. Each map now counts its removals and is rehashed in place once
they reach a tenth of its capacity.

Test: 20,000 random allocations and frees (small ranges and large chunks) keep a tenth of each map free at every step;
without the rehash it fails.
…amily that installs it, without a rebuild

Cache.init applies the operator's value through Settings.operator, so a deployment that measures graphs slower
can turn them off at serve time. The value is read once a cache, and is set alike on every rank like the
settings themselves: no agreement is added, and hits still make no collective.
…at start; RUNBOOK says what a mismatch does

An off cache never calls Agree, so a rank left on waits at its first miss for a vote that never comes. Settings.effective
applies TF_GRAPH_CACHE, clamps min_keep and maps every off cache (0, off, OFF, a max of 0) to one value; Cache.init runs
with it, and Settings.digest gives ranks those bytes to compare before building a cache. Hits still make no collective.
…d RoCE collectives, plan link, fail-fast.

zig/src/fabric/tp brings a rank up from TF_TP_WORLD, TF_TP_RANK, TF_TP_MASTER and TF_TP_PORT, agrees the settings
digest over every rank, and gives a family all-gather, all-reduce and broadcast over NCCL (TF_COMM_BACKEND=nccl,
the default), a pinned host mailbox for ranks on one host, or RoCE verbs between two hosts (TF_TP_ROCE_*), with an
NCCL fallback when RoCE setup fails. Rank 0 sends each round's plan to the others over its own link (TF_TP_PLAN_*).
A failure or a vanished rank ends every rank shortly after (TF_TP_FAILFAST, TF_TP_FAILFAST_GRACE_S).
No family uses it yet. zig build test-tp runs the host tests; zig build tf-tp-test builds the two-GPU runner
(-Dtp-nvcc= or -Dtp-fatbin= for the mailbox kernel). The RoCE all-gather adapts b12x's RoCEnante protocol.
… the stop word with no fail-fast exit; a rank killed mid-drain still fails the other fast.
… /24 the peer also has

The automatic pick took the first N active RoCE ports in device-list order and never checked that the peer can reach
them. On a host with two neighbours, one picked port can sit on a subnet the peer does not have, and the queue pair's
RTR step then fails, which reports RoCE unavailable.

Every rank now sends its usable ports' IPv4 addresses over the bootstrap. Each rank then keeps the ports whose /24 the
peer also lists, ordered by subnet and each /24 no more often than both sides have it, so both ranks pick the same
number. With no shared /24 the old first-N order is kept, with a warning to set TF_TP_ROCE_HCA. The exchange runs on
every rank, including ranks that set TF_TP_ROCE_HCA, so the bootstrap stays in step.
…FNAME and TF_TP_MASTER are needed, with a two-host example
… kernel backends up front; run_hosts.sh passes HCA picks

- `tf-tp-test kernel` reports the embedded kernel and exits 1 without one. `suite` and `failfast` on the mailbox or
  RoCE backend stop at once with a message that names `-Dtp-nvcc`, instead of failing later on a missing kernel.
- `run_hosts.sh` stops before any step when the kernel is missing. It exports TF_TP_ROCE_HCA and NCCL_IB_HCA (derived
  from TF_TP_ROCE_HCA when unset), warns when a host has more than one RDMA device and neither is set, and records all
  three variables in host.txt.
… with another region layout are refused

roce_guard.stripes computes each HCA's share of a post (its send stripe, the peer's receive range and its flag word)
and refuses with error.OutOfRegion any range past its slot, its flag area or the registered region, before
post_send. The verbs wire and the shm wire both post through it. The shm wire moves to roce_shm.zig and can stripe
like the verbs wire (Options.shm_stripes), with an optional tap that sees every post for tests. The connection record
carries the slot and registered length, so a peer with another layout is refused at connect; its magic is bumped.

Tests: stripes tile the slot over two HCAs and refuse a post past the slot, a third slot, an unpadded or empty post,
no HCA and a short region. On fake verbs a post past its slot reaches no verb, and a full slot stays inside the
region. Over the shm wire striped as two HCAs, 2,000 variable-length gathers stay inside slot and region, bit for bit.
…would ask for one

A post of about 9.6 MB faulted a DGX Spark's HCA. roce_guard.max_write (1 MiB, a constant) is checked in stripes()
before the slot bounds, so the verbs wire, the shm wire and the proxy refuse a larger post with error.WriteTooLarge
before any verb, whatever the slot size. Roce.init refuses a slot past it. Config.parse fails boot with a clear
message when TF_TP_MAILBOX_MAX_KB would make the RoCE slot pass 1 MiB; the value is never clamped.

Tests: a 9.57 MB and a 1 MiB + 16 post are refused in a 10 MiB slot and reach no verb, a 1 MiB post goes out; boot
refuses TF_TP_MAILBOX_MAX_KB 1028, 2048 and 16384 and keeps 1024.
…sized ops, at most 2 MiB in flight

Default off. allGatherV strides past the slot, up to TF_TP_ROCE_CHUNKED_KB, go RoCE as ceil(n / slot) launches of
the tp_roce kernel: op c moves at most a slot of each shard from c x slot (RoceArgs.chunk), and an op empty on both
ranks rings no doorbell and leaves the epoch. Every RDMA write keeps the 1 MiB cap. The kernel poisons the transport
rather than stage past a slot, and its four failure-record blocks fold into fail_record (same stores and fences).

VerbsWire.post waits for completions while the bytes posted and not completed over both HCAs would pass
max_inflight (2 MiB, a constant in the post path); a wait that sees no completion for 10 s fails the proxy. Boot
refuses TF_TP_ROCE_CHUNKED_KB when the kernel image lacks the tp_roce_chunk_abi marker. The setting is part of the
digest both ranks agree on.

Tests: chunked strides from 300 KB to a 128 MiB union posted back to back on fake verbs whose completions lag keep at
most 2 MiB in flight and no write past 1 MiB, and reach the cap; the wire's own in-flight count and peak match the
fake HCAs'. Over the shm wire, 2,000 chunked variable-length gathers of up to four slots arrive bit for bit.
…region; the region is DONTFORK and NOHUGEPAGE

A local protection error can arrive while the IOMMU invalidates its mappings lazily. On such an error the old path
left the other HCA's QP ready to send (still taking the peer's writes), hung up the fate channel without telling
the peer to stop, and freed the region at once: unregistered from CUDA with no GPU sync, then QP destroy, MR
deregistration and munmap. A device write after the unmap could then reach a reused page through a stale IOTLB entry.

- Roce.fail and Roce.abort (the fail-fast hook) move every QP to the error state: no send goes out and no peer write
  lands.
- Roce.deinit quiesces first: QPs to error, every posted request reaped (flushed or not), cuCtxSynchronize. A failed
  transport, or one that does not quiesce, keeps its region registered and mapped; the process exit tears it down.
- Session.close on a failed transport goes fail-fast before closing, so the peer aborts and halts its HCAs first.
- The region is MADV_DONTFORK and MADV_NOHUGEPAGE before ibv_reg_mr; a refusal fails the start.
- A QP whose actual max_inline_data is under 4 B is refused (the flag post uses lkey 0 on a stack word).
- One log line a rank: region base and length, each HCA's lkey and rkey, the peer's region and rkeys.

Tests: on fake verbs Roce.abort halts both QPs; quiesce halts both before the first flush and reaps every posted write;
an aborted transport reports itself failed, and over the shm wire the aborted rank keeps its region while the other
frees it; smaps shows dc and nh on a prepared region; the inline bound refuses 3 B and takes 4.
…path on real HCAs, only on an idle link

- `tf-tp-test failfast V transport [N [HOLD_S]]`: N clean 4 KiB sums, the ranks meet over NCCL, each waits for its
  link to go idle (every HCA's posts completed), both agree over NCCL, then the victim takes the proxy's failure path
  (`Roce.inject`, which is `Roce.fail`) and closes its session: both ranks halt their QPs and exit 70, and the
  victim's region stays registered. When either rank's link is not idle there is no inject, a clean stop, REFUSED and
  rc 2.
- Its host-only forms (TF_TP_FAILFAST=0, or a hold) are refused unless TF_TP_ALLOW_HOST_ONLY=1 and no RDMA wire is
  in use (the shm wire, or no RoCE), so they never run on an HCA.
- `run_transport.sh MASTER PEER_SSH OUT`, driven from rank 0's host (rank 1 over ssh): prechecks on both hosts (no
  GPU process, memlock unlimited), then T0 (suite), T1 and T3 (each rank as the victim). After each step it reads
  both hosts' kernel log since the step and every HCA *err* counter; a hit, a counter that grew, an unexpected rc or a
  failure line prints STOP: and exits 1. `run_transport.sh t2 OUT` runs the host-only form on one host.
- The `halted` and `quiesced` lines carry each QP's state read back with ibv_query_qp (an optional symbol), each
  HCA's posts and completions, the completions the drain reaped and how many of them were flushes.
- `Roce.allGatherV` refuses a stride past the slot (one op; the route never sends one).
- The README states the RoCE limits and how to run the check.

Tests: on fake verbs the link reads busy with two posts out and idle after the drain, and the report line names both
QPs in the error state with every completion a flush.
… TF_TP_ROCE_HCA nor NCCL_IB_HCA is set

- `tf-tp-test hca` (host only, no GPU): both ranks run the RoCE pick over the bootstrap, the same rule the wire uses,
  and each prints its own devices as `NCCL_IB_HCA=name,...` (no GIDs). It exits 1 with the reason when the host has
  no usable port or no port on a /24 the peer shares, so no rank falls back to its first ports for NCCL.
- run_hosts.sh runs it when neither variable is set, exports the names for every step and logs each rank's pick;
  a failed or malformed `hca` stops the runner (exit 3) with the reason; `hca` is capped at TF_TP_PLAN_TIMEOUT + 31 s, so
  its own reason (no peer joined in time, port in use, the peer closed, a bootstrap error) comes first. An explicit NCCL_IB_HCA, an explicit
  TF_TP_ROCE_HCA (NCCL_IB_HCA derived from it) or both keep their behaviour; the many-devices warning is gone.
  Both hosts use the same mode: with one naming its ports and the other not, the latter's `hca` finds no peer and
  stops after TF_TP_PLAN_TIMEOUT with that reason (README).
- roce_pick: `select` / `selectFrom` return how the devices were chosen (`resolve` is unchanged for the wire),
  `joinNames` and `hcaLine` give the NCCL list. Host tests: the port scan over a stub verbs table (state, Ethernet,
  the IPv4 RoCE v2 GID index), then both ranks through a real bootstrap on the two hosts ashhart#636's receipt reports
  (modelled, documentation addresses), an explicit rank, and a host without ports.
…k switched off refuses to start instead of stalling

A family that installs the keyed graph cache sets Config.graph_cache before Session.open; the settings digest then holds
their effective digest under TF_GRAPH_CACHE as read, so 0, off and OFF agree and on against off stops every rank at
start with the existing mismatch message. Families without the cache leave it null and are not compared. Hits add no
collective.
…idency budget, streamed NVMe tier.

zig/src/sessions keeps a chat's KV pages after its request ends: entries are found by a trie over chained page
digests, held in RAM within a residency budget (chats and pool bytes), and the least recently used idle chat is
parked to an NVMe tier and streamed back on resume. Ranks that split KV run every store call in the same order, so
their books stay identical. It complements core/prompt_cache, which snapshots a whole family state; a family that
uses it reports the resident bytes as Memory.cache and its budget as Info.prompt_cache_plan. No family uses it yet;
zig build test-sessions runs the host tests, the NVMe tier on real files.
The prefix index keeps one node per distinct full page of every saved entry in `by_digest`. Each saved turn adds its
new pages, and each entry dropped or evicted removes the pages no other entry passes through, for the life of the
server. std's tombstones never clear, so in time they take every free slot, and each save's new pages and each find's
walk past the cached prefix then probe the whole map. The map now counts its removals and is rehashed in place once
they reach a tenth of its capacity.

Test: 3,000 turns of up to 60 fresh pages, the oldest dropped past eight, keep a tenth of the map free after every
turn; without the rehash it fails.
Use null for unlimited residency, retain portable bookkeeping tests on macOS, and run the Linux NVMe tier tests only on Linux.
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.

3 participants