Repository navigation
prompt_logprobs on /v1/completions for the CUDA lanes (#449) - #647
plotarmordev wants to merge 6 commits into
Conversation
…CUDA server) A stream's content chunks carry the logprob rows of the answer tokens their text completes (rows copied from the mailbox with each round's tokens), so the rows joined over a stream are the whole reply's, answer-only with thinking on. /v1/completions takes the legacy integer logprobs (0-20) and answers in the legacy form (tokens, token_logprobs, top_logprobs, text_offset), whole and streamed. Tools, stop strings, structured output and a thinking budget stay refused with logprobs. Refs ashhart#449.
The CHANGELOG entry moves under Unreleased; chat.zig stays at 600 lines (the tail's sent text folds into rest).
The prompt-rows pass moves to cuda_prompt_rows.zig and the prefill rate to lane_host_status.zig, so cuda_engine.zig and lane_host.zig stay within 600 lines.
|
Brought up to date with 1.0.6 by a merge on top of #645's, with no force-push. To stay within 600 lines:
Re-checked at this head:
|
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
|
Thank you, @plotarmordev. The rebase overlapped with three things, and we kept both sides each time. Structured output (1.0.6) verifies windows through We gated it on a GB10 with Nemotron 3.5 Lightning (MLX 4-bit). A gate-only build dumped the logits your head pass produced, and we checked every prompt row against float64:
On cost, Thanks as well to @Bizuayeu for the spec in #399 and to @jetnet for asking in #298. |
The prompt pass's rows move out of cuda_engine.zig (613 lines with Living Weights) into cuda_prompt_rows.zig, the long comments fit 120 columns, and lane_host.zig stays at 600 lines (runLone no longer repeats admitOne's start time; one single-use alias goes). No behaviour changes. Co-authored-by: plotarmordev <[email protected]>
ashhart#647 landed above as 370069e (the author's commit, rebased onto this candidate). This keeps the PR's own head commit in the history, with no change to the tree.
The two lines name their PRs, say what a GB10 measured, and credit the author.
….8 candidate CHANGELOG: ashhart#645 and ashhart#647 stay under Unreleased; 1.0.7's section is the release's.
The prompt pass's rows move out of cuda_engine.zig (613 lines with Living Weights) into cuda_prompt_rows.zig, the long comments fit 120 columns, and lane_host.zig stays at 600 lines (runLone no longer repeats admitOne's start time; one single-use alias goes). No behaviour changes. Co-authored-by: plotarmordev <[email protected]>
ashhart#647 landed above as fdca11b (the author's commit, rebased onto this candidate). This keeps the PR's own head commit in the history, with no change to the tree.
The two lines name their PRs, say what a GB10 measured, and credit the author.
….8 candidate CHANGELOG: ashhart#645 and ashhart#647 stay under Unreleased; 1.0.7's section is the release's.
What this changes
prompt_logprobson nonstreamed/v1/completions, on the native CUDA server: the next part #449 kept open. It is stacked on #645 (its first commit is #645's), so please review #645 first; this PR's own change is the last commit.The shape follows vLLM and @Bizuayeu's spec in #399, which @jetnet asked for in #298:
prompt_logprobs: k(0 to 20) giveschoices[0].prompt_logprobs,nullfor the first prompt token, then per prompt token an object keyed by token id whose first key is the prompt token itself, followed by thekbest tokens, each{logprob, rank, decoded_token}. The prompt token'srankis vLLM's: every vocabulary token at or above its logit, itself included, so a tie counts against it; the best tokens are ranked by place.What refuses it, so a client never gets a silent empty list (your point on #298): chat, streaming, and any engine whose lanes backend doesn't produce prompt rows (
Info.prompt_logprobs, from the backend'sprompt_rows). A request with it never resumes a cached prefix, because every row has to go through the head.How:
logprob_rows.cuh: the row gains one word, the pick's rank, counted over the vocabulary only when asked (rank); generation rows passfalseand write 0.cuda_engine.zig:PromptRows. When a prompt pass carries it, each chunk's rows (already inp_hidden) go through the head 16 at a time into thelogitsscratch, andlogprobRowsreads them against the next prompt tokens. That pass takes the serial chunk path rather than staggered segments.cuda_lanes.zig:prefillFninstalls the hook for that one pass, with its own small mapped buffer so a prompt pass never writes over another stream's pending window rows, and the rows land inStream.prompt_rows.lane_host.zig: skips the prompt-cache lookup for these requests, keeps them off the lone driver, and emits.prompt_logprobsright after.prefilled.fields.promptLogprobs,logprobs.promptValue, andInput/Replyfields.chat.zigwas at 600 lines, so its privateMailboxmoved, unchanged apart from the new event, toserver/mailbox.zig.Receipt
TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit@d9d758fb, this branch ona6aa4782built withzig build native -Dnvcc=… -Dsm=121in the NGC PyTorch 26.07 container, built-in kernels,--context 16384 --parallel 4.nullfirst, prompt token first, ranks consistent with the best tokens' places including ties, logprobs ≤ 0, fork= 0, 5 and 20 and for a 5000-token prompt (3 chunks).[null]."draft": falseand a repeat give identical rows.logprobs, equal their runs alone, both kinds.prompt_logprobs.logprobs, then send P+C withprompt_logprobs. On a prose and a code prompt, every generated token ranks 1 (or ties for it) in the prompt pass. Over the 48 positions, |prompt logprob − generation logprob| has median 0.000, 25 exactly equal, p90 0.034 and max 0.114. The first generated token is read from the prompt pass's last row in both cases, and it agrees to 0.000. Larger gaps show up only at uncertain positions (generation logprob around −0.5 to −1.3). I read this as the decode/verify kernels and the prefill kernels rounding bf16 differently, not as this change: the prompt rows equal the prefill path's own rows across every chunk shape tried. My script's 0.05 gate failed on the prose prompt because of this; I'm reporting the distribution rather than moving the gate.zig build test: 37/37 steps, 429/429.k= 21, a boolean, and an engine without prompt rows.main.zig fmt --checkclean on the changed files.orelseon the prompt pass and one extra word per generation row.token_shaagainst logprobs on streamed chat completions and on /v1/completions (native CUDA server) #645's binary: not run; only with and without the field on this binary.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Prompt rows checked for all three; these requests never resume.)