[SM90] Support MXFP4A8 Group Gemm for the SM90 mixed-input. - #3475
Open
yuyu5333 wants to merge 1 commit into
Open
[SM90] Support MXFP4A8 Group Gemm for the SM90 mixed-input.#3475yuyu5333 wants to merge 1 commit into
yuyu5333 wants to merge 1 commit into
Conversation
Author
|
@Junkai-Wu @IonThruster @Algy @hwu36 Sorry to bother you. Could you please review this when you have time? |
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.
Since the SM90 devices gained support for the int4 * fp8 computation pipeline, it has been widely adopted in inference frameworks such as SGLang and vLLM and delivered remarkable performance.
However, with the evolution of large‑language models (LLMs), an increasing number of models employ higher‑precision parameters like MXFP4. Unfortunately, a large number of SM90 devices lack native support for this data type. Similar to the earlier int4 scenario, runtime dequantization is required for adaptation. Most existing schemes dequantize weights to BF16 for inference, which covers the vast majority of use cases. Nevertheless, this is clearly a fallback solution for SM90‑class devices that natively support FP8 GEMM operations.
Accordingly, I have implemented the MXFP4‑to‑FP8 GEMM pipeline. Building upon existing work on WINT4A8, I realized dynamic scale retrieval and the corresponding GEMM computation logic, and removed the traditional fixed‑block‑size‑128 limitation of INT4A8. The implementation has been validated on SGLang. Results show that WMXFP4A8 outperforms existing pipelines in most scenarios.
Summary
This PR adds MXFP4A8 activation block scaling support to the SM90 mixed-input ptr-array mainloop while preserving the existing int4a8 execution path.
The implementation gates the new activation-scale TMA, shared memory, and chunked accumulation logic behind the MXFP4A8-specific
EnableActBlockScalecondition. Non-MXFP4A8 paths, including int4a8, keep the original mainloop behavior.Changes
mma()mainloop for non-act-block-scale paths.Validation
Tested on machine H20 / SM90, CUDA
12.4.131.Unit tests
./test/unit/core/cutlass_test_unit_core \ --gtest_filter="*Mxfp4*:*MXFP4*:*mxfp4*"Result:
./test/unit/gemm/device/cutlass_test_unit_gemm_device_tensorop_gmma_rs_warpspecialized_sm90 \ --gtest_filter="SM90_Device_Gemm_MixedInput_RS.Int4a8AndMxfp4a8StaticProperties"Result:
int4a8 benchmark
Benchmark target:
Small shape:
0.317806 ms0.317676 msDelta:
-0.041%Large shape:
70.65475 ms70.65260 msDelta:
-0.003%Both benchmark runs passed correctness checks. int4a8 performance is unchanged within measurement noise.
int4a8 MNK coverage
The existing CUTLASS int4/fp8 grouped GEMM example was also run on a small shape, a large-group shape, and a large prefill-like shape:
m=256, n=128, k=5120.016672 ms12075.7m=128, n=128, k=5120.043360 ms38692.8m=2048, n=5120, k=819269.4398 ms39585.0This supplements the static int4a8 path-separation test with runtime MNK coverage from the existing CUTLASS example.
MXFP4A8 correctness
MXFP4A8 correctness was validated through a temporary SGLang
cutlass_mxfp4a8_moe_mmsingle-GEMM test on the same H20 machine. The test compares the kernel output against a BF16 dequantized golden reference and exercises:m=4/8/16/128,k=256/512/1024,n=512/1024/2048;[4,4,4,4],[3,5,4,8],[16,8,32,8];Observed relative mean error was
0.0000for all tested cases.MXFP4A8 microbenchmark
The following single-GEMM MXFP4A8 benchmark uses
sgl_kernel.cutlass_mxfp4a8_moe_mmwith full activation block scaling enabled. For this single-GEMM synthetic benchmark,topk=1is the clean kernel-level setting; end-to-end MoE top-k behavior is covered separately by full MoE benchmarks.m=256, n=128, k=5120.016179 ms0.016320 ms2074.01m=128, n=128, k=5120.015639 ms0.015648 ms1072.78m=1024, n=2048, k=40960.164708 ms0.164752 ms104304.70m=2048, n=5120, k=81921.023284 ms1.024608 ms167889.58m=4096, n=5120, k=81921.975428 ms1.978080 ms173935.68For reference, using
topk=6/8in the same single-expert synthetic setup adds non-representative scheduling overhead and should not be used as the single-GEMM microbenchmark number.