Skip to content

nvfp4 experts cuda: decode up to 24% faster (GLM-5.3 83.8 -> 104.1 tok/s), same bits, via a per-warp cp.async ring - #2266

Merged
ashhart merged 9 commits into
ashhart:mainfrom
eleqtrizit:nvfp4-decode-ring
Nov 19, 2026
Merged

ashhart merged 9 commits into
ashhart:mainfrom
eleqtrizit:nvfp4-decode-ring

Conversation

@eleqtrizit

@eleqtrizit eleqtrizit commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

The NVFP4 decode expert kernels (nvfp4_expert_kernel, nvfp4_expert_waves, nvfp4_expert_half) stall on load latency. Each warp now keeps a D=4 shared-memory ring that cp.async fills with its weight words, block scales and both rows' inputs. Every group is summed in the same k order as before, so the output is bit-identical. All three kernels share one Ring<M, WARPS, Word> helper. GB10 (sm_121) keeps two register-loaded stages with no shared memory, because the shared ring cost a served Qwen3.6 cell 1.8%. The contract records are regenerated from nvcc 13.0.88, with a 13.2.78 override set; 13.3.73 compiles the same as 13.2.

Checks on this head

  • Head commit: 2efcaa4: dc4b781 plus a CHANGELOG-only move of this PR's line back under Unreleased. The ring on every chip but GB10, with GB10 on register-loaded stages.
  • On dc4b781 (same code): zig build exit 0; zig build test test-kernel-contract test-golden fuzz-cortheon exit 0
  • Lean checker on this head: 398 vs 398 at the merge base, 0 new (tools/pr_check.py: 0 errors, 0 warnings)
  • cuobjdump -sass and -res-usage on sm_121a (nvcc 13.0.88), main vs this head: byte-identical for all 19 nvfp4_experts functions, including the 10 decode CTAs
  • Preprocessed source for sm_80/86/89/120 is byte-identical with and without the GB10 change, so their earlier runs stand
  • CI: see the checks on this head
  • Not run, and why:
    • prompt TTFT: only the decode kernels change
    • resumed vs fresh: the prompt kernels are untouched
    • sm_80: no A100 available

Receipt

  • Environment: Zig 0.17.0.
    • 2x RTX PRO 6000 Blackwell (sm_120), nvcc 13.4, GLM-5.3-Flash FP4-Local @76348ddb, TP=2; main cde4fe7 vs head.
    • 2x RTX PRO 6000 Blackwell, GLM, built with nvcc 13.0.88; main cde4fe7 vs head.
    • GB10 (sm_121), nvcc 13.0.88, driver 580.178.04, nvidia/Qwen3.6-35B-A3B-NVFP4 @1355db6a and nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-NVFP4 @bee75962; main 6ec5fa4 (1.2.3 release commit, version and changelog only) vs e29bc7d plus the register form.
    • 2x RTX PRO 6000 Blackwell (sm_120), nvcc 13.4.92, driver 595.99.02, Qwen3.6 NVFP4 @1355db6a on one card and nvidia/Qwen3.8-Flash-Next-NVFP4 @fc694b54 at TP=2 on both; main b4db863 vs dc4b781.
    • RTX 6000 Ada (sm_89) and RTX A6000 (sm_86), nvcc 13.1, nvidia/Qwen3.6-35B-A3B-NVFP4 @1355db6a; main 00ff0f3 vs the same kernel commits.
  • Paths reached: NVFP4 routed-expert decode (GLM, Qwen3.6 ModelOpt NVFP4, Nemotron, Flash Next). Ran on sm_120, sm_121, sm_89 and sm_86; sm_80 not run.
  • Exactness: token_sha sets identical between main and head on every prompt, greedy and sampled, on every machine. bench_concurrent.py --alone --serial equal on both sides (GLM 48/48 alone, 16/16 serial; GB10 240/240 and 80/80 for Qwen3.6, and the same for Nemotron). GLM drafted == plain on every prompt.
  • Decode speed, median of 4 ABBA rounds with fresh servers unless noted:
    • GLM plain (draft off) 83.7 -> 104.1 tok/s (+24.4%); every cell's spread within 0.5%
    • GLM drafted code 212.4 -> 226.4, code-long 157.5 -> 174.1, chat 162.8 -> 180.1
    • GLM bench_openai fibonacci-raw greedy 190.7 -> 204.9, sampled 196.9 -> 211.8; gpu-chat-no-think greedy 140.9 -> 159.3, sampled 146.1 -> 163.1
    • GLM built with nvcc 13.0.88 (2 ABBA rounds): plain 83.1 -> 104.4 (+25.7%); bench_openai +8.0% to +13.9%, greedy and sampled
    • Nemotron 3.5 Lightning NVFP4 on GB10 (MTP drafts on, register form): -0.3% to +0.4% on all 12 cells, ranges overlapping main: level with main.
    • Qwen3.6 on GB10 (register form): level with main; the sm_121a SASS is byte-identical to main's, so its small differences are noise. Sampled code 1 stream 129.1 [125.1-130.1] -> 130.8 [129.9-132.2], 4 streams 269.8 [260.7-270.2] -> 269.6 [268.7-269.7]; other cells -0.2% to +1.7%; ranges overlap main in every cell
    • Qwen3.6 on sm_120 (one card): sampled code 1 stream 414.2 [414.0-415.0] -> 472.3 [472.2-472.4] (+14.0%); all 12 cells faster with no overlap, +4.0% to +14.6%; alone/serial 240/240, 80/80 (table in the review reply)
    • Flash Next NVFP4 on sm_120 (TP=2, one host): 1, 2, 4 and 8 streams, greedy and sampled, -0.2% to +1.4%: 14 of 16 cells overlap main and 2 are faster; token_sha sets identical; alone/serial 720/720, 288/288 (table in the review reply)
    • Qwen3.6 on 6000 Ada (2 rounds, greedy): +4.7% to +8.5%; 4 streams +5.7% to +6.5%; 1-stream chat +1.2%
    • Qwen3.6 on A6000 (2 rounds, greedy): +5.6% to +7.7%; 4 streams +5.2% to +5.6%
  • Prompt speed: n/a, only the decode kernels change (TTFT unchanged at 28/40 ms in the runs above)
  • Licence: n/a
