Repository navigation
Nemotron CUDA: a shared round's per-stream conv, scan and attention run as one launch each - #770
Conversation
…tion run as one launch each Glue.mambaSegs and Glue.attentionSegs pass every stream's buffers by value (conv/scan: blockIdx.y/z a stream; attention: blockIdx.x a shared row), each stream computed as the one-stream kernels compute it; the _segs kernels are copies, so a lone window keeps the one-stream kernels' code. tf-cuda-test glue checks three streams at once against the host references.
…3 experts Checked ash hart PRs open+closed (read-only). Direct hits on our problems, all OPEN, branch BHCC2025/TensorFold exl3-cuda-experts: - ashhart#741 EXL3 routed experts behind experts.Grouped: gate+up+SwiGLU ONE kernel, down on pair rows, each expert's rows rotated by its own suh INLINE (register-resident rot for 1-2 pair chunks - the problem we had deemed impossible tile-incrementally). Rides on grouped.zig's Plan (in our tree). 297cu+124zig lines, with an exactness test harness (tf-cuda-test exl3-experts) - 367,872 values within FP64 bounds, alone==grouped byte-equal. - ashhart#740 EXL3 projections behind qlinear (the stacked base). - ashhart#718 branch-free trellis window extraction (perf). - ashhart#729 share decoded weights across prefill rows (perf). - ashhart#728 MiMo-V2.6 CUDA EXL3 two-GPU (another full CUDA EXL3 family). - ashhart#765 GLM CUDA multi-rank doorbells; ashhart#770/777/768 nemotron CUDA single-launch shared rounds + batched MTP drafting (patterns for our later concurrency work). PLAN: vendored exl3_experts.cu/.zig + exl3.cuh into our tree (this commit, unwired). Next: build wiring (fatbin + mod), port moeBlock to Grouped.decode with the router->plan plumbing from grouped.zig, run their exl3-experts test on our checkpoint, parity, bench. Our own grouped kernels (stage-1 parity) stay as fallback.
The contributor's commit landed above with the same code, its attention kernel appended after ashhart#770's; this keeps the PR's head in the history with no change to the tree.
|
Thank you, @plotarmordev. One launch per mixer step for all of a shared window's streams is a clean way to cut a shared round's launch count, and every stream still runs on its own state. It landed in 1.0.9 under your name ( What we measured on a GB10 (sm_121):
On the copies: we checked whether one |
The contributor's commit landed above with the same code; this keeps the PR's head in the history with no change to the tree.
The contributor's commit landed above with the same code, its attention kernel appended after ashhart#770's; this keeps the PR's head in the history with no change to the tree.
What this changes
Nemotron on CUDA runs a shared round's per-stream steps for all its streams at once. Each Mamba layer's conv and scan, and each attention layer's key write, chunks and merge, take one launch for every stream instead of one per stream, with each stream on its own state, caches and position.
nemotron_mamba.cu,nemotron_attention.cu:tf_nemo_{conv,scan,kv_write,attn_chunk,attn_merge}_segstake every stream's pointers by value. They are copies of the one-stream kernels, which stay byte-identical. A first version that shared one body between them changed the one-stream kernels' code and slowed a lone stream by 1.6-1.9%.cuda_glue.zig:mambaSegsandattentionSegs. A lone window, a Triton set, or more than 8 streams take the one-stream kernels as before.cuda_forward.zig:windowRowscalls them.tf-cuda-test glue: two new cases, three streams at once against the host references (conv xc/raw/base, scan dt/state/y, key/value writes, attention out and xs).Receipt
Environment: DGX Spark (GB10), Nemotron 3.5 Lightning MLX-4bit @
d9d758fb, on 1.0.8 (0efbd447),--context 16384 --parallel 8, 400-token replies, distinct prompts.Exactness:
tf-cuda-test glue124/124 byte-equal. Replies have the sametoken_shaas 1.0.8 at 1, 2, 4 and 8 streams.Speed, makespan over 8 trials an arm:
On 1.0.7, 8 streams ran -5.5% to -7.8% across five sessions and 4 streams -3.4% to -4.3%. The Grill's concurrency ladder there gave -3.3% at 4 streams, separated, and +0.01% at 1.
Tests run:
zig build test616/621 (5 skipped);test-cuda-host25/25 steps; server tests 155/155 and 96/96; goldens 309/319 with 0 unexpected differences;zig fmt;lean_checkas on 1.0.8.Not run, and why: Metal (unchanged). The NVFP4 checkpoint and RTX cards (no hardware here). Note: this and Nemotron CUDA: decode glue keeps its loads in flight, same values and order #771 both append to
nemotron_attention.cu, so whichever lands second takes a trivial merge.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.