Repository navigation
perf(cuda-oxide): 7-stage SMEM pipeline and wave-tail tile balancing in gemm_sol_final - #1663
Merged
Merged
Conversation
…in gemm_sol_final Re-author the Blackwell (`sm_100a`) `gemm_sol_final` kernels to eliminate shared-memory epilogue staging (`SMEM_OUT`), expand the TMA/UMMA ring from 4 to 7 stages (`224 KiB`), stream 128-bit `U32x4` epilogue stores directly from registers via warp-butterfly shuffles, overlap CLC work-stealing with the final 4 K-stages, and balance the final wave across all 74 B200 CTA pairs using `M256xN192` (4K) and `M256xN224` (8K/16K) tail tiles. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Signed-off-by: nihalpasham <nihalp@nvidia.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.
What This PR Does
This PR re-authors the Blackwell (
sm_100a) kernels ingemm_sol_final(zero compiler changes) to beat livecuBLASLtacross all three target sizes (4096³,8192³, and16384³) on NVIDIA B200:1. 7-Stage Contiguous SMEM Pipeline + Register-Direct 128-Bit Epilogue (
U32x4)Previously,
gemm_sol_finalreserved64 KiBof shared memory (SMEM_OUT) to stage epilogue outputs throughstmatrix.m8n8.x2+ld.shared, which capped the TMA/UMMA input ring at 4 stages (128 KiB).SMEM_OUTcompletely (64 KiB -> 0 B) by transposing adjacent thread pairs in registers via two warp-butterfly shuffles (xor 1andxor 2) and issuing 128-bitst.global.v4.b32(U32x4) stores directly from registers.224 KiB) while dropping register pressure from64/96registers down to60registers (0spills).ACCUM_EMPTYfrom a single elected thread per warp (lane_id == 0, arrival count8instead of256) immediately after the finaltcgen05.wait::ld, releasing TMEM before the final global stores complete.2. Wave-Tail Tile Balancing Across 74 B200 CTA Pairs (
M256×N192&M256×N224)On B200 (
148SMs =74cta_group::2cluster pairs), uniform256×256tiles leave part of the GPU idle in the final wave:3. Overlapped CLC Work-Stealing & Hoisted SMEM Descriptors
k_idx + 4 == k_iters): Issuesclc_try_cancel_multicast4 K-stages before the end of each tile into a 4-slotTILE_INFO/TILE_READYring buffer, hiding the GigaThread work-stealing latency behind the last 4 UMMA stages.a_desc0andb_desc0once before the tile loop and advances per stage viaa_desc0 + (stage << 10) + j * 2, removing 36 64-bit shift/mask/or instructions per K-stage inMMA_WARP.CU_TENSOR_MAP_L2_PROMOTION_L2_128Bon the 2D swizzled TMA descriptors.Verification
sm_100a) Full Correctness & Live Benchmark (cargo oxide run gemm_sol_final):gemm_sol_clc_multicast_4_stage_pipeline(M256xN256) 4096³ full 16,777,216-element exact-BF16 check: PASS (0.0000max rel err)gemm_sol_clc_multicast_4_stage_pipeline_large(M512xN256) 4096³ full 16,777,216-element exact-BF16 check: PASS (0.0000max rel err)main)cuBLASLt top-8cuBLASLt Exhaustive*cuBLASLt top-81475.5 TFLOPS(93.15 us)1857.5 TFLOPS(73.99 us)1839.6 TFLOPS(74.81 us)1927.0 TFLOPS100.97%(+17.9 TFLOPS)1772.1 TFLOPS(620.47 us)2084.7 TFLOPS(527.42 us)2077.2 TFLOPS(529.37 us)2084.0 TFLOPS100.36%(+7.5 TFLOPS)1992.5 TFLOPS(4414.58 us)2121.1 TFLOPS(4146.98 us)2063.9 TFLOPS(4263.79 us)2103.0 TFLOPS102.77%(+57.2 TFLOPS)Test plan
cargo oxide run gemm_sol_finalon B200 (sm_100a) (full 16,777,216-element exact-BF16 validation + 4K/8K/16K benchmark vs. livecuBLASLt)cargo test --manifest-path crates/rustc-codegen-cuda/examples/gemm_sol_final/Cargo.tomlcargo clippy --manifest-path crates/rustc-codegen-cuda/examples/gemm_sol_final/Cargo.toml --all-targets -- -D warningscargo oxide fmt --check