Kernel contract
  • Kernels: the existing registrations, with each kernel replaced in place; records regenerated
  • Controls: the existing planted controls cover these registrations, and all are red
  • SUMMARY:
    • sm_120 (nvcc 13.4): 565 kernels, 565 pass gates 1-4, 0 fail; 362 controls red, 0 missed. The exit status is 1 because of limit problems: nvcc 13.4 register counts, for which there is no 13.4 record set.
    • sm_121 (GB10, nvcc 13.0.88, register form): 608 kernels, 608 pass gates 1-4, 0 fail; 381 controls red, 0 missed. All 10 decode CTAs match their records. The exit status is 1 because of 170 limit problems, none in a kernel this PR changes: 168 with no compiled usage recorded (Qwen and NVFP4 tile kernels) and 2 qwen35_kv8 register counts over their records. Not compared against plain main.
    • sm_89 and sm_86 (nvcc 13.1): 535/535 pass, 0 fail
  • Records: all 50 decode records are current under nvcc 13.0.88, 13.2.78 and 13.3.73
  • Chips not run: sm_80

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • 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.
  • Drafted output equals "draft": false, and concurrent equals solo.
  • No precision traded for speed; the bits are unchanged.
  • Decode no slower than main, greedy and sampled: GLM, Qwen3.6 and the discrete cards gain; Flash Next on sm_120 is level with main. On GB10 the kernels compile byte-identical to main's.

@eleqtrizit eleqtrizit changed the title nvfp4 experts cuda: decode kernels stream words, scales and x through a per-warp cp.async ring nvfp4 experts cuda: decode up to 24% faster (GLM-5.3 83.8 -> 104.1 tok/s), same bits, via a per-warp cp.async ring Nov 5, 2026
@ashhart

ashhart commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thanks @eleqtrizit. The ncu read is clear (long-scoreboard stalls with DRAM 30% busy), and the change keeps the sums where they were: the same compute_stage over each group in k order, now fed from a per-warp ring. A few things before it lands:

  1. sm_121. The release's qualified GPU is the GB10, and these kernels are what Nemotron's NVFP4 decode runs there. Each block now holds about 35 KiB of static shared memory, which can change occupancy on a chip you didn't run. Please post the filtered contract on sm_121 if you can reach one, or say you can't.
  2. The release toolchain. The records are regenerated for nvcc 13.0, but every timing ran at 13.1 or 13.4. Please add one GLM or Qwen3.6 cell built with 13.0.
  3. Sampled decode, the unticked box: one sampled cell per model, main against branch.
  4. More than two rounds for the GLM headline: four ABBA rounds with fresh servers, and the spread.

The bit-equality reads right from the code.

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

I'll run on a GB10. Give me some time.

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

Thanks for the careful read. All four are below.

sm_121 (GB10, nvcc 13.0.88, driver 580.178.04), head e29bc7d

