Repository navigation
Add SM90 FP8 MegaMoE support for DeepSeek-V4 - #29016
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the SM90 (Hopper) variant of the mega_moe_pre_dispatch kernel for DeepSeek v4, enabling all-FP8 Mega MoE support on SM90 GPUs. It includes the CUDA kernel implementation, JIT loading, integration into the mega_moe layer, and comprehensive unit tests. Feedback on the changes suggests optimizing _interleave_l1_weight_only by removing a redundant memory allocation and copy operation when stacking and reshaping tensors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
29360d0 to
2d5188b
Compare
|
Could we call the DeepGEMM MegaMoE API directly instead of porting all the MegaMoE kernel code piece? Something like this: |
|
In build_mega_moe_experts_weights adding SM90 deep gemm weights processing. |
|
@qiushixiaoyu Please test the full set of GPQA with 32 turns, thanks The model should be launched with |
|
Is sm90 fp8 megamoe also applicable on other models, like dsv3 or glm5? |
I think it's feasible, but we'll need to make some code adaptations. |
b3c6135 to
f1ba22e
Compare
sgl-eval run gpqa == gpqa ==
|
|
Results for 🚀 🚀 |
|
@Fridge003 |
|
@qiushixiaoyu Hi, I checkout to your branch, install sgl-deep-gemm==0.1.4, sglang-kernel==0.4.4, and flashinfer_python==0.6.8.post1, with cu129 version. Running the provided script throws an error during cuda graph capture: |
@laixinn , Could you share the full launch command and all related environment variables? Also please confirm whether these return True: |
I got Which sgl-deep-gemm version should I install? Or I should build the sgl-project/DeepGEMM dev branch? |
|
@laixinn Please use the dev branch of sgl-project/DeepGEMM. I found that the changes in sglang PR https://github.com/sgl-project/sglang/pull/25835/changes cause an accuracy drop when MegaMOE is enabled. |
c88a9d9 to
b6c3549
Compare
|
@qiushixiaoyu Hi,Have you verified the correctness with a max_token_per_rank=8K? I observed a significant drop in AIME results when running AIME25 with a concurrency of 40,max_token_per_rank=8K(sgl-version: 0.5.15,tp8 + ep8 + cp,run deepseek v4 flash)Or am I using it incorrectly somewhere? |
|
@qiushixiaoyu DeepGemm should be updated to include all the changes |
|
@Fridge003 OK, I'll rebase and re-run the accuracy tests. |
b6c3549 to
f75fd7d
Compare
|
/rerun-failed-ci |
|
Hi, after the latest rebase and DeepGEMM update, has the MegaMoE accuracy-drop issue related to SGLang PR #25835 been fixed or re-verified? Could you share the exact SGLang/DeepGEMM commits and evaluation configuration, especially fused top-k on/off, TP/EP/CP, max tokens per rank, concurrency, and dataset? Thanks! |
|
@hqliuuu Accuracy drop: it has been fixed and the fix is already merged into the DeepGEMM Commits
Config: 8×H20 (SM90) · TP8 / EP8 / DP-attention 8 · CP not enabled · Launch: export MODEL_PATH=/data00/models/DeepSeek-V4-Flash-FP8
export SGLANG_DSV4_FP4_EXPERTS=0
export SGLANG_JIT_DEEPGEMM_PRECOMPILE=0
export GLOO_SOCKET_IFNAME=eth0
export NCCL_IB_GID_INDEX=3
export NCCL_IB_HCA=mlx5_1,mlx5_2,mlx5_3,mlx5_4,mlx5_5,mlx5_6,mlx5_7,mlx5_8
export FLASHINFER_DISABLE_VERSION_CHECK=1
export SGLANG_OPT_USE_DEEPGEMM_MEGA_MOE=1
export SGLANG_OPT_FIX_MEGA_MOE_MEMORY=1
export SGLANG_OPT_USE_JIT_EP_ACTIVATION=1
export SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=1280
export SGLANG_DEFAULT_THINKING=1
python -m sglang.launch_server \
--trust-remote-code \
--model-path "${MODEL_PATH}" \
--tp-size 8 --ep-size 8 \
--enable-dp-attention --dp-size 8 --enable-dp-lm-head \
--chunked-prefill-size 8192 \
--moe-a2a-backend megamoe --moe-runner-backend deep_gemm \
--deepep-mode auto \
--cuda-graph-max-bs 32 --max-running-requests 32 \
--speculative-algorithm EAGLE --speculative-num-steps 3 \
--speculative-eagle-topk 1 --speculative-num-draft-tokens 4 \
--mem-fraction-static 0.75 \
--tool-call-parser deepseekv4 --reasoning-parser deepseek-v4 \
--host 0.0.0.0 --port 30000 |
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
Co-authored-by: yinding <yinding@bytedance.com>
Co-authored-by: yinding <yinding@bytedance.com>
Motivation
This PR adds SM90 DeepGEMM MegaMoE adaptation for DeepSeek-V4 FP8 serving. It enables the MegaMoE A2A path with the DeepGEMM MoE runner on SM90, including the pre-dispatch JIT kernel, FP8 expert weight preparation, and DeepSeek-V4 integration.
The goal is to improve long-context / large decode serving throughput for DeepSeek-V4-Flash/Pro-FP8 workloads while keeping the path guarded by environment variables.
Modifications
Environment variables used to enable the path:
SGLANG_OPT_USE_DEEPGEMM_MEGA_MOE=1enables the DeepGEMM MegaMoE path.SGLANG_OPT_FIX_MEGA_MOE_MEMORY=1enables the fixed MegaMoE memory path.SGLANG_OPT_USE_JIT_EP_ACTIVATION=1is required by the fixed MegaMoE memory path.SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=4096configures the max token buffer size per rank used by the MegaMoE path. In PD colocated serving, it should be set to the same value as--chunked-prefill-size; in decode-only serving, it should be larger than the maximum number of tokens per rank. The experiment below used4096, matching--chunked-prefill-size=4096.Serving command used in the experiment:
Accuracy Tests
sgl-eval run gpqa
--n-repeats 16 --max-tokens 200000
--temperature 1.0 --top-p 1.0 --thinking
--out-dir /sgl-workspace/logs
--base-url http://localhost:30000/v1
Unit test:
Result:
Speed Tests and Profiling
DeepGEMM dependency note:
The FP8 MegaMoE operator has already been merged into DeepGEMM in sgl-project/DeepGEMM#36. This benchmark additionally includes the small-batch performance optimization from sgl-project/DeepGEMM#48.
Benchmark script:
The serving benchmark was run with
sglang_auto_bench.py, an internal helper script that wrapspython -m sglang.bench_servingand automatically searches for the highest request rate / max concurrency for a given input-output length. It reports both:For the result below, the script was run with random prompts, input/output length
3500/1500, and SLO targetsTTFT <= 2000 msandTPOT <= 20 ms.MegaMoE ON vs OFF:
SLO total throughput: +22.24%
SLO output throughput: +22.24%
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ✅ Run #30411502411
Latest PR Test (Extra): ✅ Run #30411502209