Repository navigation
[AMD] Keep aiter's tuned GEMM for the DeepSeek-V4 compressors - #41931
Merged
Merged
Conversation
sgl-project#41019 moved the aiter branch of linear_bf16_fp32 from tgemm.mm(...).float() to torch.mm(out_dtype=float32) for every caller. The same helper serves the DeepSeek-V4 c4/c128 compressors (Compressor._compute_wkv_gate, about 90 GEMMs per V4-Pro forward), which moved from aiter's tuned FlyDSL kernels onto hipBLASLt. At decode row counts that is 1.3-2x slower on MI355X (K=7168, graph replay): N M=8 tgemm / torch.mm M=28 tgemm / torch.mm 2048 8.6 / 11.0 us 10.2 / 11.2 us 1024 7.2 / 14.1 us 8.3 / 10.7 us 512 6.5 / 10.1 us 7.4 / 7.7 us or 0.13-0.55 ms per DSpark verify step at TP8 conc 4. With SGLANG_USE_AITER and a bf16 weight, route the compressor projection back through tgemm. kv_score is bf16-rounded as before sgl-project#41019. linear_bf16_fp32 keeps its fp32 contract for its other callers, including the V4.1 compressors in dsv41_sparse.py.
RolaoDenthu
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
September 30, 2026 22:00
HaiShaw
approved these changes
Oct 4, 2026
3 of 5 tasks
3 of 5 tasks
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
#41019 moved the aiter branch of linear_bf16_fp32 from tgemm.mm(...).float() to torch.mm(out_dtype=float32) for every caller. The same helper serves the DeepSeek-V4 c4/c128 compressors (Compressor._compute_wkv_gate, about 90 GEMMs per V4-Pro forward), which moved from aiter's tuned FlyDSL kernels onto hipBLASLt. At decode row counts that is 1.3-2x slower on MI355X (K=7168, graph replay) or 0.13-0.55 ms per DSpark verify step at TP8 conc 4.
With SGLANG_USE_AITER and a bf16 weight, route the compressor projection back through tgemm. kv_score is bf16-rounded as before #41019. linear_bf16_fp32 keeps its fp32 contract for its other callers, including the V4.1 compressors in dsv41_sparse.py.
Modifications
python/sglang/srt/layers/attention/dsv4/compressor.pyin
Compressor._compute_wkv_gate, when_use_aiteris set andwkv_gate.weightis bf16, compute the projection withtgemm.mm(x, weight, otype=x.dtype).float(); every other case still goes throughlinear_bf16_fp32.Accuracy Tests
gsm8k 1319: 0.902
Speed Tests and Profiling
DeepSeek-V4-Pro, TP8, MI355X, DSpark, conc 4, 68K input / 200 output. TP0 decode trace, same 16-replay window.
Compressor projection GEMMs (M=16, K=7168):
torch.mm)hgemm)Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #37082239724
Latest PR Test (Extra): ❌ Run #37082239514
Latest PR Test (AMD ROCm 10): ❌ Run #37082239733