SUMMARY 583 kernels: 583 pass gates 1-4, 0 fail, 8 known findings; 366 controls: 366 red as planted, 0 missed; 190 limit problems

Filtered to the NVFP4 expert decode CTAs, every launch fits and matches its nvcc 13.0 record:

PASS limits live nvfp4_experts decode waves gate-up: 128 threads launched, the driver allows 128; 130 registers, 34816 + 0 shared bytes (recorded 130, 34816)
PASS limits live nvfp4_experts decode waves down f32: 128 threads launched, the driver allows 128; 108 registers, 25600 + 0 shared bytes (recorded 108, 25600)
PASS limits live nvfp4_experts decode half gate-up: 128 threads launched, the driver allows 128; 94 registers, 26624 + 0 shared bytes (recorded 94, 26624)
PASS limits live nvfp4_experts decode gate-up, 1 warp: 32 threads launched, the driver allows 32; 124 registers, 8704 + 0 shared bytes (recorded 124, 8704)
PASS limits live nvfp4_experts decode down f32, 1 warp: 32 threads launched, the driver allows 32; 103 registers, 6400 + 0 shared bytes (recorded 103, 6400)
PASS limits live nvfp4_experts decode down bf16, 1 warp: 32 threads launched, the driver allows 32; 103 registers, 6400 + 0 shared bytes (recorded 103, 6400)
PASS limits live nvfp4_experts decode up relu2, 1 warp: 32 threads launched, the driver allows 32; 103 registers, 6400 + 0 shared bytes (recorded 103, 6400)
PASS limits live nvfp4_experts decode waves gate-up, 1 warp: 32 threads launched, the driver allows 32; 126 registers, 8704 + 0 shared bytes (recorded 126, 8704)
PASS limits live nvfp4_experts decode waves down f32, 1 warp: 32 threads launched, the driver allows 32; 103 registers, 6400 + 0 shared bytes (recorded 103, 6400)
PASS limits live nvfp4_experts decode half gate-up, 1 warp: 32 threads launched, the driver allows 32; 90 registers, 6656 + 0 shared bytes (recorded 90, 6656)
  • The only nvfp4 FAILs are the four planted weight-only nvfp4 g64 bf16 controls, which are red as planted; their production rows pass.
  • None of the 190 limit problems is a decode CTA. The nvfp4 ones are tf_nvfp4_tile_swiglu and tf_nvfp4_tile_down_f32 (recorded 0, 0), the same as on main.

You're right about occupancy. On sm_12x the 4-warp waves gate-up CTA (34 KiB static plus the 1 KiB reservation) now fits 2 blocks per SM. Main's register-only version fit 4. However, each warp now keeps 4 k-groups of loads in flight instead of about 1, so bytes in flight per SM still go up. Measured on GB10 with Qwen3.6-35B-A3B-NVFP4 @1355db6a, 4 ABBA rounds with fresh servers (tok/s, median [min-max]):

cell main branch
fibonacci-raw greedy 123.6 [122.8-123.9] 122.8 [121.8-125.5] -0.7%
fibonacci-raw sampled 123.9 [119.7-127.8] 130.5 [130.0-131.9] +5.3%
gpu-chat-no-think greedy 110.6 [108.6-111.1] 110.6 [109.2-113.1] 0.0%
gpu-chat-no-think sampled 100.5 [98.1-103.0] 101.0 [100.2-102.4] +0.5%
concurrent code greedy, 1 / 4 streams 123.2 / 403.0 123.0 / 405.1 -0.2% / +0.5%
concurrent code sampled, 1 / 4 streams 134.8 / 278.1 132.4 / 279.5 -1.8% / +0.5%
concurrent chat greedy, 1 / 4 streams 110.0 / 356.2 110.5 / 358.5 +0.5% / +0.7%
concurrent chat sampled, 1 / 4 streams 101.3 / 241.2 101.2 / 244.9 -0.1% / +1.5%
  • On GB10 the result is neutral: most cells are within ±1% and both runs' ranges overlap. Two cells sit outside the spread, in opposite directions: sampled fibonacci at +5.3% and sampled code at 1 stream at -1.8%. GB10's LPDDR5X leaves these kernels little latency to hide, so the gain is on the discrete cards.
  • token_sha sets were identical between main and the branch, sampled included. --alone --serial was 240/240 alone and 80/80 serial equal on each side.
  • Main here is 6ec5fa4 (the 1.2.3 release commit, which only touches the version and changelog). The branch sits on cde4fe7.

nvcc 13.0 timing

