Repository navigation
cuda: sample.cu's keyed draws as a shared module (sample.zig); Nemotron draws through it - #654
Conversation
…on draws through it
|
One more piece I'd like to add here before review, if you agree. The sampler's rule (1/T, top_p, the near window of 20, ln(min_p), top_k, the seed) is currently built in three places:
Proposal:
The kernels and their arguments stay unchanged, and the receipts would be the same as this PR's: If you'd rather keep this PR CUDA-only, I'll send it as a follow-up after this one lands. |
|
Thank you, @jschmied. This landed in 1.0.8 as your own commit ( We built both trees with their own kernel sets and compared the tree without your PR (base) against it (tip), with Nemotron 3.5 Lightning MLX 4-bit, on a GB10 (sm_121, CUDA 13.0) and an RTX PRO 6000 (sm_120, CUDA 13.2):
Each build times its draft costs the first time it starts. On the RTX PRO 6000 the tip's own timing drafted greedy code in 52 rounds where base took 49, for the same tokens, which read as 5% slower on that one cell; with base's timing it took 49 rounds and matched base's speed. The four seeds gave four different replies in every setting, so the draws were live, and each build's own replies matched Yes to Keeping it a pure move, same kernels and same launches, made this quick to check. |
…draws module) into the 1.0.8 candidate
ashhart#654 landed above as e45d24291 (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.
…draws module) into the 1.0.8 candidate
The first of the item-4 pieces claimed in #548: sample.cu's keyed draws as a shared module, so a second CUDA family (Kolibri 1, #481) draws by the same rule as Nemotron and the Metal engine without importing Nemotron. It's a move like #558 and #602: same kernels, same launches.
cuda/sample.zig:margin,max_candidatesandcount.Ruleandrule(seed, temperature, top_p, min_log, top_k). It takes plain values, since thecudamodule doesn't depend onlanes.Draws:resolvefrom the loadedsamplemodule,draw(with or without a column id map) andlogprobRows, each the launch Nemotron'sOpsmade.families/nemotron/cuda_sampler.zigkeepsSampling,checkand the Triton-keyedgreedy_draft.rule(s)maps a request ontocuda.sample.rule, and its test is unchanged.families/nemotron/cuda_kernels.zig:Kernelsholds oneDrawsinstead of three functions, andOps.drawandOps.logprobRowsdelegate, so no caller changes.Receipts on GB10 (DGX Spark, sm_121, CUDA 13.0).
main(a6aa478) and this branch were each built with nvcc forsm_121:zig build testpasses;zig fmt --checkandlean_checkare clean for the touched files.tf-cuda-test sample: 2,880 draws equal the Metal rule's host references.d9d758fb:tensorfold check-kernels: 1,008 of 1,008 projection cases and 384 of 384 forked-MoE cases, both builds.tensorfold run: three prompts, greedy and sampled (0.8 / 20 / 0.95, seed 7; the sampled ones draw through the moved code). All six reply hashes equal main's:5923b40d570b,d38725819372,ead827be94f5,bb8855c2f084,068276d3ec75,a6961a8c7589.