Repository navigation
[AMD][DSV4] route bf16->fp32 GEMM to aiter's tuned FlyDSL kernel - #41904
Closed
AMD-yanfeiwang wants to merge 1 commit into
Closed
AMD-yanfeiwang wants to merge 1 commit into
AMD-yanfeiwang wants to merge 1 commit into
Conversation
On ROCm, linear_bf16_fp32 looks up aiter's tuned bf16 x bf16 -> fp32 config for (M, N, K) and calls tgemm.mm(otype=fp32) when it is a FlyDSL row; otherwise it keeps torch.mm(out_dtype=fp32). The FlyDSL rows for the DSv4 compressor wkv_gate (N=1024/2560, K=7168, M<=32) and the fp32-accumulator fix come from ROCm/aiter#6005; without them the route stays on torch.mm. DSv4-Pro TP8 8k/1k, paired: plain c8 -2.7%, c32 -1.1%, DSpark c2/c4 -1.1%/-1.2%; gsm8k unchanged.
Collaborator
|
Coverd by #41931 |
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.
Motivation
On ROCm,
linear_bf16_fp32(bf16 x bf16 -> fp32) runstorch.mm(out_dtype=fp32), i.e. hipBLASLt. For the DeepSeek-V4 compressorwkv_gate(K=7168, N=1024 HCA / N=2560 fused CSA) that takes 11-16 us per call at decode sizes (M<=32), and a DSv4-Pro decode step makes 61 of these calls. ROCm/aiter#6005 makes the FlyDSL HGEMM fp32-accurate for fp32 output and adds tuned FlyDSL rows for these shapes (6-14 us).Modifications
kernels/ops/gemm/bf16_fp32.py: on ROCm,_linear_bf16_fp32_cublaslooks up aiter's tuned bf16 -> fp32 config for (M, N, K). If it is a FlyDSL row, it callsaiter.tuned_gemm.tgemm.mm(x, w, otype=fp32). Otherwise it usestorch.mm(out_dtype=fp32)as before.torch.mm. The same holds when aiter is not installed.Accuracy Tests
wkv_gateshapes (N=1024/2560, K=7168, M=1..112) vs fp64, 1x MI355X, imagelmsysorg/sglang-rocm:v0.5.20-rocm724-mi35x-20260927:torch.mm;torch.mm.test/registered/kernels/ops/gemm/test_router_gemv_hip.py: 2/2 pass, with and without [FlyDSL] HGEMM: keep the C shuffle in fp32 for fp32 output; DSv4 wkv_gate fp32 rows ROCm/aiter#6005.Speed Tests and Profiling
Kernel,
wkv_gatethroughlinear_bf16_fp32, 1x MI355X, CUDA graph of 64 calls with 8 rotating weights, us per call:N=1024 M=1/8 come from the aiter tuning sweep (same timing method); the other cells time the sglang route.
E2E, DeepSeek-V4-Pro fp8, TP8 MI355X, image
lmsysorg/sglang-rocm:v0.5.20-rocm724-mi35x-20260927, 8k in / 1k out, step time (ms). Before = image + our DSv4 decode stack: #41383 (with ROCm/aiter#5882), #38919 + #38920 (SGLANG_OPT_DSV4_C4_COMPRESSOR_GEMM_FUSION=1), the DSpark verify ring write and the MoE small-batch sort. After = before + ROCm/aiter#6005 + this PR. Paired, 2 boots x 3 reps:All 24 pairs are faster. DSpark c16/c64 (M>32) are unchanged by construction.
Checklist
CI States
Latest PR Test (Base): ❌ Run #36731607608
Latest PR Test (Extra): ❌ Run #36731607096
Latest PR Test (AMD ROCm 10): ❌ Run #36731607442