Repository navigation
Conversation
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.
Brings upstream main at 93de4c7 into the branch at 902b0a3, so the pull request is judged against current main and no pushed commit is rewritten. One conflict, CHANGELOG.md: both sides insert at the top of Unreleased. This branch's ashhart#2762 bullet stays first and every line of main's Unreleased block is kept as main has it, so the merged changelog is main's plus that one bullet. Four files both sides changed merged on their own and keep both sides' changes: docs/environment.md and zig/src/platform/environment.zig (this branch's carveout rows beside main's new settings and its blank-default rule), zig/src/platform/environment_test.zig (their tests), and docs/recipes/cuda.md (main's API-reference line and this branch's daemon section). zig/tests/fixtures/gradient-serving.tsv keeps both sides' rows, and this branch's carveout.zig and carveout_lend.zig pins still match the merged files.
…ut first With the display carveout on (TF_CUDA_CARVEOUT=1, the lending client from pull request 2762), each of the DeepSeek-V4.1 KV pool's family tensors is taken from the carveout when it fits there and from ordinary device memory otherwise, first fit in family order, and each span goes back to the carveout when the pool is torn down. With the carveout off every tensor comes from cuda.DeviceBuffer.alloc as before. No setting is added: the carveout's own rows, already in the settings table, decide it. A span the carveout lends is zeroed by Carveout.take on the legacy stream, which the compute stream does not wait for, so the pool syncs the device once when it took one; an ordinary allocation's fill runs on the compute stream and orders there already. The load-time check (kv/budget.zig) charges the pool only for the part that stays in device memory. The carved part is not assumed: DevicePool.carvedBytes runs the same first-fit placement the allocator makes over a copy of the carveout's spans, so the check uses the placement's own figure. The largest pool the terms still admit is priced with those bytes as room, and the figures kept for the end-of-boot check hold the device part, so its measured growth stays a measurement of memory the kernel can see. A carveout asked for without TF_DSV41_POOL_TOKENS stops the load with CarveoutWithoutPool: the carveout exists to hold the pool, and without one it would take memory nothing uses. A daemon or card that is not there, or a refused claim, stops the load at the client's own line, and a refused claim's line carries the daemon's reason. A malformed carveout row is refused by its name and accepted forms, because the family's startup walk covers only its own rows. Why: at a 1,048,576-token context a two-GB10 pair's 3,932,160-token split pool leaves rank 0 less than half a GiB above the 2 GiB hard floor at its worst point; with part of the pool in the carveout's slice the margin is more than a GiB. The slice costs prompt speed, not decode, which is why it is opt-in. The receipts, and the image they were measured on, are in the pull request. Host tests: kv/budget.zig's check with a carved part (the worst point lifted by the carved bytes, those bytes counted as room for the largest pool that fits, a carveout larger than the pool charging nothing, and a refusal whose line names the carved part); kv/device.zig's placement (family order, a family that does not fit left to device memory while a later one still fits, and the spans untouched by the dry run); and carveout_kv_test.zig in the device host steps (off unless asked for, with or without a pool; refused without a pool; refused by name for a malformed row and for a slice under the source's unit; and a load stopped by a daemon that is not there, with nothing left allocated). CHANGELOG.md gets its Unreleased bullet above the carveout client's.
|
Receipts for this draft on the stack it sits on: head Two deviations, the same on both arms:
Token ids, base against head, carveout unset Both arms ran the same environment file byte for byte. Two prompts ( Resume equals fresh Raw token ids, so the first request's end is a strict prefix of the second. Rank 0 logs The carveout at boot With the carveout on, the whole pool is placed in the display carveout on both ranks: 8 of 8 family tensors, 0 MiB of it charged to device memory, at pool sizes 1,127,429 tokens (1,141 of 1,141 MiB) and 846,032 tokens (856 of 856 MiB). What we do not have on this stack No timing number: the second GB10 was held by another session's builds through every timing window, so every decode, prompt and capacity cell was discarded as confounded instead of quoted. The refusal cells at 1,048,576 context were also not taken, for the same reason. |
|
Additional GB10 placement evidence for this PR: our local DeepSeek backport uses the space remaining after compressed caches for RoPE tables and five index workspaces, reaching 2,042.026642 MiB of a 2,044 MiB claim on each TP2 rank. This is a field report from an older serving tree, not a test of PR #3592's head or a patch ready for current main. The allocation categories may be useful when extending the new KV-family implementation. Environment and source
Useful placement, per rank
The workspaces are prompt Both ranks logged the exact category totals. Alignment takes 2,272 bytes and 2,066,944 bytes remain unused. Relative to the cache-only integration, this moves an additional 1,207,984,640 bytes / 1,152.023926 MiB per node. Rank 0's cold native allocation counter fell from 112,043,696,164 to 110,835,711,524 bytes, exactly that difference. These are useful-placement and allocation-counter measurements, not a claim of added physical RAM or an equivalent instantaneous Linux Checks and bounded timings
Single matched comparison through our serving gateway, cache-only 890 MiB → expanded allocation, not attic-off → on and not upstream main → PR:
These end-to-end timings include reasoning and answer generation. They are not repeated throughput benchmarks or proof of a general speedup, and they do not establish performance for PR #3592's current head. Availability and limitsOur local opt-in has an The earlier cache-only revision passed a paired OS reboot. The expanded revision passed a cold model restart and persistent-pin checks; it has not yet been exercised through another OS reboot or an actual OS/driver upgrade. No full endurance/capacity rerun or independent raw-token-ID comparison is claimed here. The contribution is measured evidence for additional long-lived allocation categories and optional fallback semantics. |
|
Thanks @BadAd84. The current-stack carveout-off token checks and logged RAM resume are useful, as are the enabled boot-placement rows. The idle-pair timings, capacity/refusal checks and enabled-versus-off serving equality remain open; the newer expanded-placement report is explicitly an older backport. Please keep those receipts tied to the exact integrated stack, including the shared float-linear patch. #2762 remains the prerequisite.
|
Stacked on #2762: this branch contains #2762's commits and the merge with main; the diff against main shows them until #2762 lands. Review the last commit only; it must land after #2762.
What this changes
With the display carveout on (
TF_CUDA_CARVEOUT=1, the client from #2762), each of the DeepSeek-V4.1 KV pool's family tensors is taken from the carveout when it fits there, first fit in family order, and from device memory otherwise. The load-time memory check then charges the pool only for the part in device memory. With the carveout off nothing changes: every tensor comes fromDeviceBuffer.alloc, as on main.902b0a307with main93de4c724merged in (7d67a0d41, tree8339fe4aa), then this pull request's one commit (f272c709f, treee697f7ef7). Main has moved since that merge and itsCHANGELOG.mdconflicts with CUDA (GB10): a lending-daemon source for the display carveout, opt-in #2762's bullet again; this branch takes main again, by a merge commit, when CUDA (GB10): a lending-daemon source for the display carveout, opt-in #2762's branch does.atc overlap --json(atc 0.9.6, 2026-11-16 13:03 UTC, main at9e00f2cb5, on this head's tree):complete: false(pullFilesUnavailable,timeLimit): it could not read the files of all 419 open pull requests in its time limit.git merge-treeagainst every open pull request that shares a file with this branch or whose file list GitHub cuts at 100 files, and CUDA (GB10): a lending-daemon source for the display carveout, opt-in #2762: 232 in all. This commit adds no conflict to any of them.budget.zig,cuda_model.zigordevice_host_test.zigwith it and merge cleanly in them. dsv41: serve structured output with the lane core's grammar masks #1665, dsv41: serve structured output with the lane core's grammar masks (from #1665 by @nuk3s) #3026 and deepseek_v41: opt-in per-layer hash files for TP repeat divergence (split from #2030) #3297 already conflict with main elsewhere.docs/environment.mdandzig/src/platform/environment.zig; Prefill on a GB10, decode on a Mac: long prompts for Qwen3.8-27B handed over ConnectX (#1594, step 2b) #2648 and Draft: DeepSeek-V4.1 prefill on a GB10 pair, decode on Metal over the #2648 hand-off (alignment base) #3386 inzig/src/platform/environment.zig; cuda aot: refuse a captured spec whose launch PDL disagrees with its PDL constant (#2715) #2899 inzig/tests/fixtures/gradient-serving.tsv; cuda: TF_CUDA_HOST_WFE, opt-in WFET waits for the RoCE proxy and GLM token readbacks #2922 and qwen3_5: CUDA and HIP settings through environment.zig, refused at startup by name #3520 inzig/src/platform/environment_test.zig; logit_bias: token biases and -100 bans on each row's draw for Qwen CUDA, Qwen3.5-2B Metal and Nemotron Parse HIP #3146, docs: move README sections into docs/, short human README #3170, info prices a Qwen3.8-27B-class Metal start from the charge serve makes (#2761) #3268 and dsv41: its 118 settings through the shared environment validator, refused by name at startup #3557 inCHANGELOG.md; families: Nemotron, GLM, Qwen 27B, MiniMax and Dory settings through environment.zig #3558 inCHANGELOG.mdandzig/src/families/nemotron/cuda_native.zig.Checks on this head
f272c709f(treee697f7ef7d7a), on the merge7d67a0d41(tree8339fe4aa0e1).python3 tools/zig/lean_check.py, on the base and on this head: each tree's own checker, the base (the CUDA (GB10): a lending-daemon source for the display carveout, opt-in #2762 merge) 6,552 files and 219 problems, this head 6,553 files and 219 problems, 0 new (lean_new.py). The 219 are inherited: main alone has 221.python3 tools/pr_check.py --base origin/main: 18 changed files, 0 errors, and the one advisory warning that the Unreleased line names no pull request number yet.zig build -j4 -Dfixed-cpu <step> --summary allon this tree:test-dsv41-device-host225 of 225 tests,test-dsv41-forward172 of 173 (1 skipped),test-dsv41-draft137 of 137,test-dsv41-shared102 of 103 (1 skipped),test-dsv41-cuda-host69 of 69,test-cuda-host6,772 of 6,805 (33 skipped),test-environment-host27 of 27,test-env-defaults-host117 of 117,test-environment-report-host39 of 39 andtest-gradient-serving1 of 1.test-dsv41-kv,test-dsv41-env-hostandtest-dsv41-statepass, with Zig reusing the runs of identical test binaries.compile-dsv41-server,compile-dsv41-device-host,compile-dsv41-kv,compile-dsv41-toolandcheck-native-cuda-hostbuild.test-host, the CI job's Linux step: 11,841 of 11,938 tests passed, 96 skipped, 1 failed. The failure isbringup_test's "a peer that stops after agreeing is found dead by name within the membership's dead time", a timing bound in main's ownzig/src/cluster, which this change does not touch; it failed while the host was under heavy load and passed when its step ran alone (37 of 38, 1 skipped). Before the change the three new tests do not compile (the base has noopenCarveout,Measured.carvedorDevicePool.carvedBytes), and 7 mutants, each reverting one decision of this change, are each killed by the test written for it.zig build testas a whole;test-host, the CI job's Linux step, is listed above.Receipt
The receipts below were measured on 2026-11-14 on an image of upstream v1.2.7 (
93a2e93ec) with #2762's round-6 client and this change re-seated on it. That image also carried six more changes of ours that this branch does not contain and does not need, among them the float-projection setting our checkpoint needs to load. Receipts on this head's base are to follow.TF_CUDA_CARVEOUT,TF_CUDA_CARVEOUT_SOURCE,TF_CUDA_CARVEOUT_MIB); unset, nothing changes. No profile row.--tp 2on one ConnectX-7 cable (NCCL), kindling spark-os with dispramd lending 2,046 MiB a box,TF_CUDA_CARVEOUT_SOURCE=daemon. CheckpointMia-AiLab/DeepSeek-V4.1-Flash-1017-EXL3-EAQ-v1.1-2.9-bpwataee640e2. The image's Zig, driver and CUDA toolkit versions were not recorded with these receipts; they will be with the receipts to follow.DeviceBuffer.allocand the check charges the whole pool.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: from our own harness, not upstream's tools (those runs come with the receipts to follow). It compares token-id sha256 digests of fixed prompts.tools/bench_openai.py: from our own harness (carveout on against off, A B B A).tools/bench_cache.py.What the carveout buys, from the same receipts:
The hard floor in those boots was 2 GiB (
TF_DSV41_FLOOR_HARD_GIB=2.0). Without the carveout the 1,048,576-token boot runs within 0.28 GiB of it by the check's prediction; with the carveout, rank 0 never sampled below 3.11 GiB.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. Measured on the older image above; to be repeated on this head.No precision traded for speed. If the bits change, the description says which sums change and why. No sum changes: only the memory the pool's tensors live in.
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. With the carveout off this is main's code path. With it on, prompts are slower, as measured above; that trade is why it is opt-in.