Skip to content

CUDA: pair Qwen3.8 FP8 GDN QKV and Z projections - #4664

Draft
Maharajahu wants to merge 2 commits into
ashhart:mainfrom
Maharajahu:qwen-cuda-fp8-gdn-qkv-z
Draft

Maharajahu wants to merge 2 commits into
ashhart:mainfrom
Maharajahu:qwen-cuda-fp8-gdn-qkv-z

Conversation

@Maharajahu

@Maharajahu Maharajahu commented Nov 22, 2026 •

Copy link
Copy Markdown

What this changes

Qwen3.8-27B NVFP4 now uses one CUDA launch for the two scalar-FP8 Gated DeltaNet QKV and Z projections when the SM120 forward has exactly 16 rows. Each cluster still processes one output tile with the existing 128-thread tile, two K slices, accumulation order, and BF16 output rounding. The paired entry uses the existing qmmf body.

Checks on this head

  • Head commit: e39457e4b0b85071c427def1bc6dda99eebe8f80. Its sole difference from the code and measurement commit 91b97a4862218ab511e48b9a33a2216c761350e2 is the Unreleased changelog entry for this PR.
  • Lean checker: 165 on base and head, 0 new. tools/pr_check.py --base origin/main --pr 4664 reported 0 errors and 0 warnings on the pushed head.
  • zig build test test-golden -Dcpu=baseline -Doptimize=ReleaseFast on Windows: 775/775 steps succeeded, 2,717 tested cases passed and 96 skipped in this incremental invocation. Remaining steps were reused from cache.
  • zig fmt --check build.zig zig and git diff --check origin/main..HEAD passed.
  • zig build -Dgpu=sm_120 -Dnvcc=PATH -Doptimize=ReleaseFast: 151/151 steps on WSL2.
  • zig build check-pdl-loads -Dsm=120 -Dnvcc=PATH: 0 early reads in 212 functions from nine CUDA images. The PDL Python suite passed 18/18.
  • CI: pending on the submitted head.
  • Not run: native Windows CUDA serving. Unmodified main fails to compile GLM CUDA sources with the installed Windows nvcc, so both served variants use WSL2. Metal, HIP, and CUDA devices other than SM120 were outside the runtime test matrix.

Receipt

  • Environment: RTX 5090, 32 GB VRAM, Windows NVIDIA driver 617.42, Ubuntu 24.04.5 LTS in WSL2, Zig 0.17.0, nvcc 13.1.115. NVIDIA Qwen3.8-27B NVFP4 482ca0f3832238542f8f5295dde86b5f22711d80 and DFlash2 50307d4c4cde6860d4eee73e2547cd786fe8e8a4.
  • Base binary: 462f5eca3e2a6c8095c2d2c7504a37d8e3768925. Its delta to the final merge base is two DeepSeek test files and changelog. Candidate served binary: 91b97a4862218ab511e48b9a33a2216c761350e2.
  • Main and candidate used the same public prompts, seed and greedy settings, FP8 KV, DFlash2, and a 15-node cap. 128K tests used one stream. Four-stream tests used an 8K context. Served diagnostics observed min_rows=16 on both binaries.
  • Switch: n/a. The pair is selected for the compatible production shape on SM120.
  • Kernel microbenchmark: 36 alternating CUDA Graph trials per arm with 96 pairs of projections per trial and eight weight banks. The median per projection pair was 58.088 → 54.097 µs. Thirty output and guard comparisons passed on 524,288 output bytes per case.
  • Model replay: the fixed 16-row window produced 31,784,960 identical bytes of FP32 logits in an earlier candidate with the same dispatch and CUDA arithmetic. SHA-256 ff6166226c1b344d61efb8feaf76f6f2760c9a9f998639333554d1024b2ad8f1.
  • Reproduce served benchmarks with python3 tools/bench_qwen_fp8_pair.py SERVER MODEL DRAFTER OUTPUT --suite decode-prefill --tokens 128 --reps 3. For the concurrency cells use --suite concurrent --context 8192 --parallel 4 --tokens 128 --reps 1.
  • New weights or drafter license: n/a. The comparisons use identical checkpoint revisions on both arms.

