Skip to content

tp ranks: every byte after the key proof crosses the bootstrap, fate and plan links in sealed records - #3101

Draft
ashhart wants to merge 2108 commits into
security/rank-link-frames-flashnextfrom
security/rank-link-frames-tp
Draft

ashhart wants to merge 2108 commits into
security/rank-link-frames-flashnextfrom
security/rank-link-frames-tp

Conversation

@ashhart

@ashhart ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

What this changes

Before: after the key proof the tensor-parallel bootstrap, fate and plan links ran in clear text. A host on the path read the ranks' settings, the NCCL id rank 0 broadcasts, every round plan and every failure reason, and a byte it changed in a plan was taken as sent. After: on a group with a key, every byte the socket helpers move on those connections is a ChaCha20-Poly1305 record under the proof's session key, and a record that does not open closes the link.

Checks on this head

  • Head commit: 181f288fcdafed704bdd01f5ff2ec09d0ea54f2f
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 345 on the base, 345 on this head, 0 new.
  • Tests run, with the command and pass, fail and skip counts:
    • zig fmt --check and git diff --check: pass
    • zig build test-rank-auth-host test-tp test-tp-fate-host: 22/22 steps succeeded; 178/181 tests passed (3 skipped)
    • zig build check-native-cuda-host compile-flashnext-mtp-parity-host compile-glm-native-open: 11/11 steps succeeded
    • zig build test-cuda-host: 391/391 steps succeeded; 6261/6303 tests passed (42 skipped)
    • zig build native: 66/66 steps succeeded
    • zig build test-golden test-server-security test-pull-security: 76/76 steps succeeded; 34/34 tests passed
    • a step served from the build cache prints no test count, so the counts above are lower bounds
    • the tests of this stack, built from its top for aarch64 Linux and run in a throwaway VM: tensor-parallel 80/80, liveness lines 4/4, rank auth 50/50
  • New tests:
    • security: a host on the path reads none of a keyed group's settings, plans or failure reasons
    • security: a byte changed on a keyed group's plan link ends the link, and no plan is taken from it
    • security: a new socket whose number a sealed one had carries its bytes as they are
    • rank seal: a record that arrives a few bytes at a time opens once it is whole, and not before
    • security: a record altered on its way, or a head no record has, is refused piece by piece too
  • CI: runs on this push.
  • Not run, and why: nothing ran on a GPU or between two hosts. zig build test and every step that runs on a GPU were not run: this Mac's GPU was serving a model, and no CUDA hardware was available.

Receipt

  • Main against branch: could not be run. It needs two CUDA hosts.
  • Boxes it reaches: every --tp group and every family that opens the fabric's bootstrap, on a group with a key. A group with no key stays on one host and its bytes are unchanged.
  • New switch? Default, accepted values, profile row: none. The key is ranks: every rank connection proves a shared key before its first protocol byte #3041's TF_RANK_SECRET_FILE.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: this head on Zig 0.17.0, on an Apple silicon Mac, CPU-only steps, and the same tests in a Linux VM. No GPU and no checkpoint was used.
  • Paths and platforms the change reaches, which I ran and which I could not: the bootstrap, fate and plan links over loopback on macOS and Linux, through a relay that records and changes bytes. Two hosts were not run.
  • Exactness: not measured. No kernel, no arithmetic and no frame's content changes.
  • Main against this branch, same machine and checkpoint: not run, for the reason above.
  • Decode speed before and after: not measured. A keyed group's plan frame crosses in records of at most 16 KiB each: two for a small plan, its length and its words.
  • Prompt speed before and after: not measured.
  • Licence of any new weights or drafter: n/a.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. With the two sock.seal calls in the bootstrap switched off, the relay reads the settings, the plan and the failure reason, and a changed plan byte is taken: both relay tests fail.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

For a change that reaches inference:

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Not measured: no served run.
  • No precision traded for speed.
  • Decode and prompt processing are no slower than main. Not measured: no served run.

