Skip to content

[ROCm][Perf] Use AITER tuned GEMM for the MoE router gate (backport #50535) - #21

Merged
hgquannn merged 1 commit into
moreh/v0.28.0from
moreh/v0.28.0-pr-50535
Sep 21, 2026
Merged

hgquannn merged 1 commit into
moreh/v0.28.0from
moreh/v0.28.0-pr-50535

Conversation

@hgquannn

Copy link
Copy Markdown

Context

Backport of upstream vllm-project#50535 (open, base main, upstream commit 5fbeda2065) to moreh/v0.28.0, for the GLM-5.2 DSA test images built from this fork.

The MoE router gate's bf16×bf16→fp32 GEMM tier was reachable only through cuBLAS on Hopper/Blackwell; on ROCm the gate fell through to F.linear. This extends the tier with the AITER tuned GEMM (gfx950). It also keeps the gate weight in bf16 when the AITER tier is available, since force_fp32_compute would otherwise promote it to fp32 and AITER only ships bf16-output tuned configs for the gate shapes; the small num_tokens x num_experts output is cast instead. Upstream reports TPOT -3.05% / throughput +3.10% on MI355X TP4 for GLM-5.2-MXFP4.

Changes

  • vllm/model_executor/layers/fused_moe/router/gate_linear.py: can_use_aiter_tuned_gemm, allow_aiter_router_gemm, bf16 weight when the AITER tier applies, the AITER branch in the bf16→fp32 tier, and the rocm_aiter_router_gemm custom op (opaque to torch.compile).
  • tests/kernels/test_rocm_aiter_router_gemm.py: upstream test, unchanged.

Backport difference: v0.28.0 still has the six-tier docstring (DSV3 kernel tier included), so the AITER GEMM is documented under tier 5 here instead of tier 4. The code is identical to upstream.

Test plan

Assisted by Claude Code; conflict resolution reviewed by hand.

Tier 5 of the gate dispatch runs a bf16xbf16->fp32 GEMM, but it is
reachable only through cuBLAS on Hopper and Blackwell. On ROCm the gate
fell through to the generic F.linear fallback.

Extend tier 5 with the AITER tuned GEMM. cuBLAS requires is_cuda() and
AITER requires is_rocm(), so at most one is ever eligible and the two
share the existing bf16 guard rather than adding a tier.

Reaching it also requires leaving the weight in bf16: force_fp32_compute
promoted the gate weight to fp32 whenever no specialized kernel was
available, which on ROCm meant always. AITER only ships bf16-output tuned
configs for the gate shapes, so the promotion would have kept the tier
dead. The GEMM now takes the tuned bf16 kernel and casts the small
num_tokens x num_experts output instead of upcasting the activation.

Signed-off-by: Sriram Kumar <sriramkumar.kishorekumar@amd.com>
Backport of upstream vllm-project/vllm PR vllm-project#50535 to moreh/v0.28.0. v0.28.0 keeps
its six-tier dispatch docstring (it still lists the DSV3 kernel tier), so the
AITER GEMM is documented as part of tier 5 there; the code change is identical.

(cherry picked from commit 5fbeda20650903e9c21ec382b0affb804d2a2e76)
@hgquannn
hgquannn merged commit 2471cc1 into moreh/v0.28.0 Sep 21, 2026
hgquannn added a commit that referenced this pull request Sep 21, 2026
…se branch

Brings the changes tested on the tmp/v0.28.0 image series into moreh/v0.28.0.
Content is exactly that of the fork PRs #16 to #22 (all against this branch
or its tmp copy):

  #16  [ROCm][Perf] Fuse DSA indexer QK preprocessing with AITER (upstream vllm-project#53094)
  #17  [ROCm][Perf] Shard DSA prefill indexer rows across TP ranks (upstream vllm-project#56944)
  #18  [ROCm] Skip redundant sparse index remap on non-indexer layers
       (backport of upstream vllm-project/vllm vllm-project#51309)
  #19  [ROCm][MLA][Perf] Fuse decode QK-RoPE + Q-concat + KV-concat + KV-cache
       write for sparse MLA (backport of upstream vllm-project#47757)
  #20  [ROCm][Perf] Dispatch DSA prefill indexer logits to aiter's HIP kernel on gfx950
  #21  [ROCm][Perf] Use AITER tuned GEMM for the MoE router gate
       (backport of upstream vllm-project#50535)
  #22  [ROCm][Bugfix] Add `positions` to unified_mla_attention_with_output_fake

Verified as image vllm-forks:0.28.0-pr16-21-a4-9-260917 (this branch minus #22)
built with aiter moreh/v0.1.19 + PR #4 + PR #9 on MI355X.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hgquannn
hgquannn deleted the moreh/v0.28.0-pr-50535 branch September 21, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants