Skip to content

perf(nemotron cuda): prompt_logprobs reads 256 rows a head pass - #776

Merged
ashhart merged 1 commit into
ashhart:mainfrom
plotarmordev:perf/nemotron-prompt-rows-batch
Oct 13, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
plotarmordev:perf/nemotron-prompt-rows-batch

Conversation

@plotarmordev

@plotarmordev plotarmordev commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

prompt_logprobs on Nemotron CUDA reads its prompt rows through the head 256 rows a pass instead of 16, so the head's weights are read once for every 256 rows. The pass writes into a logits buffer of its own (64 MiB, made at the first such request). Without the memory it keeps 16-row passes. The rows are unchanged to the bit.

  • cuda_prompt_rows.zig: batch_rows = 256; PromptRows carries its row count and logits buffer.
  • cuda_lanes.zig: the prompt_logits buffer, and prompt_out sized for 256 rows.

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: the prompt_logprobs array is byte-identical to 1.0.8 at 0, 5 and 20 alternatives on 563-, 3,377- and 8,741-token prompts, every run. Requests without prompt_logprobs are unchanged in time (0.556 s against 0.555 s at 3.4k tokens).

  • Speed, a 1-token reply with prompt_logprobs (2 starts an arm, 3 calls each):

    prompt alternatives 1.0.8 this change
    8,741 tokens 0 2.04 s 1.46 s -28%
    8,741 tokens 20 2.55 s 1.79 s -30%
    3,377 tokens 0 0.81 s 0.58 s -28%
    3,377 tokens 20 1.02 s 0.71 s -30%

    The extra cost of prompt_logprobs on the 8,741-token prompt fell from 0.70 s to 0.13 s.

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

  • Not run, and why: Metal (unchanged). The NVFP4 checkpoint and RTX cards (no hardware here). Note: this and perf(nemotron cuda): the lone driver takes requests with logprobs #777 each open a ## Unreleased section in CHANGELOG.md, so whichever lands second takes a trivial merge.

Checklist

  • 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. (The same head kernels over more rows a pass; every row byte-identical.)
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran: CUDA GB10 only.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (The existing prompt_logprobs tests cover it.)
  • 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.

…256 rows a pass

A logits buffer of its own (made at the first prompt_logprobs request) lets each head pass take 256 prompt rows,
so the head's weights are read once for all of them; without the memory the pass keeps state.max_rows.
@ashhart
ashhart merged commit 6485d23 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. Reading the prompt rows through the head 256 at a time is a small change that does a lot for long prompts with prompt_logprobs. It landed in 1.0.9 under your name (067c84543) with the same code; only the CHANGELOG needed a hand merge. Your head is merged after it with no change to the tree (6485d23ef), so GitHub shows this PR as merged.

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

  • Exact. The prompt_logprobs rows were byte-equal to the 16-row passes at 300, 3,377, 4,097 and 8,741 tokens, with 0 and 20 alternatives, on MLX 4-bit (our kernels and the captured set) and NVFP4. So the prompt GEMM gives a row the same bits at 16 and 256 rows on all three, which was the part we wanted to see.
  • Speed. Four servers a build in a mirrored order, MLX 4-bit: the extra time prompt_logprobs adds to an 8,741-token prompt fell from 0.71 s to 0.12 s at 0 alternatives and from 1.21 s to 0.47 s at 20 (1.94 s to 1.35 s in all at 0), and on 3,377 tokens from 0.29 s to 0.06 s. That's close to your receipts.

The 64 MiB logits buffer stays for the server's life once the first such request makes it; the CHANGELOG line says so.

@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
The contributor's commit landed above with the same code; 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