Repository navigation
[AMD] Add opt-in AITER ASM FP4 GEMM for Quark dense linear - #39598
vorapolsiloai wants to merge 3 commits into
Conversation
8dc26de to
2d708d9
Compare
Open question for maintainers: default CK vs extra envThis PR currently keeps What this PR does today
Why we did not copy vLLM blindly Ask for maintainers
We can keep (1) in this PR and do (2)/(3) as a follow-up if that is preferred. |
Quark W4A4 MXFP4 dense linear layers on ROCm always call AITER's Triton gemm_afp4wfp4, so they cannot use the a4w4_blockscale_tuned_gemm CSV tables that AITER gemm_a4w4 and vLLM share. Add an opt-in path that does. - Add SGLANG_ROCM_USE_AITER_FP4_ASM_GEMM (Envs, default off) for gfx95 - Preshuffle FP4 weights and E8M0 weight scales once after loading - Quantize activations with AITER's shuffled per-1x32 FP4 quantizer - Dispatch through gemm_a4w4 so model-specific tuned CSV entries apply - Keep the Triton path for layers whose scale shape cannot be swizzled - Reject Quark tuple-input fusion projections while the flag is on
b60f090 to
b046ed7
Compare
BowenBao
left a comment
There was a problem hiding this comment.
Thanks @vorapolsiloai, looks good overall.
Could you share some end to end performance and accuracy data comparison for your model use case?
Quark tuple-input projections that hand over an already-quantized MXFP4 activation no longer raise when SGLANG_ROCM_USE_AITER_FP4_ASM_GEMM=1. - Skip per_1x32_f4_quant for (x_fp4, x_scales) and feed x_fp4 to gemm_a4w4 unchanged; bpreshuffle only applies to the weight - Pad and swizzle the row-major activation scales from the Triton fused-quant kernels into the layout per_1x32_f4_quant(shuffle=True) emits - Keep rejecting the 3- and 5-tuple fused-epilogue inputs, which have no gemm_a4w4 equivalent
AITER's untuned gemm_a4w4 heuristic returns wrong rows 1..M-1 for N <= 128 at 2 <= M <= 64 on MI355X (ROCm/aiter@e7d2453f2). Qwen3.8 GDN in_proj_ba (N=96) hits it at decode batch sizes, so identical greedy requests in one batch diverge. Keep such layers on the Triton GEMM until AITER is fixed.
|
Thanks @BowenBao! Here is the end-to-end performance and accuracy comparison for Qwen3.8-27B (Quark-AWQ-MXFP4) on AMD Instinct MI355X (TP2), demonstrating the uplift when enabling this PR's opt-in ASM FP4 GEMM path ( 1. Setup & Environment
2. End-to-End Performance Comparison
3. Accuracy Verification
|
Motivation
On ROCm, Quark W4A4 MXFP4 dense linear layers always run AITER's Triton
gemm_afp4wfp4. That kernel does not read the tuneda4w4_blockscale_tuned_gemm.csvtables, which AITER'sgemm_a4w4and vLLM both use. So SGLang cannot use the per-model CK/ASM tuning that vLLM gets (for example ROCm/aiter#5350), and we would have to keep a separate set of Triton tunings for SGLang.This PR adds an opt-in path that runs these layers through
gemm_a4w4, so SGLang uses the same tuned kernels.Modifications
SGLANG_ROCM_USE_AITER_FP4_ASM_GEMMtoEnvs(default off). It only takes effect on gfx95.gemm_a4w4expects.per_1x32_f4_quant(shuffled scales) and callgemm_a4w4withbpreshuffle=True. AITER then picks the model-specific CSV entry if there is one.Limitation: Quark's tuple-input fusion projections are not supported on this path. The weights are preshuffled at load time, so we cannot fall back to Triton per call. These projections raise an error that tells the user to turn the flag off.
Open question for maintainers
Should this stay behind its own env var, or should gfx95 with
SGLANG_USE_AITER=1use CK/ASM by default (as vLLM does) and keep Triton as the fallback? Details: #39598 (comment)Accuracy Tests
MI355X, synthetic GEMM
(M, N, K) = (16, 1024, 5120):f4gemm_bf16_per1x32Fp4_BpreShuffle_32x128.process_weights_after_loading+apply_weightsgave exactly the same output as a separately dequantized FP4 reference (rtol=0,atol=0).test/registered/unit/layers/quantization/test_quark_mxfp4_asm.py) cover which scale shapes are supported and check the scale permutation against AITER's tile order (all 3 tests pass cleanly).EnvsandQuarkW4A4MXFP4module imports pass cleanly.Speed Tests and Profiling
TODO: add a serving comparison on one image, flag off (Triton) vs flag on (CK/ASM).
Checklist
CI States
Latest PR Test (Base): ❌ Run #37922164076
Latest PR Test (Extra): ❌ Run #37922163642
Latest PR Test (AMD ROCm 10): ❌ Run #37922164006