Skip to content

perf(nemotron cuda): the lone driver reclaims the lane rounds' last stream - #780

Merged
ashhart merged 8 commits into
ashhart:mainfrom
plotarmordev:perf/nemotron-lone-reclaim
Oct 13, 2026
Merged

ashhart merged 8 commits into
ashhart:mainfrom
plotarmordev:perf/nemotron-lone-reclaim

Conversation

@plotarmordev

@plotarmordev plotarmordev commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

On top of #779 (its commits come first here; this pull request adds the last two). Once the requests beside a stream finish and nothing else waits, Nemotron CUDA hands the lane rounds' last live stream back to its lone driver. Before, the stream stayed in the lane rounds to its end.

  • lane_host_lone.zig reclaim, after each round: one admitted job; no queue, fills, cancels or foreground wait; a stream the driver takes, with no forced close or budget cut near. The host detaches the stream and runs the driver resumed. A resumed stream keeps what it already delivered.
  • lanes/engine.zig detach: off the live list, its round state dropped, as adopt expects it back.
  • cuda_lanes.zig reclaim: the lane's sequence bound, and its last draft's kept rows. A lane with rows not yet committed stays in the lane rounds.
  • cuda_drafts.zig Rounds.resumed and cuda_mtp.zig Head.again: the head begun again at the same rows (its meta rewritten) and level 1 drafted again.
  • engine_api.zig LoneHooks.resumed, through native/cuda.zig and cuda_native.zig.

