Repository navigation
Nemotron CUDA: a masked window replays a graph, captured on first use for each row count - #660
Merged
Merged
Conversation
… for each row count A structured-output window ran eagerly: its grammar bits made it skip the verify window graphs. Its bits live in one place for every single-stream window (the lanes' device-mapped bits, slot 0), which the host rewrites before each launch, so a graph can read them like any other input. A masked window now launches a graph of its row count and draw mode, captured on the bound sequence's buffers the first time it runs (the own sequence included), as ashhart#615 does for other sequences, and captured again after a slide recapture. Bits in another place than the first window's run eagerly, as do shared windows and dumps. Nemotron 3.5 Lightning on GB10, --parallel 4, 16 structured cells (two JSON schemas, json_object, regex, choice, required and named tool calls, greedy and sampled) plus plain prose, main and this change run twice each (A B B A): every reply's token_sha equals main's, drafted equals "draft": false, and a burst of the seven greedy cells equals their solo replies. TF_GRAPH_LOG: 0 eager windows where main had 10-127 a request. Decode under a grammar +5.0% with "draft": false (12 cells, +1.3 to +6.3%), +2.2% drafted (short replies pay their first captures, ~1.5 ms each); plain prose unchanged.
Owner
|
Thank you, @BobClawblaw. The argument in your description, that every single-stream window's bits sit at one address the host rewrites before each launch, holds up, and it closes the gap the 1.0.6 notes left open. Your commit What we measured on a GB10, Nemotron 3.5 Lightning MLX 4-bit, your change against the same tree without it, both builds pricing windows from one window-cost table:
One change on our side, in a commit after yours: |
BobClawblaw
pushed a commit
to BobClawblaw/TensorFold
that referenced
this pull request
Oct 12, 2026
cuda_engine.zig reached 608 lines with ashhart#660. Its prompt pass (prefill, prefillWith, prefillFrom, redrawFirst, beforeChunk, serialChunks, setSegments, promptHost, segmentSet) moves unchanged but for indent into cuda_prompt.zig, and Engine keeps each under its old name, so no caller changes. The two pinned offsets and two lesson helpers it reads become public, and the grid import goes with it. Reversing the move rebuilds the old file byte for byte. cuda_engine.zig is 516 lines, cuda_prompt.zig 121.
BobClawblaw
pushed a commit
to BobClawblaw/TensorFold
that referenced
this pull request
Oct 12, 2026
BobClawblaw
pushed a commit
to BobClawblaw/TensorFold
that referenced
this pull request
Oct 12, 2026
…e served host (ashhart#659) and Nemotron's masked CUDA windows replaying graphs (ashhart#660)
Closed
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
cuda_engine.zig reached 608 lines with ashhart#660. Its prompt pass (prefill, prefillWith, prefillFrom, redrawFirst, beforeChunk, serialChunks, setSegments, promptHost, segmentSet) moves unchanged but for indent into cuda_prompt.zig, and Engine keeps each under its old name, so no caller changes. The two pinned offsets and two lesson helpers it reads become public, and the grid import goes with it. Reversing the move rebuilds the old file byte for byte. cuda_engine.zig is 516 lines, cuda_prompt.zig 121.
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
ashhart#660 landed above as 3fa4ea873 (the author's commit, rebased onto this candidate), with our pure move 928cd7473 after it. This keeps the PR's own head commit in the history, with no change to the tree.
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
…e served host (ashhart#659) and Nemotron's masked CUDA windows replaying graphs (ashhart#660)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #615 and the 1.0.6 notes on #564/#596 ("a masked CUDA window runs without its captured graph").
What
A structured-output window on CUDA skipped the verify graphs and ran eagerly. Now a masked single-stream window
launches a graph of its row count and draw mode, captured the first time it runs on the bound sequence's buffers
(the own sequence included) and replayed after, the same path #615 gave other sequences, under its own ids
(4000 + mode × 17 + rows). A slide recapture's epoch drops them like any other sequence graph.
Why a graph can hold the mask
Every single-stream window's bits sit at one address:
Cuda.putBits(0, …)writes slot 0 of the device-mappedbits buffer, made once and kept to the end. The host rewrites the words before each launch, after the last
window's tokens were read, the same order the eager path relies on, so the graph reads them like the window's
ids.
Engine.maskGraphskeeps the address the first masked window used; bits anywhere else run eagerly, as doshared windows (
verifySharedhas no graphs on main either) and dumps.Changes
cuda_engine.zig:Body.windowcarries aMask;recordBodypasses it towindowSegs(unmasked windows areunchanged:
window()waswindowSegswith no mask);launchGraph's capture-on-first-use half islaunchCaptured;verifyMaskedreplays through it;deinitfrees the own sequence's map.cuda_lanes.zig: TF_GRAPH_LOG's line says "replays of graphs it captured for itself" (the own sequence now has some).cuda_state.zig: the comment onSeq.graphs.Checks (GB10, Nemotron 3.5 Lightning 30B-A3B MLX 4-bit d9d758fb,
--parallel 4 --context 16384 --no-thinking)16 structured cells (two JSON schemas,
json_object,guided_regex,guided_choice,tool_choice: "required"and a named function; greedy and sampled with a seed; each drafted and
"draft": false) plus plain prose, withlibtfgrammar.sofrom the 1.0.7 archive. Main and this branch, two runs each, A B B A:token_shaequals main's (32 cells × 4 runs, 0 mismatches); drafted equals"draft": false;a burst of the seven greedy structured cells at once equals their solo replies on both builds.
TF_GRAPH_LOG=1: main ran 10-127 eager windows per constrained request, this branch 0. The own sequence's firstmasked request captured 8 graphs (12 ms); later ones replay.
tokens_per_second, mean of two runs): under a grammar"draft": false+5.0% (12 cells, +1.3 to+6.3%), drafted +2.2% (−4.9 to +4.3%: replies of ~0.6 s pay their first captures, ~1.5 ms each); plain prose
+0.2%.
zig build testandzig fmt --checkpass on Linux aarch64.