Notes for the reviewer

  • The seal sits under sock.zig's helpers, keyed by the socket. The bootstrap adds a connection's seal right after its proof, so the hello, the blobs, the fate frames, the plans and the DeepSeek session words that use the plan socket all cross sealed with no change in their callers. planlink.zig now sends its length through sock.sendMore instead of its own send.
  • A group with no key adds no seal and takes the same path as before, with one lookup that finds nothing.
  • sock.accept and sock.connect drop any seal listed under a new socket's number, so a number that is reused never inherits one.
  • The fate watcher reads on while a sealed record still holds frames, since a poll of the socket does not show them.
  • tcp-host, the test tool that moves tensors on the plan socket with its own reads and writes, now refuses to run on a keyed group.
  • Still clear after this: the ranks' liveness lines, which the next PR seals, and the NCCL, RCCL and RDMA traffic that carries the tensors.
  • The lean count is against flashnext ranks: every byte after the key proof crosses the pair's link in sealed records #3076's head.

Suggested changelog line

Tensor parallelism: on a group with a key, every byte after the key proof crosses the bootstrap, fate and plan links in sealed records.

@ashhart

ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

Review: ready. The session key comes from #3041's proof (bootstrap.zig:51,56,91), and it is fresh per connection and bound to the link's purpose. Each direction has its own key and a 64-bit counter. trySend rolls back only when no byte left the socket, so a counter value is never reused on the wire. An altered, replayed, reordered, reflected or cut record fails to open and shuts the socket, which ends in fate's exit 70 or the plan link's PeerClosed; no path hangs. Every byte on the control and plan sockets goes through the sealed helpers, and tcp-host refuses a keyed group. An unkeyed group's bytes are unchanged, and the relay test proves it. Cost: about 5-8 µs a DSV4.1 decode round on the follower, under 0.05%.

Small notes, none blocking:

  1. A keyed plan frame is two records. Sealing the length and the words as one record at planlink.zig:111-113 would make it one seal and two receives, as plain.
  2. sealed.of scans a list. That's fine at TP 2-4; keep each follower's seal in PlanLink if large worlds matter.
  3. A partial trySend can now block up to 1 s holding fate's send lock.
  4. SECURITY.md: the GLM and MiniMax ranks also broadcast each step's header and prompt token ids over NCCL (glm/cuda_follow.zig:84-97), not only tensors. Please say so.

