Skip to content

[AMD] Keep aiter's tuned GEMM for the DeepSeek-V4 compressors - #41931

Merged
HaiShaw merged 3 commits into
sgl-project:mainfrom
RolaoDenthu:dsv4/restore-perf-dsv41
Oct 4, 2026
Merged

HaiShaw merged 3 commits into
sgl-project:mainfrom
RolaoDenthu:dsv4/restore-perf-dsv41

Conversation

@RolaoDenthu

@RolaoDenthu RolaoDenthu commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

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.py
    in Compressor._compute_wkv_gate, when _use_aiter is set and wkv_gate.weight is bf16, compute the projection with tgemm.mm(x, weight, otype=x.dtype).float(); every other case still goes through linear_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):

N Before (hipBLASLt torch.mm) After (aiter FlyDSL hgemm)
2048 16.8 us 8.7 us
1024 15.4 us 6.7 us
512 14.8 us 6.1 us

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ❌ Run #37082239724
Latest PR Test (Extra): ❌ Run #37082239514
Latest PR Test (AMD ROCm 10): ❌ Run #37082239733

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.
@kkHuang-amd kkHuang-amd added amd run-ci CI: run the baseline test suite on this PR labels Oct 3, 2026
@HaiShaw
HaiShaw merged commit 663984b into sgl-project:main Oct 4, 2026
142 of 164 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

amd run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants