Repository navigation
Nemotron CUDA: decode-sized router, topk and add_moe_norm keep their loads in flight, the same bits - #833
Conversation
…loads in flight, the same bits The router's decode windows (16 rows or fewer) run tf_nemo_router_rows: a block of 16 experts and one K slice stages its rows with every 16-byte load issued at once, then thread (row, expert) runs tf_nemo_router's fma chain from shared memory, the next pair's loads ahead of each step. tf_nemo_topk loads every slice and bias before its sums. tf_nemo_add_moe_norm takes a row's loads and adds on 1024 threads, and its first 256 sum the squares in row_ss's order. Every sum keeps its order: tf-cuda-test glue stays byte-equal to the host references.
…gnitudes too, where the sum of squares' order shows in the stored outputs
… their loads in flight (#833)
Recall (off unless asked for), model discovery's reasoning efforts (#819), the NVFP4 prompt entries' skip (#764) and Nemotron's CUDA decode router, top-k and add_moe_norm (#833), gated on the candidate before Living Weights' key, snapshot and rollback. Two conflicts: the CHANGELOG's Unreleased list, where both sides' lines are kept in landing order, and the server main's imports, where all four are kept.
#833's top-k loads every slice and bias before it sums them, and nvcc now gives it 95 registers on sm_86 and sm_89 and 91 on sm_120 and sm_121, where the record kept 63, 59, 58 and 58 from before that change. On a GB10 `tf-cuda-test kernel-contract` failed its live limit check on this launch alone (91 registers loaded, 58 recorded), and `kernel-contract-limits` called the record stale on all four SMs. The new values are the ones it printed from fatbins built for all four; 32 threads at 95 registers fit every SM.
|
Thank you, @jschmied. Closing most of the gap to the captured Triton glue while keeping every byte is the change we want. Both commits ship in TensorFold 1.0.12 under your name ( On a GB10 the router with top-k and add_moe_norm matched the host references at every row count from 1 to 64 and at 17 more up to 4,096. On the same window-cost table one stream decodes about 0.9% faster drafted and 1.5% faster with Posted by Ash's AI Assistant Synthena |
… their loads in flight (ashhart#833)
The contributor's two commits landed above with the same code; this keeps the PR's head in the history with no change to the tree.
…date Recall (off unless asked for), model discovery's reasoning efforts (ashhart#819), the NVFP4 prompt entries' skip (ashhart#764) and Nemotron's CUDA decode router, top-k and add_moe_norm (ashhart#833), gated on the candidate before Living Weights' key, snapshot and rollback. Two conflicts: the CHANGELOG's Unreleased list, where both sides' lines are kept in landing order, and the server main's imports, where all four are kept.
ashhart#833's top-k loads every slice and bias before it sums them, and nvcc now gives it 95 registers on sm_86 and sm_89 and 91 on sm_120 and sm_121, where the record kept 63, 59, 58 and 58 from before that change. On a GB10 `tf-cuda-test kernel-contract` failed its live limit check on this launch alone (91 registers loaded, 58 recorded), and `kernel-contract-limits` called the record stale on all four SMs. The new values are the ones it printed from fatbins built for all four; 32 threads at 95 registers fit every SM.
What this changes
Nemotron's router,
topkandadd_moe_normon CUDA keep their loads in flight at decode sizes, and every sum keeps its order, so all outputs are byte-equal tomain. This addresses the part of #627 agreed there: one-row decode on GB10 was 0.35 ms a step behind the captured Triton glue, mostly on the MoE side chain that the main stream waits for.tf_nemo_router_rows(nemotron_route.cu) runs decode windows of 16 rows or fewer. A block of 16 experts and one K slice stages its rows with every 16-byte load issued at once. Thread (row, expert) then runstf_nemo_router's fma chain from shared memory, loading the next pair ahead of each step. Prompt chunks keeptf_nemo_router.tf_nemo_topkloads every slice partial and bias before its sums.routerShape's slice count is now checked against the kernel's 8.tf_nemo_add_moe_normloads and adds a row on 1,024 threads, every load in flight. Its first 256 threads sum the squares inrow_ss's order: the same chains, butterflies and warp order.Receipt
mainat1e76a70e, plus this commit. One DGX Spark (GB10, sm_121, CUDA 13).TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit(MLX 4-bit).tensorfold runreply shas equalmain's for code and prose prompts (36 and 38 tokens, 256 greedy tokens), plain and drafted, in every round. Prompts of 2,048 and 8,192 tokens also give the same shas.main.tf-cuda-test glue: 1,245 of 1,245 comparisons byte-equal, several streams at once included.glue.topk's slice sum failsglue.add_moe_norm's square-sum chain passedglueas it was. With uniform inputs the order almost never shows after the square root and the division, even at 2 × 4,096 rows. The second commit adds 2,048 rows of log-uniform magnitudes (2^-8 to 2^8), where it shows. The mutation now failsglueat 10 stored outputs and 10 group sums, and the test passes onmain's kernels and on this branch. The teacher-forced check also catches it, at 508 of 512 rows.tensorfold run, ms a token, median of 3 interleaved rounds. "Triton" ismainwith--kernelsset to 1.0.2's capturedsm121glue, for reference.main--no-drafts--no-draftsIn every cell, every round of this PR is faster than every round of
main. The engine's measured round costs at 1/2/4/8/16 rows go from 9.18/11.78/15.38/21.40/30.46 ms to 8.99/11.51/15.16/21.23/30.35 ms.Per launch, from nsys with
--cuda-graph-trace=node:maintopkadd_moe_normThe main stream's wait on the side chain drops from 1,489 to 730 µs a step (Triton: 561).
mainand 0.2704 s here; 8,192 tokens take 1.0406 s and 1.0418 s, a median of 3 each.zig build test-cuda-host: 27 of 27 steps, 451 of 451 tests.zig build testpasses.tf-cuda-test glueandnorm-rowspass.zig fmt --checkis clean, andlean_check.pyreports 527 findings, as onmain.tools/bench_openai.pythrough the server:tensorfold rundrives the same lane rounds.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (No bits change.)gluecase fails on a reordered sum of squares and passes onmain's kernels and on this branch.)