Repository navigation
perf(b12x/gemm): decouple .cs weight streaming, lower NVFP4 evict_first, and tune SM121 blockscaled/WO - #188
Open
original-el8 wants to merge 1 commit into
Open
original-el8 wants to merge 1 commit into
original-el8 wants to merge 1 commit into
Conversation
…st, and tune SM121 blockscaled/WO - Decouple ld_global_cs_v4_u32 weight streaming from use_pdl in MXFP8 and grouped WO TC-GEMV kernels while keeping .nc loads on activations/scales. - Lower NVFP4MultiRowTCGemvKernel evict_first threshold from n >= 65536 to n >= 16384 so wide projections stream weights past L2 at M <= 16. - Extend SM121 (12, 1) blockscaled tuning: enable tile_n=32 defaults (M >= 17, 512 <= N <= 2560), allow mma_warps=8 when chunks_per_split is divisible by 8 on M <= 16 or sm_count <= 64, retain compact 6 <= M <= 28 TMA A16 and wide-N (N >= 16384) quantized M64xN64 candidates, and bump candidate_contract_version (62 -> 63). - Support chunks_per_program=64 with num_warps=8 for tokens > 32 and dynamic_tokens prefill quantizers in wo_mxfp8.py. - Update test_decode_gemm_moe_contracts.py for SM121 tile_n=32 and add unit tests for NVFP4 evict_first, 64-chunk WO quantization, and SM121 MXFP8 tuning. Validated on CPU with CUDA_VISIBLE_DEVICES="" (92 passed, 724 CUDA-skipped across 16 blockscaled/WO/MXFP8/NVFP4 test files). Signed-off-by: Jason Cook <jasonc@maxlyn.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Description
Optimize SM121 blockscaled GEMV, grouped WO projection, and MXFP8 WO quantization with decoupled cache-streaming weight loads, lowered NVFP4
L2::evict_firstwidth thresholds, expanded SM121tc_gemvwarp/tile predicates, compact6 <= M <= 28MXFP8 search candidates, and 64-chunk prefill WO quantization:flashinfer/experimental/b12x/gemm/blockscaled/_mxfp8_tc_gemv.py&flashinfer/experimental/b12x/gemm/wo_projection/_tc_gemv.py: decoupleld_global_cs_v4_u32weight streaming fromuse_pdlso weight matrices stream with.cswhile activations and scales keep.nccaching whenuse_pdl=False; bumpgemm.blockscaled.mxfp8_tc_gemv(9 -> 10),gemm.blockscaled.mxfp8_tc_gemv_rope(5 -> 6), andgemm.wo_projection.grouped_woa_tc_gemv(5 -> 6).flashinfer/experimental/b12x/gemm/blockscaled/_nvfp4_tc_gemv.py: lowerNVFP4MultiRowTCGemvKernel.evict_firstwidth threshold fromn >= 65536ton >= 16384and bumpgemm.blockscaled.nvfp4_tc_gemv(5 -> 6).flashinfer/experimental/b12x/gemm/blockscaled/_tuning.py: extend_tc_gemv_default_configtile_n=32(M >= 17, active_k >= 2048, 512 <= N <= 2560) andtc_n32_ok(M >= 12) to(12, 1), enablemma_warps=8whenchunks_per_split > 4is divisible by 8 onM <= 16orsm_count <= 64, retain compact6 <= M <= 28TMA A16 (16x{32,64,128}x256) and wide-N (N >= 16384) quantized64x64candidates inprefer_tc_gemv, and bumpcandidate_contract_version(62 -> 63).flashinfer/experimental/b12x/gemm/_shared/wo_mxfp8.py: permitchunks_per_program=64in_wo_quant_chunks_per_programfortokens > 32anddynamic_tokensprefill paths, and launchnum_warps=8whenchunks >= 32(4x fewer programs onK=4096/K=2048prefill groups).tests/experimental/b12x/gemm/test_decode_gemm_moe_contracts.py: update SM121tile_n=32assertions and add unit tests forNVFP4MultiRowTCGemvKernel.evict_first,_wo_quant_chunks_per_program(..., maximum=64), SM121mma_warps=8defaults, and compact6 <= M <= 28search candidates.Benchmark Results (NVIDIA GB10, SM121, 48 SMs, 273 GB/s LPDDR5x)
1. 20-Op Sequential Chain
.csvs PDL Ablation (174.15 MB,637.9 usfloor)Conditions: captured CUDA graph over
[qkv_a -> q_b -> GroupedWoa -> bf16.router -> shared.gate_up -> shared.down] x 3 + qkv_a + engram, bit-identical outputs across all modes:Mno_pdl(us)no_pdl + cs(us)full_pdl + cs(us).csGain.csAcross
M in {1, 3, 6, 8, 12, 16, 24}inbench_ds41_chain_pdl.py,full_pdl_csreduces chain latency by 43.4–78.2 us (5.0%–8.8%) vsno_pdl.2. NVFP4
draft.head(5120 -> 32320,93.10 MB,341.0 usfloor)evict_first=FalseatM <= 16):410.9–424.6 us(verify_final_gains.py) /405.0–417.4 us(bench_ds41_chain_pdl.py).n >= 16384evict_first=True(no PDL, bit-identical):366.7–375.5 us(90.8%–93.0%of 273 GB/s,-37.7to-49.1 us); with PDL+evict_first:361.3–368.7 us(92.5%–94.4%).3. Cold-Pool SM121 MXFP8 Shapes (
>48 MBrotating weight pools)K -> N, weight, floor)Mdefault(us, % 273)qkv_a(5120 -> 2112, 11.16 MB, 40.9 us)tc(w=8)49.8–51.5 /a16_tma47.1 (86.8%)qkv_aa16_tma47.1 / 46.5 (88.0%) / 51.0 (80.2%)q_b(1536 -> 3072, 4.87 MB, 17.8 us)tc(tn=16,sk=1,w=8)20.7–21.1 (85.6%)M=6)shared.gate_up(5120 -> 1152, 6.08 MB, 22.3 us)tc(tn=16,sk=1,w=8)24.6–24.9 (90.3%)shared.gate_upa16_tma26.0 / 24.8 /tc(tn=32,w=8)26.9engram(1536 -> 25600, 40.55 MB, 148.5 us)quant166.5 /a16_tma171.2 /quant174.1 / 183.3Conclusion: decoupling
.csweight streaming from PDL captures 4.0%–6.9% chain speedup without enabling consumer PDL on SM121; lowering the NVFP4evict_firstthreshold liftsdraft.headup to 93.0% peak bandwidth; and SM121mma_warps=8,tile_n=32, and compact6 <= M <= 28search candidates resolveqkv_a,shared.gate_up, andengrambottlenecks.Combined-Stack End-to-End TP4 Serving Verification (
flare run)flare runverification below integrates the combined SM121/RoCE kernel, recipe, and scheduler optimization set (isolated single-component GPU microbenchmarks are reported directly above).GB10,SM121, 48 SMs, 121 GiB unified LPDDR5x, dual-rail ConnectX-7 200 GbE RoCEv2),deepseek-ai/DeepSeek-V4.1-Flash-1017TP4 exported package (draft_tokens = 7,speculative_token_capacity = 256,graph_budget = 80,prefill_chunk = 8192,row_shard_prefill = True,row_shard_attention = True,adaptive_verification_alpha = 0.75), served viaflare run(27,051,776logical KV tokens/rank, up from26,272,640baseline).17 * 23 = 391): pass4/4distinct images,4vision graph launches):4/4pass8K, 16K, 32K, 64K, 128K,0reused tokens):5/5pass (128Kin11.71 s)4 x 32Klong-context stress:4/4pass in12.19 s,0failed requests,0preemptionsllm-decode-benchv0.8.0 (exactnative token counting,30 s/cell sustained decode,0errors,0CJK):prompt_tokens / client TTFT):8K8,639 tok/s(0.95 s),32K10,994 tok/s(2.98 s, vs10,810 tok/sbaseline),128K11,349 tok/s(11.55 s, vs11,181 tok/sbaseline); cold64Kpass-2 prefill reached11,390.9 tok/swall (11,462.6 tok/sGPU).C = 1, 2, 4, 8):8K:67.7 / 106.5 / 159.1 / 224.6 tok/s(vs65.4 / 107.1 / 152.5 / 218.6 tok/smatchingdraft_tokens = 7,alpha = 0.75baseline)32K:71.2 / 107.6 / 163.1 / 227.6 tok/s(vs70.2 / 105.0 / 154.9 / 222.4 tok/sbaseline)128K:69.1 / 99.2 / 154.0 / 219.9 tok/s(12-cell geomean126.61 tok/svs124.96 tok/sbaseline;B16xW1pure 1-token/lane GPU step75.70 ms -> 70.54 ms,-6.8%)8K C=16 / C=32underalpha = 0.75(272.5 / 411.0 tok/s): atalpha = 0.75withmax_verification_token_budget = 256, unclamped calibration offers~2.8–2.9drafts/lane on low-acceptance prose (49.4%–51.8%accept rate vs59.7%–62.2%baseline), increasing packed verification rows;C=32fixed-prompt sweep (P=256) reached419.93 tok/s.5/5runs,0CJK):109.0 tok/smedian,110.7 tok/smean,118.0 tok/speak (vs116.5 tok/sbaseline).46,766completion tokens:27,108reasoning +19,658HTML/JS code,temperature = 1.0, adaptivedraft_tokens = 7):118.23 tok/s(179.53 tok/s1s peak,162.56 tok/s5s peak; vs114.68 tok/sfixed-W=8baseline and87.74 tok/sflat-ceiling adaptiveW=6baseline)105.49 tok/s(4.19mean tokens/step,5.40offered drafts/round)19,655tokens up to47Kcontext):141.85 tok/s(6.11mean tokens/step,6.59offered drafts/round,77.6%accept rate, per-depth survival[0.955, 0.904, 0.854, 0.791, 0.715, 0.614, 0.279]).🔍 Related Issues
🚀 Pull Request Checklist
✅ Pre-commit Checks
pre-commitby runningpip install pre-commit(or used your preferred method).pre-commit install.pre-commit run --all-filesand fixed any reported issues.🧪 Tests
Tests have been added or updated as needed.
All tests are passing (
unittest, etc.).This PR requires full-scope CI, not targeted tests (expensive; justify below).
Suggested CI test targets:
tests/experimental/b12x/gemm/test_decode_gemm_moe_contracts.py tests/experimental/b12x/gemm/test_blockscaled.py tests/experimental/b12x/gemm/test_blockscaled_a16.py tests/experimental/b12x/gemm/test_gemm_wo_projection.py tests/experimental/b12x/gemm/test_wo_projection.py tests/experimental/b12x/gemm/test_mxfp8_tc_gemv.py tests/experimental/b12x/gemm/test_nvfp4_tc_gemv.py🔬 Experimental Track
flashinfer/experimental/and/or an@flashinfer_experimental_api.flashinfer/experimental/b12x/gemm/).tests/experimental/and were validated on CPU and GB10 hardware.flashinfer/aot.py, and no experimental backend is reachable frombackend="auto"withoutFLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1.Reviewer Notes
CUDA_VISIBLE_DEVICES=""(92 passed, 724 skippedacross the 16 declared test files; CUDA runtime cases skipped on CPU build host).