GLM-5.3-Flash FP4-Local on 2x RTX PRO 6000 Blackwell, TP=2, built with nvcc 13.0.88, 2 ABBA rounds:

cell main branch
plain decode (code / code-long / chat) 83.1 / 83.1 / 83.0 104.5 / 104.3 / 104.3 +25.7%
drafted code / code-long / chat 212.1 / 157.0 / 162.3 227.2 / 174.9 / 180.9 +7.1% / +11.4% / +11.5%
bench_openai fibonacci-raw greedy / sampled 190.4 / 196.5 205.6 / 212.6 +8.0% / +8.2%
bench_openai gpu-chat-no-think greedy / sampled 140.3 / 145.6 159.8 / 163.7 +13.9% / +12.4%

Every min-max spread is within 0.4%. The token_sha sets match the nvcc 13.4 runs exactly. The GB10 table above was also built with 13.0.88.

Sampled decode and 4 ABBA rounds for the GLM headline

GLM-5.3-Flash FP4-Local, 2x RTX PRO 6000 Blackwell, TP=2, nvcc 13.4, main cde4fe7 vs e29bc7d, 4 ABBA rounds (base, cand, cand, base twice) with fresh servers, median [min-max]:

cell main branch
plain decode, code 83.7 [83.7-83.9] 104.1 [104.1-104.1] +24.4%
plain decode, code-long 83.7 [83.6-83.8] 104.0 [104.0-104.1] +24.4%
plain decode, chat 83.6 [83.6-83.8] 104.0 [103.9-104.1] +24.4%
drafted code 212.4 [212.3-212.8] 226.4 [226.3-226.6] +6.6%
drafted code-long 157.5 [157.5-157.9] 174.1 [174.1-174.3] +10.6%
drafted chat 162.8 [162.8-163.3] 180.1 [180.1-180.3] +10.7%
bench_openai fibonacci-raw greedy 190.7 [190.7-191.1] 204.9 [204.8-205.0] +7.4%
bench_openai fibonacci-raw sampled 196.9 [196.9-197.3] 211.8 [211.7-212.0] +7.6%
bench_openai gpu-chat-no-think greedy 140.9 [140.9-141.1] 159.3 [159.2-159.3] +13.1%
bench_openai gpu-chat-no-think sampled 146.1 [146.1-146.4] 163.1 [163.1-163.3] +11.6%
bench_concurrent code sampled 205.8 [205.7-206.2] 219.1 [219.1-219.2] +6.5%
bench_concurrent chat sampled 137.6 [137.6-137.8] 154.5 [154.4-154.5] +12.2%
  • Main and the branch produced the same 8 token_sha values (greedy and sampled).
  • --alone --serial: 48/48 alone and 16/16 serial equal on each side; drafted == plain on every prompt.
  • Qwen3.6 sampled cells are in the GB10 table above. The earlier Ada and A6000 runs were greedy only.

@eleqtrizit
eleqtrizit marked this pull request as ready for review November 5, 2026 20:55
@ashhart

ashhart commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Thanks @eleqtrizit, all four are answered: the sm_121 contract with every decode CTA on its nvcc 13.0 record, a GLM
cell built with 13.0.88, sampled cells, and four ABBA rounds for the headline, with token hashes equal everywhere.
The GB10 table is useful too: level within noise, and clear about the occupancy going from 4 blocks to 2. Two things
before it lands:

  1. Nemotron on a GB10. It's the other main user of these kernels on that chip, and with half the blocks per SM
    it's the family we'd most want to see. If you can reach a Nemotron NVFP4 checkpoint, main against branch, 4 ABBA
    rounds with fresh servers, 1 and 4 streams, greedy and sampled, with token_sha and each cell's range. If you
    can't, please say so.
  2. The code-sampled 1-stream cell at −1.8%. The comment is cut off in our copy right where you discuss the two
    cells outside the spread: please post that cell's main and branch ranges.
    And a CHANGELOG line under Unreleased, naming the sm_120 gain and the GB10 result as you measured them, with
    "(nvfp4 experts cuda: decode up to 24% faster (GLM-5.3 83.8 -> 104.1 tok/s), same bits, via a per-warp cp.async ring #2266, fixes nvfp4 experts cuda: decode kernels stall on load latency; a cp.async ring makes GLM-5.3 decode up to 24% faster, same bits #2265)".

@ashhart

ashhart commented Nov 6, 2026

Copy link
Copy Markdown
Owner

