Skip to content

Inkling 2 Mini CUDA: serve batched DSpark drafts (stacked on #4858) - #5197

Draft
plotarmordev wants to merge 7 commits into
ashhart:mainfrom
plotarmordev:feat/inkling2-cuda-dspark-serve-on-4858
Draft

plotarmordev wants to merge 7 commits into
ashhart:mainfrom
plotarmordev:feat/inkling2-cuda-dspark-serve-on-4858

Conversation

@plotarmordev

Copy link
Copy Markdown
Contributor

What this changes

I add opt-in Inkling 2 Mini CUDA DSpark serving on top of #4858's all-stream draft kernels. Before this stack the Mini target served plain; with --drafter I load its bundled mtp.safetensors, capture target visits 5/23/41 plus post-final norm, draft two proposals per stream in one batched pass per layer, and verify against the unchanged target with rollback. I reuse #4858's kernels rather than duplicate them.

Draft PR while #4858 is open and remaining upstream checks (CI, independent fidelity, and cold prompt overhead) are resolved.

Checks on this head

  • Head commit: 35bdb47fcdb94ef1afceb8e4aa30f4bdf433bd9d.
  • Lean checker: I counted 164 inherited findings on main and 164 on this head; 0 new. The checker itself exits nonzero on both.
  • Tests run: zig fmt --check and git diff --check pass. I ran zig build test-cuda-host -Doptimize=ReleaseFast -Dnvcc="$(command -v nvcc)" -j1 on the final code head, exit 0 with 3 expected negative-test failed command lines and no explicit FAIL; I rebuilt the CUDA device runner and passed tf-cuda-test inkling2-dspark-serving for greedy/sampled code/chat, 2053 prompt tokens, resumed cuts 23/28/2048, four mixed and resumed streams, equal-proposal identical streams, and head release/reopen. The mixed cohort accepted 70 proposals at the served two-draft cap. tf-cuda-test kernel-contract dspark DSpark passed 27/27 kernels under gates 1–4, 0 failed, 0 known findings, with 24/24 planted controls red and 0 limit problems.
  • Not run yet: I did not run device inference on SM80/86/89/120, full zig build test test-golden, independent teacher-forced released-checkpoint fidelity, or an external standard-server comparison. At context 8192, cold 32k/64k prompts are not admitted; those require a larger-context separate receipt. The full five-SM limits check exits 1 on both main and this final head with the same 184 inherited stale records, 0 new; I do not call it green.

Receipt

  • Main against branch: I compared plain main (A), stacked opt-in drafter (B), and a fresh plain main repeat (A2) in all eight cells below.
  • Boxes it reaches: I reach Mini CUDA text serving and the C5 speculative verification path; I leave Metal, HIP, image serving, and other model families unchanged.
  • New switch: n/a. I use existing --drafter, opt-in; ordinary plain decode remains the default.
  • Environment: main c0ea57ddd924cb8ab76ee9d4939b4a141ce7d392, Inkling-2: Add DSpark kernels that draft all streams in one pass #4858 833875fe0b732c7083f236ea7cc3c01a96ebc076, stacked head 35bdb47fcdb94ef1afceb8e4aa30f4bdf433bd9d; Zig 0.17.0, CUDA 13.0, Linux ARM64, one GB10 SM121, released Inkling 2 Mini checkpoint revision ed40e7da625f594fc9c4990f5f66be24873c22d7 with its bundled drafter file.
  • Paths and platforms: I ran plain and opt-in CUDA text paths on SM121. I built fatbins for SM80/86/89/120/121 but did not execute inference on the other chips; Metal, HIP and other products are out of scope.
  • Exactness: I measured 100% ordered SHA-256 equality for all 256 output tokens of every stream and three repetitions in every greedy/sampled, code/chat, one-/four-stream cell across A/B/A2; solo, concurrent, and "draft": false serial references agreed. The device test passed resumed and released/reopened state.
  • Decode: B beat both A and A2 in all eight cells, including four-stream greedy code 104.7 vs 77.6/77.3 tok/s (+34.9%) and four-stream greedy chat 97.3 vs 80.2/80.2 tok/s (+21.3%). Four-stream decode is aggregate tok/s; TTFT is median per-request ms.
Prompt Streams Temp A tok/s B tok/s A2 tok/s B accepted/round TTFT A/B/A2 ms Token SHA-256
Code 1 0 25.8 35.9 25.7 1.032 101/109/102 exact
Code 4 0 77.6 104.7 77.3 1.383 251/270/250 exact
Chat 1 0 26.2 35.1 26.1 0.947 335/318/335 exact
Chat 4 0 80.2 97.3 80.2 1.125 1114/1129/1115 exact
Code 1 0.8 25.9 32.1 25.9 0.747 102/110/102 exact
Code 4 0.8 58.4 66.3 58.5 1.024 251/271/252 exact
Chat 1 0.8 26.1 36.6 26.1 1.081 336/318/335 exact
Chat 4 0.8 61.3 71.4 61.2 1.056 1116/1126/1112 exact
  • Prompt processing: I measured cold 2k/8k after a fresh server start with prompt caching disabled. B took about 0.6% longer than both plain arms, so I leave the prompt no-slower checklist line unticked.
Cold prompt tokens A TTFT ms B TTFT ms A2 TTFT ms
2,048 6,881.0 6,924.9 6,890.1
8,000 27,029.6 27,184.2 27,036.5
  • Memory: I measured fresh-server peak process RSS A/B/A2 at 0.416 / 0.425 / 0.415 GB, and in a separate matched memory probe measured engine CUDA allocator peak 23.023 / 24.829 / 23.023 GB (+1.806 GB opt-in when --drafter is enabled). I do not add process RSS to CUDA allocations on unified memory.
  • Licence: I commit no weights. The released Apache-2.0 checkpoint separately supplies mtp.safetensors; the caller opts into loading it.
Kernel contract
  • Kernels: I reuse Inkling-2: Add DSpark kernels that draft all streams in one pass #4858's multi-stream Q/K, attention, context, recurrence, and pick kernels, with two registered Mini-only tap/hidden bridge kernels; no upstream kernel is duplicated.
  • Controls: I observed 24/24 planted controls red as planted, none missed.
  • CUDA summary: (filtered) SUMMARY 27 kernels: 27 pass gates 1-4, 0 fail, 0 known findings; 24 controls: 24 red as planted, 0 missed; 0 limit problems; exit 0. Full five-SM resource limits exited 1 with the same 184 inherited stale records on main and final head, 0 new.
  • Unrun chips: I built fatbins for SM80/86/89/120/121 but device-tested only SM121.

How to check

Base: c0ea57ddd924cb8ab76ee9d4939b4a141ce7d392. Stacked #4858 parent: 833875fe0b732c7083f236ea7cc3c01a96ebc076. Head: 35bdb47fcdb94ef1afceb8e4aa30f4bdf433bd9d.

Use two independent checkouts for main and this branch, the same released checkpoint and an SM121 device; set MODEL_DIR, IDS_FIXTURE, OUT, and each checkout's SERVER_BIN accordingly:

BASE=c0ea57ddd924cb8ab76ee9d4939b4a141ce7d392
PARENT=833875fe0b732c7083f236ea7cc3c01a96ebc076
HEAD=35bdb47fcdb94ef1afceb8e4aa30f4bdf433bd9d
zig fmt --check build.zig zig
python3 tools/zig/lean_check.py
git diff --check
zig build test-cuda-host -Doptimize=ReleaseFast -Dnvcc="$(command -v nvcc)" -j1
zig build -Dnvcc="$(command -v nvcc)" -Doptimize=ReleaseFast
zig build -Dgpu=sm_121 -Dnvcc="$(command -v nvcc)" -Doptimize=ReleaseFast --prefix "$OUT"
zig build fatbins kernel-contract-fatbins -Dsm=80,86,89,120,121 -Dnvcc="$(command -v nvcc)" -Doptimize=ReleaseFast
./zig-out/bin/tf-cuda-test inkling2-dspark-serving "$MODEL_DIR" "$IDS_FIXTURE"
./zig-out/bin/tf-cuda-test kernel-contract dspark DSpark
./zig-out/bin/tf-cuda-test kernel-contract-limits zig-out/fatbin

I start a fresh server for each A (plain main), B (stacked with --drafter "$MODEL_DIR"), and A2 (plain main repeat) arm; only B enables the drafter. SERVER_BIN is the product build's native/bin/tensorfold-native:

"$SERVER_BIN" serve "$MODEL_DIR" --backend cuda --host 127.0.0.1 --port 8188 \
  --name inkling-2-mini --parallel 4 --context 8192 --prompt-cache-gib 0 --no-update-check
python3 tools/bench_concurrent.py http://127.0.0.1:8188 inkling-2-mini \
  --levels 1,4 --tokens 256 --reps 3 --seed 42 --temperatures 0,0.8 \
  --alone --serial --output "$RESULT_JSON"

Checklist

  • I matched the description, stack, SHA and measured receipt to this head.
  • I still need a before-change red run of the new identical-stream device test; an earlier served probe demonstrated unequal acceptance.
  • I kept comments concise and omitted private hosts, paths, and identity data from the diff and commit messages.
  • I kept every token in shared lane rounds, with a profiler-confirmed four-stream batched draft launch.
  • I matched drafted, plain, resumed, concurrent and solo output without changing target arithmetic.
  • I beat plain on every decode cell, but cold 2k/8k prompt processing is about 0.6% slower; independent fidelity, full-suite, and CI checks remain while this PR stays Draft pending Inkling-2: Add DSpark kernels that draft all streams in one pass #4858.

- I retain the PR kernel implementations and numerical contracts without importing the older expert or vision stack.
- I register the DSpark fatbin alongside Mini serving on current main.
- I capture decoder taps and verify or roll back one shared multi-stream draft pass.
- I register Mini CUDA bridge contracts and per-request draft counters.
- I leave the serving acceptance regression visible as an unresolved gate.
- I compute post-final target normalization before tap capture and unembedding.
- I feed mask rows 1 through 7 into the matching recurrence and hidden projections.
- I verified greedy, sampled, resumed, four-stream, and reopened Mini CUDA drafting.
- I describe target tap ordering, aligned recurrent rows, and the unchanged fidelity and speed gates.
- I advertise the existing multi-stream hold to the shared scheduler instead of receiving singleton holds.
- I document why the scheduler flag is required for the reused batched CUDA kernels.
- I pack the target unembedding to its valid vocabulary width while checking the full checkpoint tensor.
- I compare identical concurrent greedy and sampled streams to catch shifted batched proposal rows.
- I avoid spending shared target passes on the checkpoint’s mostly rejected deeper proposals.
- I document the serving depth choice separately from the eight-row kernel capacity.

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