CUDA launch strategies on SM120

This follow-up uses the same RTX 5090, FP8 weights, activation inputs, and compiled qmmf image for all three arms. The separate arms run the existing 128-thread scalar FP8 kernels. Each trial measures a CUDA Graph with 96 projection pairs and rotates across eight weight banks.

Strategy Trials Median (µs/pair) Min–max (µs/pair)
Two launches on one stream 36 57.982 57.873–58.438
Two launches on two streams with fork/join events 36 55.199 54.875–55.876
One fused launch 36 54.047 53.956–54.235

Two streams recovered 2.78 µs of the sequential baseline. The fused launch saved a further 2.09% versus two streams. All 60 output comparisons were byte-identical over 524,288 bytes per case, with guard bytes intact.

Three-way microbenchmark timing samples, µs per pair
{"successive":[58.19633102,58.2816658,58.17699814,58.43832779,57.99833679,57.93099976,57.95733261,57.88133621,57.97133255,57.89700317,57.90233231,58.1713295,57.93600082,58.2183342,58.01133347,57.89466858,57.9106636,57.93033218,58.02433395,58.01533127,58.0356636,57.96033096,57.98600388,57.93233109,57.93533325,58,57.98933411,57.87333298,57.99633408,58.03466797,57.93466568,58.0146637,57.9786644,57.95899963,58.00700378,57.97200012],"two_streams":[55.56466675,55.25999832,55.87600327,55.31433105,55.18133545,55.49699783,55.06433487,54.98899841,55.19266129,54.875,55.23733521,55.48066711,55.22066879,55.29533386,55.21966553,55.20633316,55.20000076,55.16433334,55.19733047,55.33833313,55.30866623,55.19067001,55.02633286,55.08533096,54.94466782,55.08466721,55.26433182,54.95632935,55.16333389,55.08333206,55.0316658,55.22599792,55.03133774,55.03700256,55.21666336,55.22900009],"fused":[54.23466873,54.23266602,54.16666794,54.07600021,54.09199905,54.00033188,54.04299927,54.02099991,54.01233292,53.99399948,54.0316658,54.0890007,54.0423317,54.04699707,54.02033615,54.07799911,54.04166794,54.11999893,54.07733154,54.03666687,54.02532959,54.07633591,53.98266602,54.01199722,54.04966736,54.04566956,54.03066635,54.02499771,54.04866409,54.06700134,54.04666519,54.16900253,54.07733154,54.0870018,54.11300278,53.9560051]}

Served A/B

The cold fixture IDs, token fingerprints, and output hashes matched across the tested binaries. Full token hashes matched for the smoke and five cold lengths. Greedy drafted replies matched "draft": false. The four-stream cells matched their standalone twins for both prompts.

Median decode at 128K capacity, in tok/s. The base replay has two 128-token repetitions per cell and the pushed head has three.

Prompt Main Head Change
fibonacci-raw 269.54 272.95 +1.26%
gpu-chat-no-think 216.65 223.16 +3.01%

First-request TTFT in seconds. The full cold run covered 130,816 prompt tokens, leaving room for output within the 131,072-token capacity. Every tested TTFT difference was within 0.3%.

Prompt tokens Main Head Cached tokens
2,048 0.5207 0.5221 0
8,192 2.1198 2.1218 0
32,768 9.5500 9.5634 0
65,536 21.8186 21.8517 0
130,816 54.6455 54.6743 0

Single-sample aggregate decode at 8K context, in tok/s.

