Skip to content

[Deepseek V4] Keep fp32 routing weights in the mxfp4 trtllm MoE - #33608

Merged
b8zhong merged 3 commits into
mainfrom
mxfp4-unpacked-routing
Sep 7, 2026
Merged

b8zhong merged 3 commits into
mainfrom
mxfp4-unpacked-routing

Conversation

@b8zhong

@b8zhong b8zhong commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

The packed topk_ids format is (expert_id << 16) | bf16(weight), so it truncates the fp32 routing weights that moe_fused_gate produces. Pass the ids and weights unpacked instead, the kernel then keeps them in fp32, and the PackTopkIds launch goes away.

The reference DeepSeek-V4 implementation keeps the routing weights in fp32 (inference/model.py, Gate.forward).

Requires flashinfer 0.6.18 (flashinfer-ai/flashinfer#3763)

For BS = 1 under MTP, 771.97 -> 780.27 TPS

As the topK IDs can be consumed without packing the expert IDs and topK expert weights, this kernel disappears. The MoE finalize use finalizeKernel<KernelParams<bfloat16_t, bfloat16_t, 2, true>> -> finalizeKernel<KernelParams<bfloat16_t, float, 2, true>>

Before
Screenshot 2026-08-04 at 3 47 35 PM

After
Screenshot 2026-08-04 at 3 47 52 PM


CI States

Latest PR Test (Base): ✅ Run #34046732801
Latest PR Test (Extra): ❌ Run #34046732525
Latest PR Test (AMD ROCm 7.2): ❌ Run #34046732635

python test/registered/models_e2e/test_deepseek_v4_flash_fp4_b200.py
...
Ran 34 tests in 1004.055s

OK (skipped=1)

@b8zhong
b8zhong force-pushed the mxfp4-unpacked-routing branch from 7544842 to 187cacd Compare August 4, 2026 22:30
@b8zhong
b8zhong force-pushed the mxfp4-unpacked-routing branch from 187cacd to 9610835 Compare August 4, 2026 22:30
@b8zhong b8zhong changed the title Keep fp32 routing weights in the mxfp4 trtllm MoE [Deepseek V4] Keep fp32 routing weights in the mxfp4 trtllm MoE Aug 4, 2026
@b8zhong
b8zhong marked this pull request as ready for review September 4, 2026 08:20
@b8zhong b8zhong added the run-ci label Sep 4, 2026
@b8zhong
b8zhong merged commit 30705c0 into main Sep 7, 2026
237 of 258 checks passed
@b8zhong
b8zhong deleted the mxfp4-unpacked-routing branch September 7, 2026 00:12
hnyls2002 added a commit that referenced this pull request Sep 13, 2026
The unpacked routing input introduced by #33608 supplies genuine FP32 weights, but the branch-specific deferred finalize adapter reinterprets FP32 buffers as BF16. CUDA graph decoding then produces repeated BOS tokens.

Restore the packed routed-MoE input so deferred finalize receives BF16 weights with the expected layout.

Validated on 4 GB300 GPUs with TP4, EP4, CUDA graph enabled, and no DSpark. GPQA Diamond: 178/198 correct, 2 truncated, 0 request errors. Chat and thinking probes both terminate normally.
mqhc2020 pushed a commit to mqhc2020/sglang that referenced this pull request Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants