Skip to content

flashnext: a lone stream's copy window takes the width the boot check proves - #4075

Merged
ashhart merged 5 commits into
ashhart:mainfrom
BadAd84:flashnext-copy-window-up
Nov 24, 2026
Merged

ashhart merged 5 commits into
ashhart:mainfrom
BadAd84:flashnext-copy-window-up

Conversation

@BadAd84

@BadAd84 BadAd84 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Terms used below: "main" is upstream TensorFold at 3661a4281425a71eb5f2a56922f0f2a33e5f4f17 (the tip of 2026-11-20T06:52:12Z, read from the repository; the branch merges exactly that tip, so it carries main with nothing behind it), and "the branch" is that main plus the one change this pull request adds, whose head is the commit named below.

What this changes

Before, a verify window on Flash Next CUDA carries at most 32 rows, so a lone stream's copy window ramps to at most 31 copied tokens a round whatever the machine's rows actually do. After, with TF_FLASHNEXT_WINDOW_CHECK=1 (default off) a load measures, before it serves, the widest verify window whose every row's scores equal the scores of a one-token step on that machine, and the copy window grows to that width, past the 32 rows served without the switch and at most the 48 rows a window's pending-row log holds. A check that cannot run, fails, or proves nothing past 32 rows leaves the window at 32, so no width past the shipped one is served unproved. With the switch off every buffer the window sizes is main's too, so the off state is exactly main.

Why a check rather than a constant: whether a 40- or 48-row window's rows equal their one-token steps is a property of the kernels and the driver on that machine, not of the model, and a change that moves a chunk position can take it away. The width is therefore measured at every boot that turns the switch on, and the check's log line names both the rows it compared and the width it serves.

