Repository navigation
CUDA (GB10): Flash Next KV in the display carveout, opt-in - #2763
bertholomus wants to merge 10 commits into
Conversation
|
Thanks @bertholomus. Counting the carved planes into the room the streams are planned in, rather than
|
|
Thanks @ashhart. 1. You read it correctly. It is a fault in this head. The Nov 4 runs had 2. We will add a host test for the 3. Receipts on this head with both sources are not run yet. Noted that the five-stream cell waits for #2753. 4. We will rebase on #2762 once the shared opener settles there. This stays a draft.
|
|
Thanks @bertholomus for checking so quickly and for finding exactly what the rebase dropped. The plan sounds right:
A few small things for the next push:
|
|
Pushed the fix for the fault you found: 468b35e on this branch (one commit on f271b73, fast-forward).
Not done yet, as you asked: the rebase waits until @BadAd84's fold in #2762 settles. After it, the carve opener becomes a call to the shared opener in |
|
Thanks @bertholomus, that's the fault fixed. Two small things for the next push:
The rest is as agreed: receipts on the new head with both sources (the five-stream drafts-on cell after #2753), then the rebase onto #2762's fold with the opener moving to the shared one and the room helper to its own file. It stays a draft until then, which is fine.
|
|
Pushed 35dbd00 on this branch (fast-forward from 468b35e), for your two points:
One file changed. |
|
Thanks @bertholomus, both are in on
|
35dbd00 to
5bad6de
Compare
|
Thanks @bertholomus for the rebase onto #2762's new head. This head (
Still open from our 11 Nov note:
New on this head:
CI hasn't run on this head yet. It stays a draft until the receipts are in, and it lands after #2762. Once the receipts are posted, we'll repeat what we can on a GB10 with Qwen3.8-Flash-Next.
|
c0b02d0 to
d0fb048
Compare
Rebase onto upstream main and round-7 gates (2026-11-17)Branch
|
|
Thanks @bertholomus for the rebase onto main. On Still open from our 12 Nov note:
This lands after #2762. The branch carries its own copies of #2762's two commits (
|
d0fb048 to
383d2e2
Compare
Round 8: points 2-4 on the new head; point 1 (device receipts) scheduledBranch 2. The opener now runs before the load. 3. 4. Description and changelog. The description now covers this head. The CHANGELOG line ends with "Thanks to @bertholomus." and also names the early open. 1. Receipts on this head, card and daemon. Not run yet. All our GB10 boxes are on another job until it finishes. When one is free, we will run your full list on this head on one box: main against branch with the carveout off; carveout on against off for the card and the daemon, with greedy hashes and seeded tokens; decode and prompt speed at one stream and at the widest admitted; and the five-stream drafts-on cell. On this OS the card source is refused ( Once #2762 is in, we will drop its two commits ( Gates on
|
Point 1: device receipts on
|
| Measure | main | head off | head daemon |
|---|---|---|---|
Greedy decode, 1 stream, bench_openai code |
72.0 | 71.5 | 71.5 |
Greedy decode, 1 stream, bench_openai chat |
45.9 | 45.8 | 45.8 |
| 3 streams, greedy, code | 191.4 | 190.8 | 191.0 |
| 8 streams, greedy, code (512 pages) | 367.4 | 367.8 | 367.9 |
| 8 streams, greedy, chat (512 pages) | 243.3 | 243.3 | 243.6 |
| 5 streams, drafts on, greedy, code | 266.3 | 266.5 | 265.9 |
| 8K cold prefill (ttft, s) | 4.38 / 4.36 | 4.35 / 4.37 | 4.37 / 4.37 |
The 32K cell reuses the 8K prefix from the cell before it, so --require-cold marks it unqualified. The same happens in all three arms (first rows 13.3 s in each).
What the carveout buys.
- Point 3, from the startup lines: carveout off gives 3 streams and a 4.6 GiB prompt cache. With the daemon, the carveout holds 2,032 of the 2,044 MiB (keys and values of 3 attention layers, indexer keys of 7, pooled keys of 3), and the host prompt cache grows to 6.6 GiB. Before this head it came out smaller.
- At 512-row pages, main and head off take 1,384 pages. Head with the daemon takes 1,519 pages, which is +135 pages or +69,120 tokens.
- atticd logged one client holding 2,044 MiB during the daemon arms, and nothing lent after them.
The card source. On this OS it refuses with DumbBufferRefused (needs nvidia_drm modeset=1 ...), as in our earlier runs. With point 2 in place, the refusal came 10 s after the container started and before any layer loaded (the log has no loaded layer line). That is the early-refusal receipt for point 2. We have no box with modeset on, so the card's on-against-off comparison is the one cell still missing. If you have a GB10 with the card source available, that cell is yours to run.
From our side, all four points are now answered on this head. Tell us if you want this marked ready, or kept as a draft until #2762 lands and its two commits come out of this branch.
|
Thanks @bertholomus, this answers all four points. Every arm keeps its tokens, speed is level with main, and with the daemon the carveout adds 135 pages at 512 rows (+69,120 tokens). Thanks too for the early-refusal receipt for the card source. Please mark it ready. We are rebasing #2762 onto main now and will land it first, then this PR on top once our own GB10 cell on the final head agrees. The card-source on/off cell would be nice to have, but we won't hold the PR for it, since the card refuses early and cleanly.
|
|
I trial-merged zig build test-environment-host test-env-defaults-host test-gradient-serving check-native-cuda-host test-flashnext-buffer-plan-host -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j3 --summary allExit 0, with 191 tests passed and three skipped. The serving pins passed and the Linux ARM64 CUDA runner compiled. The GB10 comparison on the final landing head remains the device gate after #2762. Igor Lessio - AIFLOW LABS |
383d2e2 to
8c4715e
Compare
cde282b to
dd7d993
Compare
|
I replayed only the Flash Next delta of zig build test-environment-host test-env-defaults-host test-flashnext-compose-host \
test-kv-safety-host test-gradient-serving check-native-cuda-host \
-Dcpu=apple_m1 -j4 --summary allAll 34 steps passed on M5 Max with Zig 0.17.0, with 281 tests and three skips. The Linux ARM64 CUDA native build check passed. This verifies the restack and host paths. The final GB10 carveout-on/off and token checks remain device work. Igor Lessio - AIFLOW LABS |
TF_CUDA_CARVEOUT stays 0 or 1. TF_CUDA_CARVEOUT_SOURCE picks where the display reservation comes from: drm, the default and the existing dumb-buffer route, or daemon, where a display-memory daemon lends it in whole 2 MiB slices over a unix socket. Which daemon a box runs is a setting, not a code path: TF_CUDA_CARVEOUT_SOCKET (default /run/dispram/dispram.sock, kindling spark-os's dispramd, whose README publishes the default key), and TF_CUDA_CARVEOUT_KEY, or TF_CUDA_CARVEOUT_KEY_FILE for a daemon whose key is per box: spark-attic's atticd keeps /etc/spark-attic/key and listens on /run/spark-attic/attic.sock. The client, cuda/carveout_lend.zig, was written from a specification of the daemon's observed behaviour, by an agent working in a copy of this tree that held no client for the protocol. The specification, the probe scripts and their output are in the thread of pull request 2762. An ask is rounded up to a whole slice before it is sent, and a grant smaller than the ask is refused rather than fitted. The reply's granted size is the authority, ok must be true (a refusal carries a size field too), and a seekable descriptor's own length is checked as well. The slice is mapped through arena.zig's Vmm. One pair of calls serves every caller. carveout.requested decides whether the carveout is on and reads its rows through the settings table, where TF_DRM_CARD gains a row. Carveout.from opens the source the request names and logs a refusal once. The CLI and Nemotron make those two calls and nothing else. The key file is read only for the daemon source, as its claim is made. A file that is missing, not a regular file, empty on its first line or 256 bytes long there is refused with TF_CUDA_CARVEOUT_KEY_FILE named, and neither the path nor the file's bytes are shown. The startup walk validates the carveout's rows when it is on and skips them when it is off, as it already did for TF_CUDA_CARVEOUT_MIB, and reads TF_DRM_CARD only while the carveout is on and the card is its source. Off Linux the claim returns NoDaemon before any of the protocol code is analysed, so the Windows host tests build. The client gives the daemon 10 seconds to answer, and a daemon's rows are read only while the daemon is the source, as the card's are only while the card is. Host tests, in carveout.zig and carveout_lend_test.zig (the second runs on Linux only): the request's rows and their defaults, the key file's accepted and refused forms, the key file left unopened for the drm source, and a fake daemon on a real SEQPACKET socket for a granted claim, the descriptor by SCM_RIGHTS, a refused claim, a refusal that carries a size, a malformed reply, a short grant, an ask between two slices, a missing descriptor, a missing socket, a daemon that never answers, a daemon that has gone away, the key file's line on the wire, and the daemon getting the memory back when the connection closes. zig/tests/fixtures/gradient-serving.tsv takes carveout.zig's new hash and a row for carveout_lend.zig. docs/recipes/cuda.md says what each source costs, measured on a GB10, and CHANGELOG.md gets its Unreleased bullet. Co-authored-by: bertholomus <311723197+bertholomus@users.noreply.github.com>
…aps into Vmm's own range receive reads the reply before it looks for a descriptor. A reply with ok false is DaemonRefused whether or not a descriptor came with it, and its error text is kept in a Reason that the caller passes down through claim and slab: the first 128 bytes, marked when the text was longer. Carveout's refusal line prints it with every byte outside printable ASCII written as \xNN, so a wrong key now reads "missing or unknown key" and a full reservation "not enough free carveout", where both read DaemonRefused alone before. A descriptor is taken before the reply is judged, so one that comes with a refusal is still closed, and one that comes with a reply cut at the buffer's end is now closed too, where it was left open in the process. Vmm.mapSlice maps the slice at the next free address of the range Vmm.open reserved, which claim sizes to the grant, instead of reserving a second range and leaving the first unused. A slice past the end of that range is refused before any driver call. unmapSlice only unmaps, and Vmm.close frees the whole range, as it does for the arena's chunks. CHANGELOG.md's line names dispramd alone, gives the long-prompt cost measured with it on a GB10 (a 108,012-token prompt took 35.6 s to prefill against 22.4 s with the carveout off, and decode took 11.5 against 8.85 ms a token, with the output unchanged) and ends with the pull request's number and the thanks. docs/recipes/cuda.md says a refused claim's line quotes the daemon's reason, escaped and cut at 128 bytes. Host tests: a wrong key and a full reservation, each refused with the daemon's own text as the reference daemon sends it, and closing the connection after it; a reason with an escape sequence and a C1 control, longer than is kept, written escaped and marked as cut; a grant without a descriptor, refused with no reason to report; the descriptor sent with a refusal, and with a reply longer than the buffer, closed; the reason reaching claim's caller. In arena.zig: a lent slice mapped at the start of the range open reserved with no second reservation, the handle released, a slice past a full range refused before any import, and an unmap that frees no addresses. The host tests' openFds reads getdents64 into a dirent64-aligned buffer. zig/tests/fixtures/gradient-serving.tsv takes the new hashes of carveout.zig and carveout_lend.zig.
TF_CUDA_CARVEOUT=1 puts Flash Next's KV caches in the display carveout too: a contiguous cache holds it one at a time, as many whole planes of a full window as fit (cuda_carve.zig) - the keys and values of the first attention layers (both or neither), then indexer keys, then pooled keys. A shorter cache takes the same planes, each smaller, so it fits too and never needs more device memory than a full window. The DeltaNet states, the n-gram tail, the MTP head's cache and the pool's pages stay in device memory. The memory budget counts the planes out of device memory: Loaded.carved_bytes joins the room cuda_streams.zig counts the streams in (kv_pool.streamsRoom), which the grown streams, the shared page pool, a KV ledger's plan and the kept prompt cache are sized from. So pages or streams admitted grow by about the lent bytes. Nothing is counted when another cache may hold the carveout while the first stream runs: --slide's learner, a page test, or every stream on pages. The carveout opens before the checkpoint load finishes, so a refusal keeps the page cache as any other refusal does. The startup log names the planes, their bytes and the bytes counted. Flash Next makes the same two calls the CLI and Nemotron make: carveout.zig's requested(Settings) reads every row through the settings table, TF_DRM_CARD included, and Carveout.from opens the source the request names and logs a refusal once. The daemon's rows are read only while the daemon is the source, and the card's only while the card is. cuda_carve.zig holds no opener of its own. Opt-in and off by default: without TF_CUDA_CARVEOUT nothing changes. One rank: --tp 2 with the carveout is refused (FlashNextCarveoutUnsupported). Nemotron's placement and the card source are unchanged. Only the planes' addresses change, not the math. Host tests: the plane sizes against seqBytes; the plan at 2,044 MiB, at 1,792 MiB, at a short window and with no room; every cache size up to the window takes the window's planes from an empty carveout, in order; a cache's planes by part; and the pool gaining the carved planes' whole pages (135 pages of 512 tokens for 2,032 MiB at 30,784 bytes a token) while the prompt cache stays at its budget. Test fixtures that build an Engine field by field set carve = null. cuda_lanes.zig and cuda_prompt.zig stay under the 600-line limit: an unused import goes, the layer-map test moves to cuda_prompt_test.zig, and the engine closes the carveout. docs/recipes/cuda.md and flash-next-cuda.md describe it. Credits: urtho wrote cuda.Carveout and its spans (ashhart#487), which this builds on; coolbho3k had the idea of the display carveout as KV room; ezoushen and BadAd84 put display KV into the GLM recipe; Kindling's dispramd introduced the lending protocol atticd speaks; plotarmordev gave receipts on a second Spark; Mia's Qwen3.8-Flash-Next work, her checkpoint and settings, is what this is for; Ash's TensorFold.
…es, as newSeqOn does With TF_FLASHNEXT_LANE_PARTS at its default, a server stream's contiguous cache came from seq_parts.newSeqIn, which passed no carved planes to its caches (an empty list), while cuda_lanes_load.zig still counted the carveout's planes into the room: the plan could count up to 2 GiB that no stream uses. newSeqIn takes the carved planes again under the same rule as newSeqOn (the branch before an earlier rebase had it right), so every constructor of a contiguous cache either claims the planes or the plan does not count them. cuda_seq_parts_test.zig: with lane parts on, a lane stream's first planes are the carveout's (key/value/index/pooled of the plan's counts, borrowed, the carveout no longer whole), a second stream finds the carveout held and takes nothing, and with no carve plan nothing is borrowed. It fails on the commit before this one (the caches get no planes) and passes here. cuda_lanes.zig is untouched by this commit; cuda_launch.zig registers the new test file. The serving pin for cuda_launch.zig is re-pinned to what this commit ships.
…rry no commit hashes Ash's review: the --tp 2 refusal (carveout.open checks tp before it touches the context) had no test. One now calls open() with tp = 2 and the carveout requested through the environment, and expects FlashNextCarveoutUnsupported - with a context pointer the refusal path never reads. The test's name carries no commit hash: names and comments stay free of history.
streamsRoom() took cuda_kv_pool.zig past its 600-line limit once the carveout credited the streams' room (589 lines before it, 614 with it). It moves to cuda_kv_room.zig with its test, and cuda.zig calls it there. No behavior change: the same room and the same page gain.
…s room counts the carved planes The card or the daemon opens before the glue, the engine or any weight loads, so a refusal (`--tp 2`, a missing daemon, a short card) fails before the load and the page-cache advice stays. The engine takes the carveout once its plan is set; until then an error closes it. The host prompt cache sizes beside the streams in the same room the streams were counted in: the first window's planes held in the carveout no longer come out of the cache's device room.
Main's kvHostRefusal check (4 lines in attach) takes the file to 601 with this PR; the blank line before the kv safety test goes, as main did for the cache default tests.
dd7d993 to
57d05d3
Compare
|
@bertholomus Thanks for the carveout work and the device receipts. One small thing: with
|
What this changes
Before: with
TF_CUDA_CARVEOUT=1, Flash Next keeps all of its attention caches in device memory.After: one contiguous Flash Next cache holds the display carveout and keeps there as many whole planes of a full window as fit. The memory budget counts those bytes out of device memory, for the streams and for the host prompt cache beside them. The card or the daemon opens before the weights load, so a refusal fails fast. Without
TF_CUDA_CARVEOUTnothing changes.d86246ca,3a377acf, Adam's, unchanged) and will drop them once CUDA (GB10): a lending-daemon source for the display carveout, opt-in #2762 is in. This pull request's own commits are the five after them, ending at383d2e2a.mainate7ff97e132f2268c7c52bf55d1b8bdbb033462f3.Checks on this head
383d2e2a.zig fmt --check build.zig zigandgit diff --check: clean.python3 tools/pr_check.py --base e7ff97e13 --pr 2763: 0 errors, 0 warnings. Lean 219 on this head against 221 on the base, 0 new.zig/tests/fixtures/gradient-serving.tsv: every row matches its file (170 rows).zig build test-gradient-serving: 1 of 1 passed (rc 0).zig build test-cuda-host --summary all(umask 022): 418 of 418 steps, 2,483 of 2,492 tests passed, 9 skipped, 0 failed (rc 0). Under umask 0002 the one failure is thecli_config_testcase we reported in round 7, which fails the same way on baremainon this box.the open path opens the carveout before the glue, the engine or any weight loads) fails on the previous head21e4a34fwith only that test added: fails (error: 'cuda_seq_parts_test.test.the open path opens the carveout before the glue, the engine or any weight loads' failed). ThecacheRoomtest does not compile there, because the function is new.Receipt
8db1ee1aplus this stack, 2026-11-04): an ASUS Ascent GX10 (GB10, SM 121) on stock DGX OS 7.6.0, kernel 7.0.0-1024-nvidia-64k, driver 580.178.04, spark-attic 0.1.0 lending 2,044 MiB. Qwen3.8 Flash Next, bf16 KV, text only,--context 262144 --parallel 5, three arms on one boot: off, attic, off again. KV pool 224,256 to 293,376 tokens (+135 pages of 512). 2,032 of the 2,044 MiB held the keys and values of 3 attention layers, the indexer keys of 7 and the pooled keys of 3. Replies equalled the off arm for 8 of 8 prompts at temperature 0 and 3 of 3 seeded at 1.0. Decode tok/s attic against off and off again: 1 stream 45.1 against 45.6 and 44.9; 5 streams with drafts off 77.7 against 78.9 and 77.4. Prefill tok/s: 8K 2,097.8 against 1,929.0 and 2,085.1; 32K 2,061.0 against 2,060.8 and 2,048.0.DumbBufferRefused). The receipt will show that refusal by name, and the daemon arm carries the on-against-off comparison.TF_CUDA_CARVEOUT=1.--tp 2with the carveout is refused before the load.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.
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.Not ticked: these need the device receipts on this head.