Repository navigation
logprobs on streamed chat completions and on /v1/completions (native CUDA server) - #645
plotarmordev wants to merge 3 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).
|
Brought up to date with 1.0.6 ( Re-checked at this head:
|
# Conflicts: # CHANGELOG.md
|
Thank you, @plotarmordev. This landed in 1.0.8 as your own commit ( We gated it on a GB10 with Nemotron 3.5 Lightning (MLX 4-bit), against a build of the same tree without your two PRs and against the 1.0.6 release:
The refusals still hold (tools, stop strings, structured output, a thinking budget, On speed, a 256-token greedy reply with |
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#645 landed above as 284daf1 (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#645 landed above as 6f5863e (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
Two of the parts #449 kept open, on the native CUDA server, on top of #572:
logprobson streamed/v1/chat/completions. Each content chunk carries, inchoices[0].logprobs.content, the rows of the answer tokens itsdelta.contentcompletes; a token whose text isn't complete yet (a split UTF-8 character, or newlines after</think>before the answer starts) waits for the chunk that completes it, and the last chunk takes whatever is left. So the rows joined over a stream are exactly the whole reply's, answer-only with thinking on.logprobson/v1/completions, in the legacy form: the request'slogprobsis the integer count of alternatives (0 to 20), and the reply hastokens,token_logprobs,top_logprobs(each alternative's text to its logprob) andtext_offset, whole and streamed. It's built from the same rows as the chat form.Tools, stop strings, structured output and a thinking budget stay refused with
logprobs, as do the Responses route and the Metal engines.prompt_logprobsisn't part of this.How:
server/logprobs.zig:answerStart(where the answer's rows begin, shared by the whole reply and the stream so both cut at the same token),Stream.delta(a content delta with the rows its streamed text now covers) andlegacy(the completions form).chat.zig: the rows are copied from the mailbox under its lock with each round's tokens (the engine thread appends to the mailbox while a stream reads);Generation.lpreplaces thelogprobsflag. The file stays at 600 lines.openai.zig: a chunk moves its delta'slogprobsto the choice; completions parse the integerlogprobs(fields.legacyLogprobs) and write the legacy form; the completions stream lets a delta with rows through.Receipt
Environment: one DGX Spark (GB10, sm_121, driver 580.173.02, CUDA 13),
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.Streamed chat against the whole reply, greedy unless stated,
top_logprobs: 5(17 of 17 checks):B)"draft": falseThree at once (two streamed, one whole with
"draft": false): each identical to its run alone./v1/completionswithlogprobs: 5, 64 tokens, on a prose, a code and a Japanese prompt (15 of 15): the streamed text and every legacy array equal the whole reply's;"draft": falsegives the same; each greedy token is its row's best alternative;text_offsetstarts at 0 and grows by each token's length.Speed: unchanged for requests without
logprobs(no new kernel or engine work; the stream only formats rows the engine already returns). Not separately benchmarked for this change.Tests run:
zig build test37/37 steps, 429/429 tests. Two new server tests: a streamed reply's rows joined over its chunks equal the whole reply's and spell its streamed content (thinking on, with the answer split across rounds after</think>and two newlines, and thinking off);/v1/completionsgives the legacy arrays whole and streamed, with alternatives by text and the offsets. The refusal test now expects a stream to be served and a booleanlogprobson completions to be refused. The frozen server goldens: 309 of 319 equal, 0 unexpected differences, the same asmain.zig fmt --checkclean on the changed files.Not run, and why: Metal (no Mac; Metal engines give no rows and refuse as before).
Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Drafted and concurrent rows checked above; the engine side is logprobs and top_logprobs on the native CUDA server (Nemotron), from the verified target logits #572's, unchanged.)