@eleqtrizit, one note on reach, for when you answer the three asks: Flash Next's NVFP4 decode also launches cuda.experts_waves.run (at pt == 16, cuda_nvfp4_tile.zig:24), so the 4-to-2 blocks per SM change applies there too. That needs nothing from you. Once the asks are in, we'll run, main against your branch:

  • Flash Next NVFP4 at 1, 2, 4 and 8 streams, greedy and sampled;
  • Nemotron NVFP4;
  • GLM-5.3 NVFP4 at TP=2 on two GB10s.

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart, all three are below.

1. Nemotron on a GB10

nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-NVFP4 @bee75962 on GB10 (sm_121, nvcc 13.0.88, driver 580.178.04), MTP drafts on (the default), main 6ec5fa4 vs e29bc7d. These are the same two builds as the Qwen3.6 table. 4 ABBA rounds (base, cand, cand, base twice) with fresh servers, tok/s, median [min-max]:

cell main branch
bench_openai fibonacci-raw greedy 168.1 [167.9-169.8] 168.9 [168.3-169.0] +0.5%
bench_openai fibonacci-raw sampled 153.6 [153.4-155.0] 157.5 [156.9-157.7] +2.5%
bench_openai gpu-chat-no-think greedy 131.2 [131.2-132.5] 134.3 [134.1-134.6] +2.3%
bench_openai gpu-chat-no-think sampled 119.5 [119.3-120.7] 123.4 [123.2-123.5] +3.3%
concurrent code greedy, 1 stream 168.0 [167.8-169.3] 168.7 [168.4-168.9] +0.4%
concurrent code greedy, 4 streams 470.1 [469.4-473.5] 473.4 [470.9-475.5] +0.7%
concurrent code sampled, 1 stream 134.9 [134.8-136.3] 138.4 [138.2-138.5] +2.6%
concurrent code sampled, 4 streams 238.4 [237.4-239.9] 239.8 [238.2-241.3] +0.6%
concurrent chat greedy, 1 stream 131.2 [131.1-132.3] 134.2 [134.0-134.3] +2.3%
concurrent chat greedy, 4 streams 314.7 [314.5-316.3] 319.2 [318.5-319.6] +1.4%
concurrent chat sampled, 1 stream 119.3 [119.3-120.5] 123.2 [123.0-123.4] +3.2%
concurrent chat sampled, 4 streams 201.6 [201.1-206.0] 206.5 [205.4-206.8] +2.4%
  • No cell is slower. Eight of the twelve sit outside main's range, all of them faster.
  • The token_sha sets are identical between main and the branch: 18 distinct values, greedy and sampled.
  • --alone --serial is 240/240 alone and 80/80 serial equal on each side.

2. The code-sampled 1-stream cell (Qwen3.6, GB10)

round main branch
r1 135.2 132.8
r2 134.2 130.6
r3 134.8 131.9
r4 134.7 132.8
median [min-max] 134.8 [134.2-135.2] 132.4 [130.6-132.8]
  • The ranges don't overlap, so this −1.8% looks real, not noise.
  • The same prompt at 4 streams is +0.5%: 278.1 [276.8-280.0] against 279.5 [278.7-282.3].
  • token_sha is the same on every round.

3. CHANGELOG

Added under Unreleased in 826042e, with "(#2266, fixes #2265)". The CHANGELOG is the only file it adds. It conflicts textually with main's newer Unreleased lines only.

@ashhart

ashhart commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Thanks, @eleqtrizit, these are clear. On Nemotron 3.5 Lightning NVFP4, no cell is slower: eight of the twelve are outside main's range, all faster, and the token hashes are identical, greedy and sampled.

The Qwen3.6 cell is the one thing in the way. Your rounds put the code prompt, sampled at one stream, at 132.4 [130.6-132.8] against main's 134.8 [134.2-135.2]. The ranges don't overlap, so it's a real 1.8% loss, and we don't land changes that make a served cell slower, even beside gains elsewhere.

We think the halved occupancy is the cause. Each kernel's resident-block count comes from the occupancy query (cuda/experts.zig:400), and experts_waves.pick compares it with items × blocks to choose half, classic or waves (experts_waves.zig:21-24, :32-33). With the 4 → 2 drop from the shared ring (nvfp4_experts.cu:53-56), the one-stream Qwen3.6 rows may land on a different kernel than on main.

Could you log which path pick takes there on each side? If it changed, please keep main's choice for that case, so every cell is level or faster. Once that's in, we'll run Flash Next NVFP4 at 1, 2, 4 and 8 streams, which crosses pick's switch points too, as well as the cells we listed.

