Repository navigation
[perf] Optimize w4a8 MoE for glm5.2 on H200 - #38220
Merged
Merged
Conversation
cognaiger9
force-pushed
the
perf/perf-w4a8-moe-glm52
branch
2 times, most recently
from
September 6, 2026 16:57
a3eb052 to
d2edf1a
Compare
cognaiger9
marked this pull request as ready for review
September 6, 2026 16:57
cognaiger9
requested review from
BBuf,
FlamingoPg,
HaiShaw,
ispobock,
merrymercy and
yizhang2077
as code owners
September 6, 2026 16:57
cognaiger9
force-pushed
the
perf/perf-w4a8-moe-glm52
branch
4 times, most recently
from
September 8, 2026 08:21
b415456 to
2f06124
Compare
Contributor
Author
|
@BBuf can you take a look at this? |
cognaiger9
force-pushed
the
perf/perf-w4a8-moe-glm52
branch
3 times, most recently
from
September 11, 2026 07:17
1e51565 to
0964717
Compare
BBuf
approved these changes
Sep 16, 2026
| _check_int4_fp8_grouped_gemm(batch_size, k, n, num_experts) | ||
|
|
||
|
|
||
| # M is the original token count; the kernel receives M * topk routed rows. |
Collaborator
There was a problem hiding this comment.
Could we remove these two files? They seem to be temporary test and benchmarking scripts and are probably unnecessary to keep in the repository.
Contributor
Author
There was a problem hiding this comment.
i've removed these 2
BBuf
reviewed
Sep 16, 2026
| @@ -197,6 +263,29 @@ void cutlass_w4a8_moe_mm_sm90( | |||
| torch::Tensor const& s_strides, | |||
| int64_t chunk_size, | |||
| int64_t topk) { | |||
| const c10::cuda::CUDAGuard device_guard(a_tensors.device()); | |||
| // Match the model token, allowing descriptions such as "NVIDIA H200 SXM". | |||
Collaborator
There was a problem hiding this comment.
Suggested change
| // Match the model token, allowing descriptions such as "NVIDIA H200 SXM". | |
| // Detect H200 devices, including names such as "NVIDIA H200 SXM". |
cognaiger9
force-pushed
the
perf/perf-w4a8-moe-glm52
branch
2 times, most recently
from
September 16, 2026 09:01
0e99cf5 to
c502d85
Compare
cognaiger9
force-pushed
the
perf/perf-w4a8-moe-glm52
branch
from
September 18, 2026 04:21
c502d85 to
126994e
Compare
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.
Motivation
dispatch_w4a8_moe_mm_sm90 (python/sglang/kernels/aot/csrc/moe/cutlass_moe/w4a8/w4a8_grouped_mm_c3x.cu)picks a CUTLASS config for the W4A8 grouped GEMM by matching on (n, k). Every named branch was tuned for DeepSeek's 7168-hidden shapes on H20. GLM-5.2 (hidden=6144, moe_intermediate_size=2048, E=256, topk=8) matches none of them, so both of its production sharding layouts - TP-8 and EP-8 without DeepEP - fall through to the generic fallback tail and run untuned.Modifications
Add four named branches to
dispatch_w4a8_moe_mm_sm90for GLM-5.2's actual GEMM shapes, one per GEMM per layout:This tuning adds four unique CUTLASS configurations, increasing the W4A8 configuration count from 12 to 16. These add compilation work and binary size.
Accuracy Tests
Correctness is covered by
python/sglang/kernels/aot/tests/test_cutlass_w4a8_moe_mm.py's extended parametrizationSpeed Tests and Profiling
test/manual/layers/moe/bench_w4a8_sm90_dispatch.pytimes the completecutlass_w4a8_moecall (preprocess/reorder/quant → GEMM1 → silu+requant →GEMM2 → post-reorder) - the full MoE-layer boundary across both of its production sharding layouts:
mode="tp").mode="ep"): the script builds only the 32 local-expert weights and remaps global routing ids to local ids (or a drop sentinel for the other 224), reproducing what a real EP-8 rank sees.Shapes with
m<=2048run captured under a CUDA graph, larger shapes run eager. Each shape reports median and min latency across 30 timed calls (5 warmup calls beforehand).The results below is produced from running the script on 1x H200.
TP-8 (win at every M)
EP-8 (no DeepEP) (win at M <= 256)
Checklist
CI States
Latest PR Test (Base): ⏳ Run #35441337493
Latest PR Test (Extra): ❌ Run #35441337543
Latest PR Test (AMD ROCm 10): ⏳ Run #35441337421