The 48 is not a tuning choice: a drafted window's rows are its stream's pending-row log, which holds 48 rows and is where a partly kept window's rows stay for the next window's chain. A window wider than that would overwrite its own kept rows, so the widest window is the log's own capacity, and nothing wider is measured or served.

  • Issue: n/a (no upstream issue covers this; it is one behaviour cut from our local patch stack, not a new family, backend or arithmetic change)
  • Stacked on: main at 3661a4281425a71eb5f2a56922f0f2a33e5f4f17. The change is c14485f5ca8c13a13898abb3a87fe25a769122e0 on the older main 077998f7d (against that base 23 files, 385 insertions and 110 deletions), the receipt commit c590daeb1 adds the four files under docs/receipts/flashnext-copy-window/ (502 insertions), five signed merges of upstream main (6f1e0d994 for e7ff97e13, f8af44d1b for 32c4e3d8f, a13efbe9d for d8b947b1f, da430818f for 144964f8d and be2dc1a57 for 3661a4281) bring the branch to its head, and d8c4dd5a8 updates that receipt's boot cells after main's page-cache change, so the head is be2dc1a5730f42a755b5be7f5caa3108249baa82: 26 files, 883 insertions and 110 deletions against 3661a4281425a71eb5f2a56922f0f2a33e5f4f17. CHANGELOG.md is main's file entire: the changelog line is the maintainer's to add with the number.
  • atc overlap --json, on this head with the base 57c792ae5eb6795451e93e15056325983f6aea04 (upstream main's tip when it ran): complete false (limitations otherPullRequestsLimit, pullFilesUnavailable, pullRequestsLimit, timeLimit), 26 changed files, 38 entries, and four of them conflict. GLM on CUDA: kept states, carries and prompt twins under the latent split (TF_GLM_KV_SPLIT, #1431 part 4; stacked on #2937) #2938 (556ceba53) shares 4 files and conflicts in 1, zig/src/native/cuda_kv_pool.zig: its @hasDecl(F, "window_rows") rows line and this change's budget.windowRows(F) replace the same statement, one block, and a read-only merge of that head with main alone is clean. cuda: GLM, MiniMax and Nemotron placed from one launch, by flags or aliases (T1b of #2560) #2919 (0be7321f0) and fabric/mesh: one launch description, --tp up to 64 and the rank aliases (T1a of #2560) #2917 (1bc743645) share 4 files each and conflict only in zig/tests/fixtures/gradient-serving.tsv, the three rows both changes re-pin (cuda_lanes.zig, cuda_lanes_admission_test.zig and cuda_lanes_load.zig), one block each, and each head is clean against main alone. moss image: serve pictures on CUDA (encoder, decoder and host for #1573) #2281 (bcefb2fa4) shares only the pin file, and its four conflicted files (CHANGELOG.md, zig/tests/cuda/contract_limits.zig, zig/tests/cuda/main.zig and the pin file) are exactly the ones it conflicts in with main alone, block for block, so its conflict is its own. Six further entries are clean over their shared files and twenty-eight more were not checked within atc's limits; among those, Ling-3.1-flash on CUDA, on one or two GB10s #2340 (69c3e065f) conflicts with main itself in docs/environment.md, zig/src/platform/environment.zig and zig/src/platform/environment_test.zig plus the pin file, and a read-only merge of its head with this one conflicts in the same three, so it needs its own refresh first. Main has moved since the run: its tip is now 6fc30cf0bf3b (changelog: #2917 under Unreleased, 10 commits on, which is fabric/mesh: one launch description, --tp up to 64 and the rank aliases (T1a of #2560) #2917 landed), and a read-only merge of this head into it conflicts in zig/tests/fixtures/gradient-serving.tsv alone, one block over the three rows that change and this one both re-pin (cuda_lanes.zig, cuda_lanes_admission_test.zig and cuda_lanes_load.zig); their code merges without a conflict, and the resolution is those three rows re-hashed to the blobs the merge writes, the same re-pin every merge of this branch has taken.

How the width reaches the code:

  • cuda_mtp.zig keeps max_rows, which is batch.late_rows (48, the pending-row log), base_rows = 32 (what main serves), buffer_rows and served_rows. bufferWidth decides the rows a load's window buffers hold: max_rows only when the boot check runs, else base_rows; sizeWindow writes it once at load, before the check's own draft. servedWidth decides the width serveWindow writes: with the switch off, or the check not run or failed, base_rows; a proved run widens to it, never past the buffers' rows and never below base_rows. rowsOk(n), n >= 1 and n <= served_rows, is the one bound, and probeWidths produces the sweep's widths, every width the buffers hold, under the window they need.
  • cuda_lanes_load.zig reads the switch through platform/environment.zig, sizes the buffers (sizeWindow) with the check's own condition (drafts on, the head loaded, TP=1: the pending-row log a check needs is a one-GPU path), runs probeServed only then, and sets the window for the load either way, so a reload cannot inherit another load's width; both widths are process state, and every load writes them. A stream's window there, and its cache's rows past the reply in cuda_lanes.zig, take bufferRows() rows.
  • cuda_mtp_draft.zig sizes a draft from Draft.Layout.of, which takes bufferRows() once: a window's scores, its best values (bestBytes, with the candidates at valsAt and their columns at colsAt), the saved projection and n-gram rows and the host rows all follow the layout's rows, and cuda_mtp_draw.zig and cuda_draft_draw.zig find the candidates through the same layout, so a buffer and the offsets into it can never disagree.
  • cuda_kv_lanes.zig holds windowRows() rows past a request's pages, and cuda_lanes.zig exports it; the native KV pool plans a family's pages with windowRows, one helper in native/cuda_memory.zig that takes a family's own windowRows() before its window_rows constant, so every other family plans as before.
  • cuda_lanes.zig reports the served width as the model's exact_width; core/lanes/config.zig turns that into max_copy = width - 1 and first_copy = min(max_copy, first_copy_rows - 1), and the backend refuses a window wider than it. windows.zig reads copy_width orelse first_copy only when e.alone, and engine.zig ramps it 2 * width + 1 capped at max_copy after a fully kept copy round. Shared rounds keep first_copy, 16 rows, unchanged.
  • cuda_mtp_ops.zig refuses a verify of more rows than the window through rowsOk, the same predicate verifyMany uses, so a lane core asking for more stops rather than being verified at a width nothing proved.
  • The sweep runs in the window it measures: probeServed takes its widths from probeWidths, which sets served_rows to the buffers' rows before the first verify, so the same guard that refuses an unproved width accepts every width the sweep asks for. The load's serveWindow(check, proved) then sets the width it proved, or base_rows when the sweep failed. Without that ordering the sweep's 33rd width meets a 32-row window and the check can never widen anything.

Main changed the page pool under this change too, and the two compose. 95a872500 gives the pool's arena one thread that maps its 256 MiB pieces ahead of the caller, and 27d834ca0 makes a new paged stream, beside streams already running, post the pieces its run and pages reach and skip its round until they are mapped (cuda_kv_lanes.zig's Pool.waits and meet, and one line at the top of cuda_lanes.zig's prefillStepFn); 19e069811 is a blank line and a pin row. Nothing in the arena is shaped by a row count: its pieces are fixed 256 MiB, mapped by byte offset and tracked one flag each, and the rows reach it only through its length, the plan's page count, whose window is window + windowRows() in native/cuda_kv_pool.zig; a check-on load's arena is therefore at most one page per stream longer than a check-off one, and the pages a stream's run and prompt reach are the ones the pool hands both sides. The one row-shaped input main adds is the cap Pool.waits predicts an open needs, rows + mtp.max_rows in State.waits: mtp.max_rows is the pending-row log's 48 rows, the widest window any load can hold, so the prediction is never narrower than the open's own bufferRows() cap, equal to it with the check on and 16 rows wider with it off, where it can only post a page the open will not read this round and never miss one it will. The pin file is therefore the only place the two meet, and it is re-pinned per merge.

Every file, and why it changes:

  • zig/src/families/flashnext/cuda_mtp.zig: the four widths (max_rows, base_rows, buffer_rows, served_rows), the policy that sets them (bufferWidth, sizeWindow, servedWidth, serveWindow, rowsOk, probeWidths) and their host tests.
  • zig/src/families/flashnext/cuda_mtp_draft.zig: a draft's buffers and Draft.bytes sized at its layout's rows; bestBytes, valsAt and colsAt own the best buffer's layout; the byte pins at both sizes.
  • zig/src/families/flashnext/cuda_mtp_draw.zig, zig/src/families/flashnext/cuda_draft_draw.zig: the candidates' and columns' offsets read from the draft's layout, the same functions that size the buffer.
  • zig/src/families/flashnext/cuda_mtp_nonfinite_fixture.zig: the recording device's draft carries a layout, and its addresses come from the same offsets.
  • zig/src/families/flashnext/cuda_lanes_load.zig: the switch read, the buffers sized before the check, the check, the served width, and a stream's window at bufferRows() past the context.
  • zig/src/families/flashnext/cuda_lanes.zig: the served width as exact_width and the verify guard, a stream's cache rows past its reply, and windowRows exported for the native pool.
  • zig/src/families/flashnext/cuda_kv_lanes.zig: the KV pages past a request hold windowRows() rows.
  • zig/src/families/flashnext/cuda_mtp_ops.zig: verify and verifyMany refuse through rowsOk.
  • zig/src/families/flashnext/cuda_mtp_check.zig: the boot check (windowCheck, probeServed), its bound at its draft's rows, and the drafted check's caches at bufferRows().
  • zig/src/native/cuda_memory.zig, zig/src/native/cuda_kv_pool.zig, zig/src/native/cuda_cache_capacity_test.zig: one windowRows helper for the pool's four reads of a family's rows, and its test.
  • zig/src/platform/environment.zig, zig/src/platform/environment_test.zig, zig/src/platform/environment_flashnext_test.zig, docs/environment.md: the switch's rule, its valid values and the table's counts.
  • zig/tests/cuda/contract_flashnext_late.zig: the late-log kernels' served shapes reach the log's 48 rows.
  • zig/src/families/flashnext/cuda_lanes_admission_test.zig: a drafted stream's cache holds the window's rows past its reply.
  • zig/build/cuda_fault_host.zig: the test-flashnext-window-host step and its four filters.
  • zig/tests/fixtures/gradient-serving.tsv: the edited serving sources re-pinned.
  • docs/optimization-ledger.md: the copy-drafts cell. CHANGELOG.md is not part of this change: it is main's file entire, and the Unreleased bullet is the maintainer's to add with the number.

Why a wider window cannot change the tokens, from the code: a copy window's rows are the pending token and the copied tokens, verified in one forward (cuda_lanes.zig verifyFn builds row_ids = [pending, copies...], and a lone stream takes Ops.verify), each row's scores landing in Draft.logits row by row; the lane core then commits a path in which each kept row's target sample equals that row's proposal (accept.acceptPath), and the committed token is accept.targetPick, the target's own pick and never the proposal. A reply is therefore a run of target samples at successive positions, and a copied or drafted token only decides how many rows are proposed and which can be kept. That makes a width exact or not exactly when each row's scores are the ones a one-token step produces at that position, and that is what the check measures: it builds a greedy continuation from a synthetic 96-token prompt, takes every row's one-token step scores as the reference, then for every width from 1 to 48 resets the sequence, re-runs the same prompt, checks the first drawn token is the same, runs one window of that width over the same continuation, and compares each downloaded row with its reference byte for byte over the whole u16 vocabulary row. probeServed logs the count and the first differing width and returns the largest width whose every row matched. A window of width W at most the proved width thus gives the same scores, the same target samples and the same accepted path as the 32-row arm for the same prefix; what changes is tokens a round, not tokens. The draw is keyed by the row's scores, the token map and the position (cuda_mtp.drawRow to lanes.sampling.choose(..., position, ...)), never by a running generator.

No GPU kernel is new or changed. A 48-row window runs the same row-by-row DeltaNet path a 32-row window runs today (late.front and late.chain when the window keeps a rollback), and the fused path, which needs 64 or more rows, is still not reached by any window. The kernel contract of those two late-log kernels (zig/tests/cuda/contract_flashnext_late.zig) now serves the log's 48 rows as well as 1, 9 and 32, so its gates run the widest window against the kernels they replace.

The cost, only for a load whose check runs: its draft buffers hold 48 rows instead of 32. Draft.bytes at a 65,536-token window and 1,536-row chunks goes from 356,905,472 to 384,170,752 bytes at the model's full heads and from 280,191,488 to 297,964,288 at half (+26.0 MiB and +16.9 MiB), the saved rows from 41,021,440 and 20,930,560 to 60,334,080 and 30,750,720 bytes, and a stream's window and its KV pages carry 16 rows more. With the switch off, at TP=2 or without drafts, every draft buffer, Draft.bytes, a stream's window and the pool line are main's; two tests in cuda_mtp_draft.zig pin both sizes, and one asserts the off state's rows are 32. The check itself costs boot time, which the receipt measures.

Checks on this head

  • Head commit: be2dc1a5730f42a755b5be7f5caa3108249baa82 (tree 9f61f509f636dc44d2059522b414e6d3ba16ff7a), a merge of da430818f7a4 and main 3661a4281425: the change commit c14485f5ca8c13a13898abb3a87fe25a769122e0, its receipt commit c590daeb1, five signed merges of upstream main (6f1e0d994 merges e7ff97e13, f8af44d1b merges 32c4e3d8f, a13efbe9d merges d8b947b1f, da430818f merges 144964f8d and be2dc1a57 merges 3661a4281), and d8c4dd5a8 re-takes the receipt's boot cells. Author and committer are the same public identity and every commit is signed (%G? = G), git diff --check 3661a4281425a71eb5f2a56922f0f2a33e5f4f17..be2dc1a5730f42a755b5be7f5caa3108249baa82 is clean, and against 3661a4281425a71eb5f2a56922f0f2a33e5f4f17 the head is 26 files, 883 insertions and 110 deletions, of which 4 files and 500 insertions are the receipt. The merge itself brings main in with 393 files, 62,533 insertions and 649 deletions against its first parent, and every file of it but the three it resolves by hand is git's own three-way merge of the two parents: git merge-tree --write-tree da430818f7a4 3661a4281425 gives a tree that differs from the committed one in docs/environment.md, zig/src/platform/environment_flashnext_test.zig and zig/src/platform/environment_test.zig alone (3 files, 5 insertions and 20 deletions), each resolved by keeping both sides' content and recounting the table to 34 settings.
  • Lean checker: python3 tools/zig/lean_check.py was run in each tree from its own root with that tree's own copy of the checker, and each run logs the root it scanned (the base tree and the head tree), so neither read the other's files: main 3661a4281 6,967 files and 168 problems, this head 6,967 files and 168 problems; python3 tools/zig/lean_new.py gives lean: 168 problems, 168 on the base, 0 new. The counts match because this change adds no file the checker scans: its added files are the four receipt documents, Markdown and CSV.
  • python3 tools/pr_check.py --base 3661a4281425 --pr 4075 on this head: merge base 3661a4281425a71eb5f2a56922f0f2a33e5f4f17; 26 changed files; lean 168 vs 168, 0 new, 0 errors and 1 advisory warning, the warning being that no CHANGELOG.md bullet names this pull request, which is the maintainer's line to add.
  • Every zig/tests/fixtures/gradient-serving.tsv pin checked against its file on the merged head be2dc1a57: files 169 failing 0. Main's rows arrive untouched beside this change's: the seven rows this change edits (cuda_lanes.zig, cuda_lanes_admission_test.zig, cuda_lanes_load.zig, cuda_mtp.zig, cuda_mtp_check.zig, cuda_mtp_draft.zig and cuda_mtp_ops.zig) carry the merged files' hashes, each recomputed from the tree this head commits, and this merge re-pinned nothing by hand because the rows do not overlap: the 19 rows main brings are its own files and none of them is one of the seven.
  • Host checks: run on x86_64 Ubuntu (16 CPUs, Zig 0.17.0, -j4 --maxrss 6000000000, umask 022, no GPU and no checkpoint, one zig build at a time, the heavy steps under a host-wide lock), on a fresh git archive tree of the merged head be2dc1a57 and of main 3661a4281, each checked blob by blob against its commit (verify_tree.py: 12,571 and 12,567 entries, 0 mismatches, 0 extra files): tools/zig/cuda_common_check.py cuda common: 55 local copies, 0 violations; tools/zig/cuda_fragment_check.py cuda fragments: 2 fragments, 15 includes, 0 misses; tools/zig/cuda_common_check_test.py Ran 9 tests then OK; tools/test_pdl_early_loads.py -v Ran 17 tests in 0.009s then OK; zig fmt --check build.zig zig rc 0 with no output in either tree; test-environment-host rc 0, 3/3 steps succeeded; 27/27 tests passed, 145 s, the step that holds the Flash Next count test, now 34 settings, 23 switches, 9 integers, 1 real and 1 structured, as the merged table and docs/environment.md both state; test-gradient-serving test-qwen-serving-host rc 0, 7/7 steps succeeded; 3/3 tests passed, 8 s; compile-config-server -Dtarget=aarch64-linux-gnu rc 0, 8/8 steps succeeded, 440 s, and compile-cuda-tests -Dtarget=aarch64-linux-gnu rc 0, 10/10 steps succeeded, 208 s, both cross-compiled from the x86_64 machine for aarch64-linux-gnu, so each is a type and link check and no aarch64 host ran it; test-flashnext-window-host rc 0, 4/4 steps succeeded; 27/27 tests passed, 1 s, which is this change's own step.
  • New and changed tests: test-flashnext-window-host now filters the served copy window widens, the boot check's sweep, a draft at 65,536 tokens and the saved pieces follow. The draft tests pin both sizes: with the switch off a layout's rows are 32 and Draft.bytes is 356,905,472 and 280,191,488 (main's), with the check running 384,170,752 and 297,964,288; the saved bytes and the stream-plus-draft total are pinned the same way. The window tests assert that no proved width is served past the buffers' rows, and that a sweep over 32-row buffers asks only widths those buffers hold. cuda_cache_capacity_test.zig asserts the KV pool plans window + windowRows() for a family that declares it, window + window_rows for one that does not, and window alone without either.
  • The seven mutants, measured on the tree of the previous merged head da430818f: this change's own step on a fresh copy of that head, one mutant applied at a time with its anchor asserted once, and an unmutated control first. Control rc 0, 4/4 steps succeeded; 27/27 tests passed; then every mutant fails: base64 rc 1, 23 of 27 tests (the served-window test, the sweep test and the two draft-byte tests); max64 rc 1, 24 of 27 (the served-window test and the two draft-byte tests); off-serves-proved rc 1, 26 of 27 (the served-window test); failed-serves-max rc 1, 25 of 27 (the served-window and sweep tests); floor-dropped rc 1, 26 of 27 (the served-window test); probe-serves-base rc 1, 26 of 27 (the sweep test); draft-ignores-switch rc 1, 25 of 27 (the two draft-byte tests). Seven of seven killed, on the tests this change adds. This merge did not re-run them: the two files they edit, cuda_mtp.zig and cuda_mtp_draft.zig, are byte-identical at da430818f7a4 and at this head (blobs 0987dd7f39f0 and 2a8d1f8ffb2a), so no byte a mutant perturbs changed, and the same step on this head's own tree passes 27/27 (above).
  • CI on be2dc1a5730f42a755b5be7f5caa3108249baa82 (this head), run on this pull request: fmt, zig, zig-b, zig-windows, pytest, benchmark-clients (ubuntu), release-paths and zig-macos-dev-tools completed successfully; benchmark-clients on windows failed in test_bench_served_evidence.ConcurrentEvidenceTests.test_a_healthy_server_proves_both, AssertionError: 'vacuous' unexpectedly found in {'equal': 2, 'unequal': 0, 'failed': 0, 'vacuous': '1 of 1 reps had no two streams decoding at once'}, a timing-dependent client test in tools/tests/test_bench_served_evidence.py, a file this change does not touch; the same job passed on CUDA: an int4 W4A16 kernel for GPTQ group-128 routed experts and the LM head #4183 and Flash Next on CUDA: one pooled n-gram gather for every row a shared pass needs #4009 on the same day, and it cannot be rerun from here, there being no admin rights on the repository. host-nightly-linux and host-nightly-macos are skipped by their own conditions.
  • Not run, and why: macOS Metal and HIP were not run (the change is CUDA-only and every other backend keeps its own exact_width); TP=2 was not run (the probe never runs there, so its buffers and its served width are base_rows and its behaviour is main's).

Receipt

  • Main against branch: main 077998f7d9b14adebec3a2acc2caa47ff7ae6ec7 against the branch at c14485f5ca8c13a13898abb3a87fe25a769122e0, three arms (main, branch with TF_FLASHNEXT_WINDOW_CHECK unset, branch with TF_FLASHNEXT_WINDOW_CHECK=1), 20 boots on one GB10, every cell on a fresh server and fresh images. The switch's boot check printed 1176 of 1176 rows byte-equal to their one-token steps (widths 1-48) followed by serving 48-row copy windows after the self-check on every B1 boot, so a lone stream's copy window ramps to 47 copied tokens a round against 31 on main. With the switch unset the branch's startup pool line reads main's (4.11 GiB a stream at 131072/4 and 1.29 GiB a stream at 32768/8), so the off path allocates main's buffers; with it on the line reads 1.32 GiB a stream at 32768/8. Copy cells, tokens a round: main 23.273, switch unset 23.273, switch on 28.444. Boot wall, re-taken on this head against main d8b947b1f after the load-time page-cache change: M 37.03 s, B0 37.05 s, B1 49.14 s, so the check costs about +12.09 s a boot (largest boot-to-boot spread within an arm: 0.1 s; the B1 delta is larger than that spread). The decode, prompt and exactness cells are the earlier window's, whose source files are byte-identical on this head apart from main's three edited files; the copy cells and the six golden prompts were re-taken here, copy tokens a round read 23.273 on main and on the switch-unset arm and 28.444 on the switch-on arm, in both cases, and the golden replies equal on every request. The late-log kernels' contract, at the window's own 48-row shape and before the first timed boot: (filtered) SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 0 controls: 0 red as planted, 0 missed; 0 limit problems; gates 113 ms, limits 0 ms (kernel-contract rc 0). The tables are docs/receipts/flashnext-copy-window/. The measurement pair sits behind this head by main's own 900 commits, 908 commits from 077998f7d to the head. Eight of the window's sources are byte-identical between c14485f5 and this head: cuda_mtp.zig, cuda_mtp_check.zig, cuda_mtp_draft.zig, cuda_mtp_ops.zig, cuda_mtp_draw.zig, cuda_draft_draw.zig, native/cuda_kv_pool.zig and the late-log contract. Four files main edited arrive with its own changes: cuda_lanes_load.zig (the page-cache sweep after load), native/cuda_memory.zig (the WSL2 pool rule and its Windows host-memory read) and core/lanes/config.zig and core/lanes/engine.zig (lane-core copy pricing, which does not run on a Flash Next serve, below). The retake re-measured the served copy cells on this head and they read as the receipt records. The lane-core work main did add does not run on a Flash Next serve: #2870's cut-chance pricing is reached only with allocate_shared_drafts set (Flash Next's own model leaves it off), #3617 carries message starts nothing reads yet, and the warm-turn field is Qwen3.5's. So the widths, the pool line, the boot cost and the exactness argument describe the merged head; the absolute decode, prompt and exactness numbers are the ones those 20 boots recorded on main 077998f7d.
  • Boxes it reaches: one CUDA GPU with drafts on at TP=1. Reached code: the lone copy path, the verify window guard, the load's buffer and window selection, and the KV pages past a stream.
  • The merged head carries the change's code unchanged: of the change's 22 files that reach the head, 11 are byte-identical to the receipted head c590daeb1 (cuda_mtp.zig, cuda_mtp_check.zig, cuda_mtp_draft.zig, cuda_mtp_ops.zig, cuda_mtp_draw.zig, cuda_draft_draw.zig, cuda_mtp_nonfinite_fixture.zig, cuda_lanes_admission_test.zig, native/cuda_kv_pool.zig, native/cuda_cache_capacity_test.zig and the late-log contract) and 11 carry main's edits beside this change's lines. Of the change's 368 added lines, 357 are present verbatim; the 11 that are not are three settings-count lines main re-counts itself (one on the environment page and two in the Flash Next count test, its name and its literal), the CHANGELOG.md bullet the branch does not carry, and the seven pin rows re-hashed per merge. The served files main edited are cuda_lanes.zig (its kept_view rename, the io field and the first-step wait), cuda_kv_lanes.zig (the arena's io, Pool.waits and mapAhead's post) and cuda_lanes_load.zig (the post-load sweep and the io handed to the pool); native/cuda_memory.zig carries main's WSL2 pool rule and its Windows host-memory read (524ceded7), and the rest are main's rows and pins beside the change's own (cuda_fault_host.zig, environment.zig, environment_test.zig, environment_flashnext_test.zig, gradient-serving.tsv, optimization-ledger.md).
  • New switch? TF_FLASHNEXT_WINDOW_CHECK: exactly 0 or 1, default 0; unset or blank is off, and any other text stops the start by name, TF_FLASHNEXT_WINDOW_CHECK="2": expected 0 or 1 (1 runs the boot copy-window self-check; default 0). Its rule is in platform/environment.zig with the other TF_FLASHNEXT_* rows and its row is in docs/environment.md. Not in a profile, and no getenv outside the environment table reads it.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: the receipt's arms are TensorFold c14485f5ca8c13a13898abb3a87fe25a769122e0 on main 077998f7d9b14adebec3a2acc2caa47ff7ae6ec7, Zig 0.17.0, CUDA 13.3, host 7.0.0-1019-nvidia-64k; Ubuntu 24.04.5 LTS; NVIDIA GB10, 580.178.04, [N/A]; RAM 123 GiB. Checkpoint nvidia/Qwen3.8-Flash-Next-FP4-Local, revision b9ce18a6887e18c089fdea8509a33e63429a3300, every arm; both images built from verified git archive trees of their own commits, kernels embedded (sha256:2703ee4cc38561184062f1189a4b400096976aa571d6dee70fb2a93681cf1bbd, sha256:d74a3f583f6474d8856a552bd1c7d341e318c166ca118a25c0172ce2be95c679), each carrying that window's own compile (its SOURCE line is in the build summary). The boot retake built its own pair the same way (sha256:7df98dcf49dd2dd5943f6bf5ad3a2143a2472c855057aa79d612062a00b8836e and sha256:0d57e8596e67827cae8ac8821eceb5953f07bc8ee21fadba083e777d760350b5), each with its own SOURCE line. The host checks above ran the merged head be2dc1a5730f42a755b5be7f5caa3108249baa82 and main 3661a4281425a71eb5f2a56922f0f2a33e5f4f17, each on a fresh git archive tree, with Zig 0.17.0 on x86_64, no GPU and no checkpoint.
  • Paths and platforms the change reaches, which I ran and which I could not: the off path's buffers and width, the on path's width selection, the sweep's window and the guard it passes through, and the KV pool's window rows run on every platform as host tests, and the environment tests cover the switch's text; the probe, the 48-row window and the late-log contract at 48 rows need a CUDA GPU and run in the receipt window. TP=1 CUDA with drafts is the only served configuration it changes; TP=2, Metal and HIP are untouched.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: concurrent equals solo, drafted equals "draft": false and resumed equals fresh on every arm, cache on and cache off; the tallies read 13/0, 24/0, 56/0, 156/0 and 7 of 7, 8 of 8, greedy token hashes 528 equal and 0 unequal, drafts off 42 equal and 0 unequal: no unequal pair anywhere. The code argument is above; the check is the gate, and a machine that fails it serves 32 rows, which is main's behaviour.
  • Main against this branch, same machine and checkpoint, posted before asking for a run on our machines (or why you can't): this section, with the raw tables in docs/receipts/flashnext-copy-window/ and the arm logs behind them; nothing is asked of your machines before it exists.
  • Decode speed before and after, from tools/bench_openai.py: level within the noise rule at 1, 2, 4, 6 and 8 streams. B0 against main 0 faster, 14 level, 0 slower; B1 against main 2 faster, 12 level, 0 slower; B1 against B0 2 faster, 12 level, 0 slower over the pass A cells. Copy cells decode tok/s 246.8 to 296.2 across the arms, the table in docs/receipts/flashnext-copy-window/.
  • Prompt speed before and after: time to first token level at 2k, 8k, 32k and 64k under the noise rule (cold cache, prompt cache off), B1 1.061 s against B0's 1.055 s at 2k and 33.068 s against 32.977 s at 64k; the change reaches decode windows only, and the check runs before the first prompt, so it can move boot time and not prompt processing.
  • Licence of any new weights or drafter, or "n/a": n/a, no new weights and no new drafter.

Checklist

  • The title and description match the head commit.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • 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.
  • 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.
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled.

The inference block is closed from the receipt above, except its last line: the receipt measures decode and prompt processing against main (level at every cell under the noise rule) and the off path's buffers against main's, but it does not measure --drafter against without it, so that comparison is not claimed and the line stays unticked.

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @BadAd84. The shape is right: off is exactly main, and a width past the shipped one is served only when that boot measured every row equal to its one-token step, capped at the pending-row log the window already owns, with any failure falling back to 32. The centralized policy and the byte pins at both sizes make it checkable.

One thing is open: the checks have not run on this head yet. Please push it and post the result as you planned.

We will read the check own log line on a GB10 boot on our side once it lands; we were unable to run any GPU cell here.

  • Synthena

@AIFlowML

Copy link
Copy Markdown
Contributor

@BadAd84 @ashhart I ran zig build test-flashnext-window-host test-environment-host test-gradient-serving test-qwen-serving-host --summary all at the current PR head be2dc1a57. All 14 steps and 57 tests passed on both macOS arm64 (-Dcpu=apple_m1) and Linux x86-64 (-Dfixed-cpu), with Zig 0.17.0 and umask 022. This covers the host window, buffer and settings checks. The GB10 boot result still needs device evidence on the landing head.

The first detail missing from the receipt is how to rerun the evidence on the current head. The old green CI note names da430818f. On be2dc1a57, the Windows job fails because the fake server's two streams did not overlap. Main already has 5128892b1, which lengthens that fixture, and I ran the six fixture tests there successfully on macOS. This PR's head still has the shorter version.

My test merge with 9ad727fcd conflicted only in zig/tests/fixtures/gradient-serving.tsv. Integrating current main, regenerating the affected pins and rerunning the Windows job would pick up that fixture change and give the receipt a current CI result.

Igor Lessio - AIFLOW LABS

ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 21, 2026
… proves

The net change of ashhart#4075 at be2dc1a over its merge base 3661a42, as one commit: the branch's merge commits hold changes of their own.
ashhart added a commit to BadAd84/TensorFold that referenced this pull request Nov 21, 2026
@ashhart
ashhart force-pushed the flashnext-copy-window-up branch from be2dc1a to 28e7cc4 Compare November 21, 2026 08:12
ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 21, 2026
… proves

The net change of ashhart#4075 at be2dc1a over its merge base 3661a42, as one commit: the branch's merge commits hold changes of their own.
ashhart added a commit to BadAd84/TensorFold that referenced this pull request Nov 21, 2026
@ashhart
ashhart force-pushed the flashnext-copy-window-up branch 2 times, most recently from 71fe442 to b578355 Compare November 21, 2026 17:29
ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 21, 2026
… proves

The net change of ashhart#4075 at be2dc1a over its merge base 3661a42, as one commit: the branch's merge commits hold changes of their own.
ashhart added a commit to BadAd84/TensorFold that referenced this pull request Nov 21, 2026
@AIFlowML

Copy link
Copy Markdown
Contributor

I rechecked b578355d9 against main 2ce240cf0 on M5 Max with Zig 0.17.0. The only textual conflict was in zig/tests/fixtures/gradient-serving.tsv. I preserved both sides’ notes for the five affected rows and hashed the merged source bytes. The CUDA sources needed no manual edits.

zig build test-flashnext-window-host test-environment-host test-gradient-serving test-qwen-serving-host -Dcpu=apple_m1 -j4 --summary all then passed 62 tests with one failure. The environment inventory expected 24 switches on both trees. Main has 25 and the trial has 26 because it adds TF_FLASHNEXT_WINDOW_CHECK. In scratch, updating the test's expected count to 26 made all 16 build steps pass.

That leaves two test-fixture updates for this rebase. This check covered host policy, bounds, and pins. I did not rerun the boot measurement on a CUDA device.

Igor Lessio - AIFLOW LABS

@ashhart
ashhart force-pushed the flashnext-copy-window-up branch from b578355 to 4e7bc21 Compare November 22, 2026 02:42
ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 22, 2026
… proves

The net change of ashhart#4075 at be2dc1a over its merge base 3661a42, as one commit: the branch's merge commits hold changes of their own.
@AIFlowML

Copy link
Copy Markdown
Contributor

I trial-merged 4e7bc21d into main 25586070b. It applies cleanly with no local edits, including the Flash Next environment count. On M5 Max with Zig 0.17.0, all 63 host tests passed and the native CUDA check compiled.

zig build test-flashnext-window-host test-environment-host test-gradient-serving test-qwen-serving-host check-native-cuda-host -Dcpu=apple_m1 -j4 --summary all

I also combined it with #2980 at a20efd9f. Only a serving-pin hunk conflicted. I kept the copy-window notes and hashed the four merged source files. The combined tree passed 162 host tests and compiled the Linux ARM64 CUDA runner:

zig build test-flashnext-window-host test-flashnext-rank-graphs-host test-kv-safety-host test-environment-host test-gradient-serving -Dcpu=apple_m1 -j4 --summary all
zig build compile-cuda-tests -Dtarget=aarch64-linux-gnu -Dcpu=baseline -Doptimize=ReleaseSafe -j4 --summary all

The actual GB10 boot width and byte parity remain the device check.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thanks @BadAd84. The boot-gated width policy and byte-exact sweep look carefully put together. One default-off mismatch remains: window buffers and open() use bufferRows() (32 with the switch unset), but State.waits() still predicts capacity using mtp.max_rows (48). With a lazy paged pool beside another stream, a request near a page boundary can therefore post and wait for a page that the open will never use, so the off path is not quite main's behavior. Could you make that prediction use the same bufferRows() capacity as open() and add a small off/paged regression test?

  • Synthena

ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 23, 2026
… proves

The net change of ashhart#4075 at be2dc1a over its merge base 3661a42, as one commit: the branch's merge commits hold changes of their own.
@ashhart
ashhart force-pushed the flashnext-copy-window-up branch from 4e7bc21 to 38ebcd5 Compare November 23, 2026 19:32
@BadAd84

BadAd84 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, that is exactly right. State.waits() added mtp.max_rows, the pending-row log's 48 rows, while open(), the window buffers and windowRows() take mtp.bufferRows(), so with TF_FLASHNEXT_WINDOW_CHECK unset the prediction was 16 rows wider than the open.

The changed line, zig/src/families/flashnext/cuda_kv_lanes.zig:

-        return s.pool.?.waits(@min(rows + mtp.max_rows, prompt.max_tokens), others > 0);
+        return s.pool.?.waits(@min(rows + windowRows(), prompt.max_tokens), others > 0);

windowRows() is mtp.bufferRows(): 32 with the switch unset and 48 when the boot check runs, so the prediction now takes the capacity open() takes. A stream without drafts still adds a window's rows, which is what main did, so the off path is main's.

The regression test is the window's waits: off, a request near a page boundary posts no page its open will not use, in cuda_kv_init_test.zig and run by test-flashnext-window-host. It builds a 96-page pool of 16 MiB pages over six fake 256 MiB pieces, maps what an open of a 224-row stream plus the shipped 32 rows takes (pages 0 to 15 and the run at 88 to 95), and asserts an off load neither waits nor queues a piece. It then sizes the buffers for the check and asserts the same request waits once for page 16 in piece 1, that the piece maps, and the next call goes on.

I ran the step on this head and on the same head with only that line reverted, so the two trees differ by this one hunk (comparing their manifests, one blob differs and it is that file):

  • Before: test-flashnext-window-host fails in the new test at its first assertion, cuda_kv_init_test.zig:358 (try std.testing.expect(!st.waits(224, 1))), 2/4 steps succeeded (1 failed); 30/31 tests passed (1 failed).
  • After: 4/4 steps succeeded; 31/31 tests passed.

The branch is your re-cut 38ebcd53bceab3d1944987185baf0b410029ab5f on main b89f5742df12 with this fix on top as 6a9c642315363691cf212e58a75a0f9ddc57da7e.

Gates, on x86_64 Ubuntu at paperclip.ots-int.net (16 CPUs, Zig 0.17.0, no GPU, umask 022, one zig build at a time under the host lock), each tree extracted from a verified git archive:

  • zig fmt --check build.zig zig: rc 0, no output.
  • Lean, each tree scanned by its own copy of the checker: base b89f5742d 7,698 files and 165 problems, head 6a9c6423 7,698 files and 165 problems, and lean_new.py reads lean: 165 problems, 165 on the base, 0 new.
  • zig build -Dfixed-cpu test-flashnext-window-host: 31/31 tests, and the same step on the before tree fails only the new test.
  • zig build -Dfixed-cpu test-cuda-host: 474/474 steps, 8,687/8,729 tests passed (42 skipped); its graph includes test-environment-host, which reports 3/3 steps.
  • zig build compile-cuda-tests: 10/10 steps; with -Dtarget=aarch64-linux-gnu: 10/10; zig build compile-native-cuda-windows: 9/9.
  • The zig/tests/fixtures/gradient-serving.tsv pins: 169 files, 0 failing. test-gradient-serving itself is excluded from CI as red on main (CI never reaches 246 of the 393 named test steps, and nine of them fail on main #2031), so I did not gate on it.

@ashhart
ashhart force-pushed the flashnext-copy-window-up branch from 6a9c642 to e9189d5 Compare November 24, 2026 00:32
ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 24, 2026
… proves

The net change of ashhart#4075 at be2dc1a over its merge base 3661a42, as one commit: the branch's merge commits hold changes of their own.
@ashhart
ashhart force-pushed the flashnext-copy-window-up branch from e9189d5 to 2683249 Compare November 24, 2026 05:01
ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 24, 2026
… proves

The net change of ashhart#4075 at be2dc1a over its merge base 3661a42, as one commit: the branch's merge commits hold changes of their own.
@ashhart
ashhart force-pushed the flashnext-copy-window-up branch from 3e63af8 to 973503d Compare November 24, 2026 14:57
ashhart pushed a commit to BadAd84/TensorFold that referenced this pull request Nov 24, 2026
… proves

The net change of ashhart#4075 at be2dc1a over its merge base 3661a42, as one commit: the branch's merge commits hold changes of their own.
@BadAd84

BadAd84 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

4c061cc57, committed 2026-11-24, made State.waits predict with windowRows(), which is mtp.bufferRows(), and added the off/paged test beside it, so both are in 973503d76. Your review of 2026-11-23 predates that commit, which is why the head you read still had the older line.

I re-ran test-flashnext-window-host at 973503d76: 31/31. With windowRows() reverted to mtp.max_rows, the off arm fails as you described: a 224-row request at a page boundary posts page 16 (224 + 48 rows) that its open (224 + 32 = 256 rows, pages 0 to 15) never uses. No other prediction in the family reads mtp.max_rows.

BadAd84 and others added 5 commits November 24, 2026 21:15
… proves

The net change of ashhart#4075 at be2dc1a over its merge base 3661a42, as one commit: the branch's merge commits hold changes of their own.
State.waits added mtp.max_rows, the pending-row log's 48 rows, while open, the window buffers and windowRows take mtp.bufferRows(): 32 with TF_FLASHNEXT_WINDOW_CHECK unset. A request near a page boundary could then post and wait for a page its open never uses, so the off path was not main's. The prediction now adds windowRows; an off and paged host test pins the page it posts, none off and page 16 when the check runs.
…switches)

The new switch is registered but the Flash Next settings test still expected 38 settings with 26 switches, so the host test failed. Test only.
@ashhart
ashhart force-pushed the flashnext-copy-window-up branch from 973503d to d7f5d83 Compare November 24, 2026 21:15
@ashhart
ashhart merged commit 1b3798b into ashhart:main Nov 24, 2026
ashhart pushed a commit that referenced this pull request Nov 24, 2026
… proves

The net change of #4075 at be2dc1a over its merge base 3661a42, as one commit: the branch's merge commits hold changes of their own.
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you @BadAd84. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

ashhart added a commit to hygurlabs/TensorFold-working-branches that referenced this pull request Nov 24, 2026
ashhart added a commit that referenced this pull request 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.

3 participants