Prompt Streams Main Head Head solo hash matches
code 1 259.7 273.1 1/1
code 4 575.6 574.5 4/4
chat 1 214.9 217.2 1/1
chat 4 377.4 378.4 4/4
Raw timing samples and response fingerprints
{"base":{"smoke_token_sha256":"5b5aee39478f3b3b0c8257bbdfb48a12cad3f409a4c935ddddc2775575600a5c","decode":{"fibonacci-raw":{"median_tok_s":269.54258873236984,"samples_tok_s":[269.57,269.52],"token_fingerprints":["54154e1e4a68","54154e1e4a68"],"output_sha256":["f6681fc4096a2afee8f614093d34ba8f087f823dea549555a572289beab77c32","f6681fc4096a2afee8f614093d34ba8f087f823dea549555a572289beab77c32"]},"gpu-chat-no-think":{"median_tok_s":216.64565603579535,"samples_tok_s":[213.94,219.35],"token_fingerprints":["562daa043166","562daa043166"],"output_sha256":["0b49d927e63c55f7fb2515ad72a89a9fd407ae3cc3c97ecd2f46e512a70f0300","0b49d927e63c55f7fb2515ad72a89a9fd407ae3cc3c97ecd2f46e512a70f0300"]}},"prefill":{"2048":{"fixture_sha256":"3e753c1250a8a57743cd8a46ac68893ce736ed218cfbb9681901f249a197c3f0","ttft_s":[0.5206635350000397,0.510511772999962,0.510897340000156],"token_sha256":["31902dd2f98a4f4165d466fccc3a6a4cfc7133fd19fa2bcf0f4bc5b925547321","31902dd2f98a4f4165d466fccc3a6a4cfc7133fd19fa2bcf0f4bc5b925547321","31902dd2f98a4f4165d466fccc3a6a4cfc7133fd19fa2bcf0f4bc5b925547321"]},"8192":{"fixture_sha256":"61a7b455f4ffad1969ff2ac6f8821460e72d5aa40bf27677660b1c662964b4c9","ttft_s":[2.1197655820001273,2.110145384999896,2.11296506199983],"token_sha256":["9d2a4c21b5778520ccbfbd5c7e50ca875fe3af74569031396d6eec90e0ce4033","9d2a4c21b5778520ccbfbd5c7e50ca875fe3af74569031396d6eec90e0ce4033","9d2a4c21b5778520ccbfbd5c7e50ca875fe3af74569031396d6eec90e0ce4033"]},"32768":{"fixture_sha256":"cc804f8d47e3ccda74480aa8c2c7c2b8e47ea7022298b5684a1027beca33fe19","ttft_s":[9.549979567000037,9.545949171000075,9.54899315800003],"token_sha256":["ebf2cdf53eb4759b0bc0295346663c592f4c54e9b53e76136defa79240e8c579","ebf2cdf53eb4759b0bc0295346663c592f4c54e9b53e76136defa79240e8c579","ebf2cdf53eb4759b0bc0295346663c592f4c54e9b53e76136defa79240e8c579"]},"65536":{"fixture_sha256":"623649f8d5c589d936ef0268ea99d3875d816cda654f45e07fca1ffd40fb8e0e","ttft_s":[21.818554001999928,21.838143159999845,21.869441111000015],"token_sha256":["c4fc9684a1493647375040f2784276e19b00dcc06436bf27ebb5ea2a743fcde9","c4fc9684a1493647375040f2784276e19b00dcc06436bf27ebb5ea2a743fcde9","c4fc9684a1493647375040f2784276e19b00dcc06436bf27ebb5ea2a743fcde9"]},"130816":{"fixture_sha256":"a12db87248d24d12b51c6822cc2e69a8c4fab770ba6cb231f5653f47cfc60861","ttft_s":[54.64548565600012,54.64436188500008,54.58184911399985],"token_sha256":["3b6c238a525e554b1e22aec63af8e0154051aff4f756e148f802270d98ebabdd","3b6c238a525e554b1e22aec63af8e0154051aff4f756e148f802270d98ebabdd","3b6c238a525e554b1e22aec63af8e0154051aff4f756e148f802270d98ebabdd"]}},"concurrency":[{"prompt":"code","streams":1,"aggregate_tps":259.7,"alone":{"equal":1,"unequal":0,"failed":0},"serial":{"equal":1,"unequal":0,"failed":0,"accepted":102,"plain_drafted":0}},{"prompt":"code","streams":4,"aggregate_tps":575.6,"alone":{"equal":4,"unequal":0,"failed":0},"serial":{"equal":1,"unequal":0,"failed":0,"accepted":102,"plain_drafted":0}},{"prompt":"chat","streams":1,"aggregate_tps":214.9,"alone":{"equal":1,"unequal":0,"failed":0},"serial":{"equal":1,"unequal":0,"failed":0,"accepted":96,"plain_drafted":0}},{"prompt":"chat","streams":4,"aggregate_tps":377.4,"alone":{"equal":4,"unequal":0,"failed":0},"serial":{"equal":1,"unequal":0,"failed":0,"accepted":96,"plain_drafted":0}}]},"head":{"smoke_token_sha256":"5b5aee39478f3b3b0c8257bbdfb48a12cad3f409a4c935ddddc2775575600a5c","decode":{"fibonacci-raw":{"median_tok_s":272.95153905114984,"samples_tok_s":[274.12,272.17,272.95],"token_fingerprints":["54154e1e4a68","54154e1e4a68","54154e1e4a68"],"output_sha256":["f6681fc4096a2afee8f614093d34ba8f087f823dea549555a572289beab77c32","f6681fc4096a2afee8f614093d34ba8f087f823dea549555a572289beab77c32","f6681fc4096a2afee8f614093d34ba8f087f823dea549555a572289beab77c32"]},"gpu-chat-no-think":{"median_tok_s":223.16334009990223,"samples_tok_s":[223.16,223.46,222.68],"token_fingerprints":["562daa043166","562daa043166","562daa043166"],"output_sha256":["0b49d927e63c55f7fb2515ad72a89a9fd407ae3cc3c97ecd2f46e512a70f0300","0b49d927e63c55f7fb2515ad72a89a9fd407ae3cc3c97ecd2f46e512a70f0300","0b49d927e63c55f7fb2515ad72a89a9fd407ae3cc3c97ecd2f46e512a70f0300"]}},"prefill":{"2048":{"fixture_sha256":"3e753c1250a8a57743cd8a46ac68893ce736ed218cfbb9681901f249a197c3f0","ttft_s":[0.5220763049999277,0.5111275899998873,0.5111758099999406],"token_sha256":["31902dd2f98a4f4165d466fccc3a6a4cfc7133fd19fa2bcf0f4bc5b925547321","31902dd2f98a4f4165d466fccc3a6a4cfc7133fd19fa2bcf0f4bc5b925547321","31902dd2f98a4f4165d466fccc3a6a4cfc7133fd19fa2bcf0f4bc5b925547321"]},"8192":{"fixture_sha256":"61a7b455f4ffad1969ff2ac6f8821460e72d5aa40bf27677660b1c662964b4c9","ttft_s":[2.121812794000107,2.1150687259998904,2.118147386999908],"token_sha256":["9d2a4c21b5778520ccbfbd5c7e50ca875fe3af74569031396d6eec90e0ce4033","9d2a4c21b5778520ccbfbd5c7e50ca875fe3af74569031396d6eec90e0ce4033","9d2a4c21b5778520ccbfbd5c7e50ca875fe3af74569031396d6eec90e0ce4033"]},"32768":{"fixture_sha256":"cc804f8d47e3ccda74480aa8c2c7c2b8e47ea7022298b5684a1027beca33fe19","ttft_s":[9.56337090199986,9.553508738000119,9.55587532100003],"token_sha256":["ebf2cdf53eb4759b0bc0295346663c592f4c54e9b53e76136defa79240e8c579","ebf2cdf53eb4759b0bc0295346663c592f4c54e9b53e76136defa79240e8c579","ebf2cdf53eb4759b0bc0295346663c592f4c54e9b53e76136defa79240e8c579"]},"65536":{"fixture_sha256":"623649f8d5c589d936ef0268ea99d3875d816cda654f45e07fca1ffd40fb8e0e","ttft_s":[21.85170700300023,21.86398734000022,21.880697990000044],"token_sha256":["c4fc9684a1493647375040f2784276e19b00dcc06436bf27ebb5ea2a743fcde9","c4fc9684a1493647375040f2784276e19b00dcc06436bf27ebb5ea2a743fcde9","c4fc9684a1493647375040f2784276e19b00dcc06436bf27ebb5ea2a743fcde9"]},"130816":{"fixture_sha256":"a12db87248d24d12b51c6822cc2e69a8c4fab770ba6cb231f5653f47cfc60861","ttft_s":[54.67429834099994,54.66572791699991,54.66712659599989],"token_sha256":["3b6c238a525e554b1e22aec63af8e0154051aff4f756e148f802270d98ebabdd","3b6c238a525e554b1e22aec63af8e0154051aff4f756e148f802270d98ebabdd","3b6c238a525e554b1e22aec63af8e0154051aff4f756e148f802270d98ebabdd"]}},"concurrency":[{"prompt":"code","streams":1,"aggregate_tps":273.1,"alone":{"equal":1,"unequal":0,"failed":0},"serial":{"equal":1,"unequal":0,"failed":0,"accepted":101,"plain_drafted":0}},{"prompt":"code","streams":4,"aggregate_tps":574.5,"alone":{"equal":4,"unequal":0,"failed":0},"serial":{"equal":1,"unequal":0,"failed":0,"accepted":101,"plain_drafted":0}},{"prompt":"chat","streams":1,"aggregate_tps":217.2,"alone":{"equal":1,"unequal":0,"failed":0},"serial":{"equal":1,"unequal":0,"failed":0,"accepted":96,"plain_drafted":0}},{"prompt":"chat","streams":4,"aggregate_tps":378.4,"alone":{"equal":4,"unequal":0,"failed":0},"serial":{"equal":1,"unequal":0,"failed":0,"accepted":96,"plain_drafted":0}}],"serial_128k":[{"prompt":"code","streams":1,"aggregate_tps":273.3,"alone":{"equal":1,"unequal":0,"failed":0},"serial":{"equal":1,"unequal":0,"failed":0,"accepted":102,"plain_drafted":0}},{"prompt":"chat","streams":1,"aggregate_tps":221.7,"alone":{"equal":1,"unequal":0,"failed":0},"serial":{"equal":1,"unequal":0,"failed":0,"accepted":96,"plain_drafted":0}}]}}