When you next push, please end the line with "Thanks to @eleqtrizit." The CHANGELOG conflict is ours to settle.

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart. I logged it, and pick isn't the cause: Qwen3.6 never goes through it. qwen3_5/cuda_routed.zig:56 calls Nvfp4Experts.run directly, and only Flash Next reaches pick. The occupancy drop you pointed to is real, though. On GB10 at the same launch sizes, resident blocks went from {192,240,240,240,192,240,192} on main to {96,144,144,144,96,144,144} with the ring.

Occupancy doesn't explain the loss. A D=2 ring brought resident blocks back to {240,240,240,240,240,240,288}, and code sampled at one stream was still 1.8% slower (130.7 to 128.4). The likely cause is the cost of the ring itself on GB10's low-latency memory, but I haven't proven that.

So GB10 now keeps register loads: on __CUDA_ARCH__ == 1210 the kernels use two register stages and no shared memory. Resident blocks equal main's, so pick gets the same inputs on Flash Next. This also gives up the Nemotron gains on GB10.

GB10 (sm_121, nvcc 13.0.88), 4 ABBA rounds with fresh servers, main 6ec5fa4 vs e29bc7d + the register form, tok/s, median [min-max]:

Qwen3.6-35B-A3B cell main branch
code sampled, 1 stream 129.1 [125.1-130.1] 130.8 [129.9-132.2] +1.4%
code sampled, 4 streams 269.8 [260.7-270.2] 269.6 [268.7-269.7] -0.1%
fibonacci-raw sampled 124.7 [124.7-125.0] 126.9 [124.4-130.8] +1.7%

The other Qwen3.6 cells are -0.2% to +0.7%, and the 12 Nemotron 3.5 Lightning NVFP4 cells are -0.3% to +0.4%. Ranges overlap main in every cell, so I read this as level with main, not faster. token_sha matches main (18 distinct each side), and alone/serial is 240/240 and 80/80.

The sm_121 records are updated from real compiles. On GB10 all 10 decode CTAs pass their limits and all 608 kernels pass gates 1-4. That contract run still exits non-zero with 170 limit problems, all in kernels this PR doesn't touch: 168 "no compiled usage recorded" on Qwen and NVFP4 tile kernels, and two qwen35_kv8 register counts over their records (209 vs 205, 248 vs 247). I didn't run the contract on plain main to compare.

Preprocessed source for sm_80/86/89/120 is byte-identical with and without this change, so those results stand. sm_80 has still never been run on this PR. The CHANGELOG line now ends with "Thanks to @eleqtrizit." Flash Next NVFP4 at 1, 2, 4 and 8 streams is yours when you're ready.

@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@eleqtrizit thanks, this settles the GB10 question cleanly. pick isn't on Qwen3.6's path (cuda_routed.zig:56), and the D=2 test separates the ring's cost from occupancy. The sm_121 records now match main's register counts with no shared memory, and the non-GB10 source is the ring as before. With GB10 back on register loads, the halved occupancy lives only on sm_80/86/89/120. That leaves:

  1. Qwen3.6-35B-A3B NVFP4, code prompt, sampled at 1 stream, on sm_120 or sm_89: main against branch, 4 A-B-B-A rounds with fresh servers, each side's range and token_sha. That's the cell that lost 1.8% on GB10, and it hasn't run sampled on a ring chip yet.
  2. If you can reach a Flash Next NVFP4 checkpoint on sm_120: 1, 2, 4 and 8 streams, greedy and sampled, since its experts_waves.pick sees the new occupancy there. If you can't, please say so.
  3. sm_80 takes the ring too. If you can reach an A100, one Qwen3.6 cell would cover it.
  4. Optional: cuobjdump -sass of the 10 decode CTAs on sm_121a, main against branch.
  5. Please re-run the lean checker on this head.

The CHANGELOG conflict is ours.

@eleqtrizit

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart. Results on dc4b7812f, against main b4db86321. The new head adds only the CHANGELOG move noted at the end.

1. Qwen3.6-35B-A3B NVFP4 on sm_120 (RTX PRO 6000 Blackwell, one card, nvcc 13.4.92, @1355db6a, 4 ABBA rounds with fresh servers, tok/s, median [min-max]):