Host tests: test-rank-auth-host, test-tp and test-tp-fate-host, 195/198 (3 skipped). With both bootstrap seals switched off, both relay tests fail. The stack needs rebasing onto main before it lands: the cuda/experts.zig serving pin is stale at its merge base and fixed on main. We'll write the changelog line. Device check before landing: the keyed TP=2 run on two GB10s against #3076's head.

  • Synthena (Ash's Agent)

ashhart and others added 22 commits November 21, 2026 17:15
…mpled transition cost

Prune inactive DFlash2 sequence rows, skip tap writes when no stream draws a DFlash2 chain (scattering stream means directly via glm_tap_mean_ring without the extra staging copy), and flatten sampled chains across active prefixes on top of PR #3920.

Stacked on #3920.
Refs #3152
… idle manager can take the lock and park on a busy runner
Main 8836b98 keeps cli.zig at
600 lines. The contributor's flag and Args field bring it to 602.
Remove two empty separator lines; every non-whitespace source byte
is unchanged and both main and witness entries remain in order.
…ord of codes at a time

tf_dsv41_route_gate_plan runs the router's matvec, the route and the experts' plan as one launch:
groups of 32 columns compute the gate logits (mv.metal's lane chains and butterfly, rows in up to
four slices), and the last group to finish (its count in the scratch's sync word, zero between
launches) reads the logits as atomics, ranks every row's picks in the route's order (each
simdgroup's top-k, then their union's) and plans them. It runs beside the shared expert's w1/w3,
so the MoE takes four waves after the norm instead of six: gate+route+plan beside the shared up
and act_quant; gate/up beside the SwiGLU and the hc mixes; down beside the shared w2; the join.

The one-row gate/up and down decode each word of E2M1 codes by shifts (no integer multiplies)
and stage x a 32-value group on a stride of 40; every chain keeps its order.

Every output and KV byte is unchanged: layers 2, 21 and 5 at 1 and 4 rows hash as main. The new
launch is in the contract twice (matvec and route suites, controls under TF_GCTL and TF_CTL).
…a propose launch in one concurrent encoder

With drafts on, the drafter's weights now carry an FP8 copy of the vocabulary head (E4M3 codes, E8M0
scales a 32x32 block, the release's own weight format), quantized from the bf16 head at load in 16
workers (0.2 s, 0.67 GB). The drafter's head runs it on the FP8 rows kernels; the target keeps the bf16
head, so every output token is unchanged and only proposals can move. The propose launch now runs in a
concurrent encoder, with a barrier wherever a step reads the one before (wq_a beside the key's wkv,
q_norm beside the key's ring write). A new test holds a launch in a concurrent encoder byte-equal to the
same launch in a serial one; dropping one barrier makes it fail.

M5 Ultra, release checkpoint, five prose prompts, one stream: propose GPU 3.73 -> 3.06 ms a round
(FP8 head 3.29, plus the concurrent encoder 3.06); accepted drafts and every reply's hash unchanged.
About 20 ingests a run (of 2,400) waited 40-570 ms between commit and their first GPU instruction, on
an idle queue (the target's window had already waited for its own command buffers), while their GPU
work took under 1 ms; target command buffers never waited. The drafter's buffers were in no residency
set, so macOS let them go between passes and a pass waited while they were made resident again. Pass.init
now holds every buffer a pass binds (the drafter's weights and FP8 head, rings, act_quant rows, plan and
working buffers, 8 GiB) in one residency set on the engine's queue, released at deinit.

M5 Ultra, five prose prompts, one stream: ingest wall 1.9-2.9 -> 0.50 ms mean (GPU 0.26), no waits past
20 ms; greedy 57.1-58.5 -> 59.7-59.9 tok/s, sampled 48.6-49.8 -> 51.6-51.7 tok/s; accepted drafts and
every reply's hash unchanged.
…s, wq_b and w2 from 5 rows, narrow ones never

The tile's form gave 16 columns only to N of 16384 or more, so wo_b, wo_a's eight groups and the shared w1, w3 and w2
ran 8 columns a threadgroup at 6-16 rows, 30-60% slower than with 16. The form now counts a batch's columns (2048 or
more take 16); projections of 2048 or more columns with K not in whole 1024s (wq_b, the index wq_b, w2) take the tile
from 5 rows, the others from 6; projections of 1024-2047 columns (wq_a) from 7; and those under 1024 (wkv, the
compressor) stay on the row kernel at every row count, where it reads them up to twice as fast. The decode Engram
projection takes the tile at the rows it does instead of the row kernel. Every row's bits are the row kernel's, as
the tile's contract registrations already prove.
… and read X 8 bytes at a time

At 2-6 rows the one-launch row kernel spent its registers on tf_dsv41_w16's sixteen decoded weights a column and on
two 16-byte X reads a row, and its time grew with each row. Block e (split 1, two columns a lane) and block f (split 4,
four columns a simdgroup) decode one word at a time and read 8 bytes of each row's X where they are used; a lane with a
NaN code or a scale past 2^120 takes tf_dsv41_w16's per-code path as before. The chains (k in order from zero), the
group butterfly and the tile roots' tree are the whole kernel's, so every output's bits are. Projections with K in
whole 1024s and 2048 or more columns take e at 1-5 rows and d above (on cold weights back to back, d was faster than b
at 2 rows here too); the others take f at 2-6 rows and b otherwise. The contract gates both blocks (one launch, f32
e and bf16 f) besides the row-invariance probe's every-kind check.
… one line each, as the lean rule asks

Four comments (fp8_rows.metal's lean kernel, fp8_rows.zig's Kind, fp8_tile.zig's minRows and the rows contract's
Variant) each ran over two lines. The block columns move to their fields and minRows' reasons to its branches; no code
changes.
…yer runs, each layer's rows written just before the command buffer that reads it, and the next window's first row's reads start after the picks
Follow main f9df8bf (the Metal lane target and native server) and e19cf91 (the pick.zig split). Keep the current prompt geometry admission assertion when taking the threaded sampled-row delta; leave the split pick helpers and every caller in their maintained modules.
…d its verify (picks, acceptance, ingest and pass on the GPU) and kept when the host's commit matches; an ingest made before its window's commit is put back where the commit cuts it
…the reply as on Nemotron

After a chat reply the server sends a background prompt-only pass over the reply as the next turn's prompt renders
it. Flash Next on CUDA did not take it, so every next turn resumed at its history's end and prefilled the reply
again. The family now declares warm_quiet, 150 ms as Nemotron's. Its CUDA cache rules then wait for quiet and keep
the pass's state one token short of its end, since the MTP head reads one token on. The native CUDA host turns warm
turns on when the prompt cache is on and one rank serves. The family keeps and resumes states at any row, so the
pass needs no message-start cuts. With --tp the store's warm rule is off and the server sends no pass.

The pass gives way to real work. Its whole-prompt prefill asks before each chunk whether to step aside, and when it
does it keeps the state it reached. Its chunks take the busy chunk's rows, 1,536 by default, where a one-stream
server's solo pass takes 8,192, so a request that arrives waits for at most that many rows.

The lane host now also counts another request's prompt that is still filling a chunk a round as work. Before, a
pass taken beside one saw no queued request and no decoding stream. It waited out its quiet on the lane thread
while that prompt stood still, then ran whole. Warm passes on every host with a fill queue now give way sooner, and
replies are unchanged.

Requests that are not warm passes take the same path and the same rows as before. Warm states go through the
store's budget and eviction like every other mark.

Host tests: a warm pass taken while a request's prompt is filling runs no chunk, or yields at its first, and the
request finishes. On main's lane host the pass ran whole and the test fails with expected .cancelled, found
.length. A Flash Next CUDA warm pass steps aside before its first chunk through the real lane opener, and Flash
Next's CUDA cache rules keep warm marks.
…ged, on today's main

Skip Flash Next CUDA image warm passes before cache admission edits flashnext/cuda_lanes.zig and its admission test
after the earlier re-pin; their gradient-serving rows take the files' sha256 on main 7b2717a. Notes unchanged.
41177ae added tools/test_ci_workflow_conditions.py, which reads the workflow files with yaml.safe_load. The
pytest job's venv installs only pytest, so collection fails with ModuleNotFoundError on every GitHub pytest run.
…tocol byte

The TCP links between the ranks of a multi-GPU group took whichever host connected first. Both ends now
send a fresh nonce and an HMAC-SHA256 over the nonces, the link, the rank and the group size, on the
bootstrap, the liveness lines, the HIP link and the Flash Next pair. A connection that fails is closed
and cannot stop the group. Ranks with no key meet on one host only. TF_RANK_SECRET_FILE or --rank-secret
names the key file. Later frames are not signed and the links are not encrypted.
… gets 2 s

- The key file opens through symbolic links, as secret mounts give it; the type and
  mode checks still run on the opened file, so a link to a file others can read is
  refused.
- Rank keys need 32 bytes after trailing whitespace. The shared loader takes the
  minimum from its caller: rank links pass 32 and the stage ring keeps its 16, so
  every stage ring that starts today keeps starting.
- A missing, different or short key's error names serve --rank-secret FILE and a
  one-line command that makes a key.
- Rank 0 logs each refused connection with the peer's address and the reason.
- An acceptor waits 2 s for the hello, so a silent connection no longer holds the
  serial accept for the whole 10 s budget.
- The Flash Next CUDA rank device test passes the new secret argument to Link.open.
test-gradient-serving pins the bytes of the maintained serving sources; the
train CI for this branch (#3168) stopped at zig/src/cuda/root.zig, but four
differ:

- zig/src/cuda/root.zig: tp_line.zig's tests are imported.
- zig/src/cuda/tp_watch.zig, zig/src/families/flashnext/cuda_rank_engine.zig
  and cuda_rank_wire.zig: rank connections prove a shared key before their
  first protocol byte (b83c447).

Each row takes its file's new hash, with the change named beside it.
…records

The proof showed which process connected, and then the ROCm ranks' command link ran in clear text: a host
on the path read rank 0's words and could change them. Both ends now seal every byte after the proof in
ChaCha20-Poly1305 records under keys derived from the proof's session key, one for each direction, with
the record's place in its direction as the nonce. A record altered, replayed, moved, sent back or sealed
under another key does not open, and the link closes. rank_seal.zig holds the record layer for the other
rank links to use. The CUDA control links and the NCCL, RCCL and RDMA traffic are still clear.
…nk in sealed records

After the proof the Flash Next pair's control link ran in clear text, so a host on the path read the frame
headers and the forward frames' token ids and could change them. Both ranks now send every byte after the
proof in the rank seal's ChaCha20-Poly1305 records. A record that does not open ends the link. A test's
socket pair, on which no proof ran, has no seal and stays clear. The tensor-parallel bootstrap, plan and
liveness links and the NCCL traffic are still clear.

This branch has not been deployed

No deployments
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.