TraceView coding benchmark at 128K

Both runs used the same TraceView task and Nsight inputs, Qwen3.8-27B NVFP4, Codex CLI 0.171.0-alpha.13, low reasoning, and the RTX 5090. The cutoff for both was the request that starts the first demo recording. The timings cover implementation, tests, and Chromium verification.

Metric BLACKFURY Exact v1.0.2 TensorFold PR #4664
Time to verified product 9m 19s 25m 3s
Weighted decode (tok/s) 279.78 246.05
Weighted fresh prefill (tok/s) 2672.78 2917.67
Reused input 92.27% 0.00%
Completed model requests 93 66
Generated tokens 97,498 65,802

BLACKFURY ran natively on Windows with nine draft nodes, up to 2,048 rows per prefill pass, and its own FP8 fusion. The upstream run used WSL2, 15 draft nodes, and up to 4,096 prefill rows. It reported zero reused input and spent 1192.6 seconds in active prefill. Treat these as whole-configuration results for an autonomous workload. The controlled CUDA comparison above isolates the launch strategy.

The upstream run completed 16 product tests and 20 independent numerical checks on the provided captures. Its output also passed 20 numerical checks on a held-out capture.

CUDA kernel contract

The paired launch names the two existing scalar FP8 lane launches as its replacement. The test covers non-finite input, repeatability, guard bytes, and exact replacement bytes in both projections. The planted Z scale mismatch was detected at byte 327,680, the start of the Z output.

SUMMARY FP8 QKV and Z pair gates 1-4: 1 pass, 0 fail; 1 controls red, 0 missed

Exit 0 on RTX 5090. The entry's measured pinned nvcc 13.0.88 records for SM120 and SM121 are 40 registers/thread, 1,024 static shared bytes (reserved), 24,576 dynamic shared bytes, zero local bytes, 128 launch bound, and a two-block cluster. SM121 runtime was not run.

Checklist

  • Title, stack, and evidence identify their tested commits.
  • The replacement fixture passes and its planted control fails as intended.
  • Source and evidence use public inputs and contain no local account paths.
  • The paired path uses the existing lane rounds and arithmetic.
  • Final textual overlap checked against the stated base and inherited hunks identified.
  • Maintainer CI and review.

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