cell main branch
code sampled, 1 stream 414.2 [414.0-415.0] 472.3 [472.2-472.4] +14.0%
code sampled, 4 streams 1152.8 [1151.2-1155.9] 1199.3 [1198.5-1200.6] +4.0%
code greedy, 1 stream 384.6 [383.3-385.5] 439.0 [438.3-439.4] +14.1%
code greedy, 4 streams 1359.8 [1357.7-1362.8] 1519.8 [1517.8-1521.8] +11.8%
chat sampled, 1 stream 308.0 [307.9-308.7] 352.7 [352.7-352.8] +14.5%
chat sampled, 4 streams 953.6 [952.0-955.4] 998.1 [997.1-999.2] +4.7%
chat greedy, 1 stream 339.1 [338.0-339.7] 388.0 [387.4-388.5] +14.4%
chat greedy, 4 streams 1168.6 [1167.6-1171.3] 1308.9 [1306.5-1310.1] +12.0%

The four bench_openai cells are +13.2% to +14.6%. No ranges overlap. token_sha sets are identical (18 distinct), and alone/serial is 240/240 and 80/80 on both sides.

2. Flash Next NVFP4 on sm_120 (nvidia/Qwen3.8-Flash-Next-NVFP4 @fc694b54, TP=2 on two cards in one host, nvcc 13.4.92, same rounds, MTP drafts on, tok/s):

cell main branch
code sampled, 1 134.4 [133.8-134.9] 134.5 [132.8-134.9] +0.0%
code sampled, 2 203.9 [203.4-204.3] 204.1 [201.5-204.4] +0.1%
code sampled, 4 360.6 [356.1-361.2] 359.9 [352.7-360.5] -0.2%
code sampled, 8 538.0 [533.8-540.0] 536.9 [533.5-537.5] -0.2%
code greedy, 1 137.6 [135.8-138.0] 137.4 [136.3-137.6] -0.1%
code greedy, 2 244.4 [241.9-244.7] 244.3 [243.1-245.0] -0.0%
code greedy, 4 442.8 [435.4-443.2] 443.6 [443.1-444.1] +0.2%
code greedy, 8 657.8 [653.4-660.6] 667.0 [661.3-669.6] +1.4%
chat sampled, 1 82.3 [81.9-82.9] 82.9 [81.9-83.0] +0.7%
chat sampled, 2 151.2 [150.4-152.3] 152.2 [150.4-152.3] +0.7%
chat sampled, 4 264.8 [262.8-267.4] 266.6 [262.2-267.0] +0.7%
chat sampled, 8 418.8 [416.2-421.2] 420.4 [414.8-421.2] +0.4%
chat greedy, 1 90.8 [89.4-91.0] 90.6 [90.4-90.8] -0.2%
chat greedy, 2 156.8 [155.8-157.9] 157.6 [157.4-157.9] +0.5%
chat greedy, 4 290.8 [287.3-292.5] 292.4 [291.3-293.0] +0.6%
chat greedy, 8 486.6 [482.9-488.9] 491.9 [490.3-492.5] +1.1%

Level with main: 14 of the 16 cells overlap main's range, and the other two (greedy at 8 streams, code and chat) are faster. token_sha sets are identical, and alone/serial is 720/720 and 288/288 on both sides. I didn't log which path pick took, so this shows the outcome, not the kernel choice.

3. sm_80: I can't reach an A100, so it remains unrun.

4. SASS on sm_121a: nvcc 13.0.88, nvfp4_experts.cu at main vs this head. cuobjdump -sass and -res-usage are byte-identical for all 19 functions, including the 10 decode CTAs. So GB10 compiles to main's kernels, and the small differences in my last GB10 table, including +1.4%, are noise.

5. Lean checker on this head: 398 vs 398 at the merge base, 0 new.

One CHANGELOG note: the last rebase had left our line at the end of ## 1.2.5, so I moved it back to the end of ## Unreleased to save you sorting that out. It still ends with "Thanks to @eleqtrizit."

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Thanks @eleqtrizit, that answers everything:

  • Qwen3.6 on sm_120 is 4.0 to 14.6% faster in every cell, with no overlapping ranges, and Flash Next at TP=2 is level from
    one to eight streams. So the halved occupancy on the ring chips costs nothing we can see.
  • With the SASS byte-identical on GB10 for all 19 functions, GB10 runs main's kernels, which settles the −1.8% cell.
  • sm_80 staying unrun is fine; thanks for saying so.
  • Lean is clean, and the CHANGELOG line is back under Unreleased with the thanks.

Since GB10 now builds main's kernels, the GB10 runs we listed on 6 Nov would compare a kernel with itself. Instead, we'll
compare the SASS of our release build (plain sm_121) against main and run the kernel contract on a GB10. Main is frozen
for a release right now; once that's out and the SASS matches, this goes on the landing queue.

@ashhart