Receipt

  • Environment: DGX Spark (GB10), Nemotron 3.5 Lightning MLX-4bit @ d9d758fb, on 1.0.8 (0efbd447), --context 16384 --parallel 4. Every server start measured its own window-cost table (a fresh cache), arms alternated.

  • Exactness: 42 replies equal 1.0.8's: logprobs pairs (greedy and seeded, 0 and 20 alternatives, the second request at 0, 0.3 or 1.0 s), thinking-budget pairs, structured pairs at four delays, and short-beside-long pairs greedy and seeded. Drafted output equals "draft": false for every request kind above.

  • Speed, an 800-token reply started beside a 60-token one (2 starts, 3 trials each):

    1.0.8 perf(nemotron cuda): the lone driver takes structured output #779 this change
    greedy, together 5.48-5.76 s 5.49-5.60 s 5.18-5.32 s
    greedy, short 0.3 s later 5.40-5.49 s 5.44-5.53 s 5.13-5.20 s
    seeded temperature: 0.8 5.48-5.68 s 5.54-5.66 s 5.50-5.68 s

    Greedy is about -5%, separated. Sampled is unchanged, and the short replies are unchanged.

  • The Grill, portable-v1 one-stream cell, 1.0.8 against this branch (all five changes): -0.18%, with its unchanged-deployment control at -0.13% (8/8 acquisitions each). No change beyond the capture drift, as expected for plain lone requests.

  • Tests run: zig build test 618/623 (5 skipped); test-cuda-host 25/25 steps; server tests 155/155 and 98/98; goldens 309/319 with 0 unexpected differences; zig fmt; lean_check as on 1.0.8.

  • New test: core/lane_host_lone_test.zig. A drafted stream handed to the lane rounds is reclaimed and resumed, with its tokens served once each, in order. A stream the driver does not take stays to its end. With the resumed delivery count reset it fails (expected 28, found 47).

  • Not run, and why: Metal (unchanged). The NVFP4 checkpoint and RTX cards (no hardware here).

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. (The lone driver is main's existing path for a lone drafted stream; this widens which requests take it. Arrivals still hand the stream to the lane rounds as before.)
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. (Same kernels and draws; only which loop drives the stream changes.)
  • Prompt processing is no slower than the last release. (The prompt pass is unchanged.)
  • The description says which platforms I ran: CUDA GB10 only.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.

It commits each round's kept rows as the lane core's windows read them (logprobRows on the window's logits)
and opens the stream with the prompt's last row, so a lone logprobs request decodes on the lone driver's
graphs and confidence depth rule.
…guards

A stream with a budget past the driver's minimum or a loop guard decodes on the lone driver until a loop
guard's close is pending or the budget's cut falls within the next round, then goes to the lane core, which
forces the close as before.
A grammar stream opens with its masked first draw; each round the grammar keeps the planned chain's rows it
allows, adds its own drafts after them and masks every row (Constraint.window, as windows.constrain does for a
lone stream), and the window is verified masked.
…ream

After a round with one live stream, no queue, fills or cancels, the host detaches it (Engine.detach drops its round
state) and runs the lone driver resumed: the lane's sequence bound, the head begun again at its last draft's kept
rows (Head.again rewrites the meta) and level 1 drafted again; a lane not settled stays in the lane core. Streams a
forced close or budget cut is near stay.
@ashhart
ashhart merged commit a72059a into ashhart:main Oct 13, 2026
2 checks passed
jschmied pushed a commit to jschmied/TensorFold that referenced this pull request Oct 13, 2026
@ashhart

ashhart commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Thank you, @plotarmordev. Giving the last live stream back to the lone driver means a reply that started beside another finishes on the fast path once it is alone. It landed in 1.0.9 under your name (7c5f9f5ce, and your test 4499d70af), and your head is merged after our two commits with no change to the tree (a72059a90), so GitHub shows this PR as merged. Those two:

  1. The batched heads. A shared round drafts its streams' heads in one batch (Nemotron CUDA: a shared round's MTP heads draft every stream in one batch #768), and that branch of draftFn doesn't go through h.chain. Your l.keep = h.keep lands on the one-stream branch as you wrote it; b6c5d7be7 records follow.len on the batched branch too, so the head is begun again at the right rows whichever branch drafted last. In practice a reclaim follows a one-stream draft (a round that batched two drafting streams leaves two live streams), but the rows should be right either way.
  2. Metal. One gate failed, and not on CUDA. reclaim runs on every backend that installs a lone driver, and Metal installs two: Nemotron's GPU round (native/metal.zig) and the 27B's serial loop on chips with tensor units (native/qwen27_served.zig). Neither reads LoneHooks.resumed; both open the stream they're given. On an M3 Ultra the last of several concurrent greedy Nemotron requests was prefilled again once its neighbours finished, and its reply went wrong from there: 1 of 2 streams at 2 and 1 of 4 at 4, every run. Sampled streams were fine, because that driver doesn't take them. The 27B, with its lone driver installed as on an M5, failed the reclaimed request with StreamBusy and left its slot busy for the next one. 4921bd621 adds resumes to the lone driver: the CUDA host sets it, and the other drivers keep their streams in the lane core as before. A host test beside yours serves a request with a driver that only opens streams and requires that it's never resumed (it fails if reclaim stops asking).

What we measured on a GB10 (sm_121), against the build without it:

  • Exact. Every reply beside a short one equalled its run alone, 10 of 10 on MLX 4-bit and NVFP4 (prose, code, logprobs, a JSON object and a thinking budget; greedy and seeded sampled), and so did the short ones. Concurrent == solo at 2, 4 and 8 streams, greedy and sampled, on MLX 4-bit (both kernel sets) and NVFP4, with each run's last stream now reclaimed. A trace build logged 16 reclaims, each with 1 to 4 kept rows and none pending, all taken by the lone driver.
  • Speed. Four servers a build in a mirrored order, MLX 4-bit: an 800-token greedy reply started 0.3 s before a 10-token one finished 1.1% to 2.2% sooner, and the same reply alone was unchanged. The pair costs the build without it 3.7% over the reply alone and the tip 1.6%. That's less than your 5%: with a short neighbour of 10 tokens, the lane core holds the long reply for well under a second either way.

On the M3 Ultra after our fix: concurrent == solo at 2 and 4 streams, greedy and sampled, three runs each, for Nemotron (a plain and a taught folder) and the 27B. In the 1.0.9 release gate, 2, 4 and 8 streams equalled their solo replies on a GB10 (MLX 4-bit and NVFP4), 4 at once did on an M5 Max with Nemotron, and the 27B's 2 and 4 at once did on an M3 Ultra.

@ashhart ashhart mentioned this pull request Oct 14, 2026
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
…date

The contributor's two commits landed above, on top of ashhart#779's. On the candidate a shared round's heads draft in one batch (ashhart#768), so the kept rows are recorded after the one-stream h.chain as in the PR and for a batched head in our commit after it; and only a lone driver that resumes a stream is given one back, in another of ours, since the Mac's drivers open every stream they are given. This keeps the PR's head in the history with no change to the tree.
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.

2 participants