Repository navigation
[HIP] Support Gemma (1 + w) weights in fused AR+RMSNorm+MXFP4 quant - #6000
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
7a6ed94 to
23e3945
Compare
|
@junhaha666 : could you have a look at your convenient time? |
|
@aiter-bot review |
ROCm/aiter PR #6000 — [HIP] Support Gemma (1 + w) weights in fused AR+RMSNorm+MXFP4 quantThreads a default-off gemma_norm flag from the vLLM-facing dist API down to a GEMMA_NORM template parameter on the 1-stage and 2-stage fused all-reduce+RMSNorm+MXFP4-quant kernels, so Gemma-style (1 + w) norm weights can ride the fused epilogue instead of paying a separate quant launch after every AR+RMSNorm. Review (advisory):
|
The 1-stage and 2-stage fused all-reduce + RMSNorm + MXFP4 kernels had no Gemma mode, so CudaCommunicator.fused_allreduce_rmsnorm_quant rejected gemma_norm for MXFP4. Gemma-norm models (Qwen3.5/3.8, Gemma) therefore could not use the fused MXFP4 epilogue and paid a separate activation-quant launch before every MXFP4 linear fed by an AR+RMSNorm. Thread a GEMMA_NORM template parameter through ar_fusion_epilogue_mxfp4 and both kernels (ar_fusion_epilogue_rms_norm already supports it: the 1 is added after widening w to fp32), expose gemma_norm on fused_allreduce_rmsnorm_mxfp4_quant and the Python dist wrappers, and pass it to the unfused fallback. With every quant type now accepting gemma_norm, the guard in fused_allreduce_rmsnorm_quant goes away. The multi-GPU test runs every case with and without gemma_norm, so the CI smoke covers it at TP2/4/8. It also gains an (8, 8192) 1-stage shape and a mean relative L1 assertion on the dequantized output, which the elementwise tolerance is too loose to provide. Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
23e3945 to
b66e114
Compare
All four points are addressed in
|
|
@aiter-bot review |
ROCm/aiter PR #6000 — [HIP] Support Gemma (1 + w) weights in fused AR+RMSNorm+MXFP4 quantThreads a default-off Review (advisory):
|
|
ROCm/aiter#6000 added gemma_norm to fused_ar_rms_mxfp4_quant in v0.1.27 and vLLM pins v0.1.29, so register the patterns on the ASM FP4 GEMM check alone. Pick the fused or unfused path with one condition. Co-authored-by: Cursor <[email protected]> Signed-off-by: Mikko Tukiainen <[email protected]>
Motivation
The 1-stage and 2-stage fused all-reduce + RMSNorm + MXFP4 quant kernels have no Gemma mode, so Gemma-norm models (Qwen3.5/3.8, Gemma) cannot use the fused MXFP4 epilogue. They pay a separate activation-quant launch before every MXFP4 linear fed by an AR+RMSNorm. On Qwen3.8 TP8 that is 68
per_1x32_f4_quant_hiplaunches per decode step in front of the GDNin_proj_qkvz. With this change the fused kernel is one launch where the unfused path is two or three, and 1.2x to 1.6x faster on the shapes it covers (Test Result).The vLLM consumer is vllm-project/vllm#59483 (draft until this merges and is released). Follows up #6472, which enabled
gemma_normfor per-group FP8 and removed the per-token-FP8-only restriction for that type.Not a duplicate: searched open and merged PRs for
gemma_norm mxfp4,gemma allreduce rmsnorm quantandfused_allreduce_rmsnorm mxfp4. #6472 covers per-group FP8 only; #6369 is a FlyDSL QuickReduce kernel.Technical Details
GEMMA_NORMtemplate parameter goes throughar_fusion_epilogue_mxfp4and both MXFP4 kernels.ar_fusion_epilogue_rms_normalready supports it: the 1 is added after wideningwto fp32.gemma_normis exposed onfused_allreduce_rmsnorm_mxfp4_quantand the Python dist wrappers (CustomAllreduce.fused_ar_rms_mxfp4_quant,CudaCommunicator,parallel_state,communication_op), and passed to the unfused fallback.gemma_norm, so the guard inCudaCommunicator.fused_allreduce_rmsnorm_quantis removed and thecommunication_op.pydocstring is corrected.op_tests/multigpu_tests/test_fused_ar_rms_mxfp4_quant.py: every case, including the no-argument CI smoke at TP 2/4/8, runs with and withoutgemma_norm(the--gemma-normflag does not exist). It adds the(8, 8192)1-stage shape and a mean relative L1 assertion (< 0.05) on the dequantized output.1 + wscale. The elementwisecheckAllcloseonly warns on that, so the L1 assertion is what fails the test. Withgemma_normforced toFalsebefore the kernel call, thegemma_norm=Truecases give a relative L1 of 0.8636 at (8, 8192) against at most 0.0062 with the fix. The fallback shape (128, 7168) is unaffected, as it should be.Where it does not help: shapes outside the 1-stage and 2-stage gates (for example (128, 7168) at TP8) run the unfused fallback, which is unchanged.
Test Plan
8× MI355X (gfx950). AITER
b66e114ff(one commit on main3a80ec0cb), JIT-built from the source tree invllm/vllm-openai-rocm:nightly-77154ca6116ae34cbfe314beef1016bde9b63989.Kernel time (harness not part of this PR): TP8, bf16, each arm captured in a CUDA graph, 5 rounds of 200 replays with the arm order alternated, device kernel durations summed from the torch profiler, median over ranks.
tensor_model_parallel_fused_allreduce_rmsnorm_quant(quant_type="mxfp4", gemma_norm=True).tensor_model_parallel_fused_allreduce_rmsnorm(gemma_norm=True)followed bydynamic_mxfp4_quant.Test Result
Both commands pass: 18 rows for the CI invocation (TP 2/4/8, three dispatch paths,
gemma_normon and off) and 80 rows for the TP8 command (28direct_1stage, 52direct_2stage, half withgemma_norm). Maximum over rows:gemma_norm=Falsegemma_norm=TrueKernel time per call, fused against unfused, Gemma weights, TP8, µs, lower is better:
The spread across ranks is under 1.1 µs for the fused arm (worst rank 13.8 µs at 16x8192). The unfused arm at 16x8192 to 32x8192 takes three launches because the 2-stage AR+RMSNorm is a reduce-scatter plus a norm kernel.
End to end on Qwen3.8 TP8 with the vLLM consumer (earlier run, before this rebase; the kernel code is unchanged by it), the fused kernel replaces 68 AR+RMSNorm + quant pairs per decode step, and the median decode step drops from 11.03 ms to 10.81 ms (−2.0%). GSM8K is 0.9680, against 0.9658 for the control.
Submission Checklist
Co-authored-by: Cursor [email protected]