ashhart commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Thanks @eleqtrizit. Our two checks on a GB10 are clean on 2efcaa446:

  • SASS: a plain sm_121 build of every CUDA fatbin, main against this head: 112 images on each side, 1,135 functions identical, none changed, added or removed. GB10 runs exactly main's kernels, as you said.
  • Kernel contract: the device contract at sm_121 and the launch limits at the five release targets show no failure line that main doesn't already have (246 known on both sides, 0 new; limits 0 and 0).

With your sm_120 numbers (GLM-5.3 at TP=2 up to 24% faster, Qwen3.6 4-15% faster, tokens equal) and these, it's queued to land, with your CHANGELOG line as written.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

@eleqtrizit this was in a landing train today, but zig/kernels/cuda/nvfp4_experts.cu is one of the serving sources pinned by sha256 in zig/tests/fixtures/gradient-serving.tsv, and the PR changes it without updating its pin, so test-gradient-serving failed on the train's tip. Since our GB10 checks on 2efcaa446 were clean (identical sm_121 SASS, contract level), I rebased it onto current main and added one commit that re-pins that file, and pushed it to your branch; your commits are otherwise unchanged. The serving-pin test and the landing gate pass, and it goes back in the queue now. For future changes to a pinned file, zig build -Dfixed-cpu test-gradient-serving shows which pin to update. No other asks.

  • Synthena (Ash's Agent)

ashhart added a commit to eleqtrizit/TensorFold that referenced this pull request Nov 13, 2026
@ashhart

ashhart commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Our GB10 check is in: GLM-5.3-Flash NVFP4 at TP=2 on two GB10s (sm_121), main against e8ae8e1, fresh launches base, new, new, base, plus a chat pair.

  • Tokens: equal in all 52 cells, and the chat resume cells cache identically on both arms.
  • Speed: level. Decode moves +0.0% to +1.5% (chat and code, one and two streams). Prompts are level at 2K and 32K. At 8K the median reads −4.1%, but every run, base included, slows within its own samples (base's last run fell from 827 to 716 tok/s as well), so that's the box, not this change.

The +24% in your description was measured on RTX PRO 6000 (sm_120) with drafts off. It doesn't show up on GB10's sm_121 path, but nothing gets slower there either. That's all we need. It's queued to land.

  • Synthena (Ash's Agent)

eleqtrizit and others added 9 commits November 19, 2026 05:47
…hrough a per-warp cp.async ring

ncu showed nvfp4_expert_half stalled on long scoreboard (~110k cycles a
warp): the register pipeline kept about one k-group in flight and the
activation loads missed L1, while DRAM sat near 30% busy. Each warp now
keeps a 4-stage cp.async ring in shared memory for its weight words,
block scales and x halves, and computes in the same k order, so sums
are bit-identical.

GLM-5.3 FP4-Local, 2x RTX PRO 6000 TP=2: one-row gate-up 69.8 -> 31.7 us;
plain decode 90.0 -> 105.7 tok/s; reply shas unchanged, drafted == plain.
Kernel contract: 551 pass gates 1-4, limit problems unchanged. The half
gate-up limit records (regs, static shared bytes) come from nvcc 13.4.92.
…per-warp cp.async ring

The ring that made the half gate-up kernel bandwidth-bound now feeds the classic and waves decode kernels too
(gate-up and down, 1 and 4 warps): one Ring helper streams each warp's words, scales and inputs D = 4 k32 groups
ahead, and the sums still run in k order, so every kernel keeps its bits.

GLM-5.3 FP4-Local, 2x RTX PRO 6000 TP=2, against the half-kernel ring alone: drafted code 220.1 -> 229.0 tok/s,
code-long 172.9 -> 175.9, chat 177.6 -> 182.1; plain 105.7 -> 107.9. Reply shas unchanged, drafted == plain.
Decode bench, one row: classic gate-up 88.0 -> 38.5 us, down 19.7 -> 13.1 us.

Limit records here are nvcc 13.4.92's; the 13.0 base and 13.2/13.3 sets are still to be re-derived.
On sm_121 the shared-memory ring halved resident blocks and cost Qwen3.6 code sampled 1.8% at one stream; a D=2 ring
restored occupancy and kept the loss. GB10 now loads two stages in registers with no shared memory, level with main.
Preprocessed source for sm_80/86/89/120 is unchanged. sm_121 limit records come from real nvcc 13.0.88 and 13.2.78
compiles.
@ashhart
ashhart merged commit 264d864 into ashhart:main Nov 19, 2026
2 of 11 checks passed
@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thank you @eleqtrizit. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

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.

nvfp4 experts cuda: decode kernels stall on load latency; a cp.async ring makes GLM-5.3 decode up to 24% faster, same bits

2 participants