Skip to content

inkling2 cuda: Mini logprob rows (first_row and verify rows) through the shared row kernel - #5210

Draft
jmpijll wants to merge 1 commit into
ashhart:mainfrom
jmpijll:inkling2-cuda-mini-logprobs
Draft

jmpijll wants to merge 1 commit into
ashhart:mainfrom
jmpijll:inkling2-cuda-mini-logprobs

Conversation

@jmpijll

@jmpijll jmpijll commented Nov 26, 2026 •

Copy link
Copy Markdown

What this changes

Before: Inkling 2 Mini on CUDA gives no logprob rows (first_row is null), so native/cuda.zig reports logprobs = false and logprobs / top_logprobs requests are refused for it. After: the first token's row and each verify row come from cuda.sample.Draws.logprobRows over the bf16 copy of the forward's fp32 logits that a sampled draw reads (a greedy lane makes that copy only for a round that asks for rows); a round's rows share one words buffer (round_rows × lanes.logprob.words) and one download. The drawn tokens do not change: the draw path is untouched and the row kernel only reads.

Checks on this head

  • Head commit: fcb2da5ca on main 3c088d969 (the same tree as 123d7568f, which every check and receipt line below ran).
  • Lean checker, python3 tools/zig/lean_check.py on the base and on this head, compared with python3 tools/zig/lean_new.py: 123 and 123, 0 new. zig fmt --check build.zig zig and git diff --check clean. python3 tools/pr_check.py --base origin/main: 0 errors; 4 advisory warnings (three inherited import cycles, and the Unreleased line, which needs the PR number).
  • Tests run, with the command and pass, fail and skip counts: zig build -Dfixed-cpu test test-golden: 924/924 steps, 13,647/13,756 tests passed (109 skipped). On one GB10, tf-cuda-test inkling2-serving MODEL IDS (4,400 ids) with the new case "logprob rows equal the host's over the same logits; tokens unchanged": 7/7 PASS (host reference, fresh/resumed, cross-prompt resume, admission, 4-slot concurrent == solo, copy rollback, logprob rows).
  • The new case fails before the change: the runner built from main plus only the new case gives the six other PASS lines and then FAIL inkling2-serving: LogprobsUnsupported (exit 1).
  • CI: not reported on this head yet (draft).
  • Not run, and why: CUDA chips other than sm_121 (only a GB10 here); Metal, HIP and XPU are untouched by the change.

Receipt

  • Main against branch: the cells below, same machine, checkpoint and settings, in one session: main's startup, the branch's, then a second main and branch startup for decode.
  • Boxes it reaches: the CUDA Mini lane backend's first and verify windows; the server's logprob path only when a request asks for logprobs.
  • New switch? None.
  • Environment: TensorFold main 3c088d969 against this branch on it; Zig 0.17.0; nvcc 13.3 (NVIDIA PyTorch 26.07 container, -Dsm=121); one NVIDIA GB10 (sm_121, 128 GB unified memory), driver 580.178.04, Linux (DGX OS, kernel 7.0.0-1025-nvidia, aarch64); thinkingmachines/Inkling-2-Mini @ ed40e7da (target shard SHA-256 65e60f51aa1284d4fb022584908c315270334d991828bb774af60584523539d1); no drafter (main's CUDA Mini has none); --parallel 4 --context 32768 --prompt-cache-gib 0.
  • Paths and platforms the change reaches: first with logprobs, verify windows with rows, greedy and seeded sampled; CUDA sm_121 run, other CUDA SMs not run.
  • Exactness: tools/bench_concurrent.py --levels 1,4 --alone --serial --tokens 256 --reps 3 --temperatures 1.0,0 on both: every cell's concurrent replies equal their alone runs (3/3 at one stream, 12/12 at four) and the alone runs equal "draft": false, on main and on the branch; all 540 token_sha256 / token_sha / output_sha256 values equal between main and the branch. A logprobs request's token ids (return_token_ids) equal the same request without it, greedy and seeded T 1.0: 24-token completions with logprobs: 5 (24 rows of 5) and chat with top_logprobs: 3 (110 and 138 ids; 7 and 27 answer rows of 3); the ids without logprobs equal main's. Main answers 400 "logprobs are not supported by this model or backend". The serving case checks the rows' ids against the host's top-k over the same bf16-rounded logits and their values within 1e-3.
  • Main against this branch, same machine and checkpoint: below.
  • Decode speed before and after, tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0 (median of 3), runs alternated main, branch, main, branch: fibonacci-raw 25.63, 25.33 against 25.40, 25.44 tok/s; gpu-chat-no-think 25.98, 25.75 against 25.86, 25.88. Main's two runs differ by 1.2%, more than main and the branch do. bench_concurrent (3 reps; one-stream cells: per-stream decode tok/s; four-stream cells: aggregate tok/s), main -> branch, one pass over every cell: code T 1.0 25.6 -> 25.4 and 57.3 -> 56.1; chat T 1.0 25.8 -> 25.7 and 61.2 -> 61.2; code greedy 25.4 -> 25.3 and 77.2 -> 77.2; chat greedy 25.8 -> 25.8 and 79.8 -> 79.8. The T 1.0 cells were then rerun with a fresh server each in the order main, branch, main, branch (--levels 4, then --levels 1, --tokens 256 --reps 3 --temperatures 1.0; medians of three reps): code four streams 57.49, 57.27, 57.20, 57.16; chat four streams 61.51, 61.19, 61.27, 61.17; code one stream 25.49, 25.35, 25.43, 25.32; chat one stream 25.80, 25.70, 25.75, 25.69. At four streams the branch is 0.2% below main (median of six reps each), less than main's own difference between its two runs (0.5% code, 0.4% chat), so the first pass's 2.1% did not repeat; at one stream it is 0.1 tok/s (0.4%) lower in both pairs, more than main's 0.2% between its runs. Every token hash is equal across the four runs. Requests without logprobs run the same kernels as on main: the branch adds a rows.len test a window and allocates the words buffer once.
  • Prompt speed: n/a, the prompt path is unchanged (cold TTFT in the decode runs 0.100, 0.101 against 0.101, 0.101 s for fibonacci-raw and 0.330, 0.334 against 0.340, 0.344 s for gpu-chat-no-think).
  • Licence of any new weights or drafter: n/a.

Raw results (decode.json for the four decode runs, concurrent.json for both arms, the logprob requests, the serving and control logs) can be attached.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • 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. If the bits change, the description says which sums change and why.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled. (Not ticked: in the alternated rerun the four-stream cells are within main's own spread, but the one-stream T 1.0 cells are 0.1 tok/s (0.4%) lower in both pairs, with no added kernel on that path; see Receipt.)

…the shared row kernel

Mini on CUDA gave no logprob rows, so the server refused logprobs for it. The first token's row and each verify row
now come from cuda.sample's logprobRows over the bf16 copy of the forward's fp32 logits that a sampled draw reads (a
greedy lane makes that copy only when a row is asked for); a round's rows go through one words buffer and one download.
Draws are unchanged. The serving test checks both rows against the host's rows over the same logits, greedy and sampled.

This branch has not been deployed

No deployments
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.

1 participant