mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #360] Add SM90 MegaMoE by cooperative #390
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepGEMM#390
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepGEMM/pull/360
Author: @mpdfdfl
Created: 6/13/2026
Status: 🔄 Open
Base:
main← Head:sm90-mega-moe-pingpong-coop📝 Commits (10+)
006709asm90 megamoe: add pingpong and cooperative FP8 kernels4dd2e94sm90 megamoe: token-count dispatch and Python bindings1f84636sm90 megamoe: correctness test and performance benchmark4cd92c4chore: ignore profiling artifacts (*.ncu-rep, *.nsys-rep, profile_logs/)4146d0efix mul23f16c98add sm90 megamoe benchd7c89bdfix accuracy183fec5fix accuracy6b5be1dadd tma to HBM double buffer5fdbddafix accuract📊 Changes
14 files changed (+5003 additions, -8 deletions)
View changed files
📝
.gitignore(+6 -1)📝
csrc/apis/mega.hpp(+141 -6)➕
csrc/jit_kernels/heuristics/sm90_mega_moe.hpp(+235 -0)➕
csrc/jit_kernels/impls/sm90_fp8_mega_moe.hpp(+229 -0)📝
deep_gemm/__init__.py(+2 -0)📝
deep_gemm/include/deep_gemm/comm/barrier.cuh(+6 -0)📝
deep_gemm/include/deep_gemm/common/math.cuh(+9 -1)➕
deep_gemm/include/deep_gemm/impls/sm90_fp8_mega_moe.cuh(+1364 -0)➕
deep_gemm/include/deep_gemm/scheduler/sm90_mega_moe.cuh(+241 -0)📝
deep_gemm/mega/__init__.py(+57 -0)➕
tests/bench_mega_moe_sm90.py(+1102 -0)➕
tests/test_l1_single_token.py(+221 -0)➕
tests/test_mega_moe_sm90.py(+711 -0)➕
tests/test_mega_moe_sm90_mimo.py(+679 -0)📄 Description
Add SM90 MegaMoE (cooperative)
Co-Authored-By: @OpenDarrenlu
First, thanks to #352 and #323 — this work builds on the ideas from those PRs.
We provide the SM90 fused MegaMoE through a single cooperative kernel
(
BLOCK_M=64,BLOCK_N=256). The two math warpgroups cooperatively N-split onetile — the first warpgroup owns the left 128 columns and the second owns the
right 128 columns (each an
m64n128WGMMA) — and share a single A-tile (weight)load.
Why cooperative-only, and why the 64×256 tiling
We discovered an accuracy issue during end-to-end testing. We suspect the cause
is that the L1 output of the MoE layer is normally quantized per-128, whereas
our earlier implementation quantized it per-64. To fix this, we settled on a
single cooperative kernel in which the first warpgroup handles the left 128
columns and the other handles the right 128 columns, so the post-SwiGLU L1 output
is quantized per-128 (matching the standard DeepEP runner's
scale_block_size=128).For the L2 GEMM, cooperative also beats a pingpong variant we tested: the
dequant FMAs inside the k-loop overlap the asynchronous WGMMAs, and the two
warpgroups share a single A-tile load.
The SM90 kernel / scheduler / heuristics are kept separate from the shared SM100
files, so SM100 behavior is unchanged.
Correctness test
tests/test_mega_moe_sm90.pychecks the fused kernel against a PyTorch reference(
calc_diff < 0.01) over layered scenarios (smoke → shapes → edge cases →random stress).
Benchmark
tests/bench_mega_moe_sm90.pytimes the fused kernel end-to-end against theDeepEP + DeepGEMM unfused baselines (V1 contiguous, V1 low-latency, V2
ElasticBuffer), same CUDA-event timing for all.
Here are our latest test results.
1. Single-operator benchmark (vs. deepep)
Shape — hidden=4096, moe_intermediate=2048, experts=256, topk=8 (MiMo-V2.5)
2. End-to-end prefill benchmark
Setup: input 16K, output 1, TTFT capped within 1s.
📈 Compared with deepep, input token throughput improves by 25% (86653 vs 69635 tok/s).
3. Decode benchmark
Since this is a single-node deployment, TPOT is derived from the logs.
TODO / future work
This is just a first version, and there is still a lot of room to optimize
inside the kernel. We would really love your help — let's optimize this kernel
together! Planned directions:
tuning the block-tile / expert-wave scheduling strategy should reduce HBM
traffic and help the large-M DRAM-bandwidth-bound cases.
MoE into focused kernels (dispatch+L1+SwiGLU / L2+combine / combine-reduce)
running concurrently on disjoint SM partitions via CUDA green contexts — to
overlap stages the fused megakernel serializes internally.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.