Skip to content

[NVIDIA] Support NVFP4 MoE for DeepSeek-V4 - #25820

Merged
Fridge003 merged 13 commits into
sgl-project:mainfrom
trevor-m:dsv4-fp4
Jun 22, 2026
Merged

Fridge003 merged 13 commits into
sgl-project:mainfrom
trevor-m:dsv4-fp4

Conversation

@trevor-m

@trevor-m trevor-m commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

This PR enables NVFP4 quantization for MoE in DeepSeek-V4. NVFP4 should provide better performance compared to MXFP4. Use --moe-runner-backend flashinfer_trtllm_routed.

Needs #25702 to help with perf

Modifications

  • Read new NVFP4 quant info from model config/hf_quant_config.json. The NVFP4 checkpoint uses FP8 quantization but with "moe_quant_algo": "NVFP4".
  • Handle apply_routed_scaling_factor_on_output for hash topk
  • Support swiglu_limit for flashinfer_trtllm_routed.

Accuracy Tests

sglang serve \
  --trust-remote-code \
  --model-path nvidia/DeepSeek-V4-Pro-NVFP4 \
  --tp 8 \
  --moe-runner-backend flashinfer_trtllm_routed \
  --speculative-algo EAGLE \
  --speculative-num-steps 3 \
  --speculative-eagle-topk 1 \
  --speculative-num-draft-tokens 4 \
  --chunked-prefill-size 8192 \
  --disable-flashinfer-autotune \
  --swa-full-tokens-ratio 0.1 \
  --mem-fraction-static 0.90 \
  --host 0.0.0.0 \
  --port 30000
python3 benchmark/gsm8k/bench_sglang.py --num-shots 8 --num-questions 1209 --parallel 1209 --platinum
Accuracy: 0.965
Invalid: 0.000
Latency: 53.335 s
Output throughput: 2149.225 token/s

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #27657320129
Latest PR Test (Extra): ✅ Run #27925999159

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added quant LLM Quantization deepseek labels May 19, 2026
@trevor-m trevor-m added blackwell SM100/SM120 nvidia labels May 19, 2026
@trevor-m
trevor-m requested a review from b8zhong as a code owner May 27, 2026 20:35
Comment thread python/sglang/srt/configs/model_config.py Outdated
Comment thread python/sglang/srt/layers/quantization/fp8.py Outdated
Comment thread python/sglang/srt/model_loader/weight_utils.py Outdated
Comment thread python/sglang/srt/configs/model_config.py Outdated
@Fridge003 Fridge003 mentioned this pull request May 28, 2026
24 of 36 tasks
@trevor-m

Copy link
Copy Markdown
Collaborator Author

GPQA Results

nemo-run_1/0 ------------------------------------------ gpqa -----------------------------------------                                                                                                                                                                                                                                                       
nemo-run_1/0 evaluation_mode   | num_entries | avg_tokens | gen_seconds | symbolic_correct | no_answer                                                                                                                                                                                                                                                       
nemo-run_1/0 pass@1[avg-of-16] | 198         | 23093      | 81683       | 86.43% ± 1.65%   | 1.89%                                                                                                                                                                                                                                                           
nemo-run_1/0 majority@16       | 198         | 23093      | 81683       | 90.91%           | 0.00%                                                                                                                                                                                                                                                           
nemo-run_1/0 pass@16           | 198         | 23093      | 81683       | 95.96%           | 0.00%

Server command

SGLANG_DEFAULT_THINKING=1 sglang serve   --trust-remote-code   --model-path nvidia/DeepSeek-V4-Pro-NVFP4   --tp 8   --moe-runner-backend flashinfer_trtllm_routed   --speculative-algo EAGLE   --speculative-num-steps 3   --speculative-eagle-topk 1   --speculative-num-draft-tokens 4   --chunked-prefill-size 8192   --disable-flashinfer-autotune   --swa-full-tokens-ratio 0.1   --mem-fraction-static 0.90   --host 0.0.0.0   --port 30000 --reasoning-parser deepseek-v4

Eval command using https://github.com/sgl-project/sglang/blob/deepseek_v4/scripts/bench_gpqa_aime25.py

PORT=30000 python3 bench_gpqa_aime25.py  setup-ns
PORT=30000 python3 bench_gpqa_aime25.py run-gpqa --num-repeats 16 --temperature 1.0 --max-tokens 400000 --max-concurrency 512

@trevor-m
trevor-m force-pushed the dsv4-fp4 branch 2 times, most recently from cf38ed4 to 2e4567e Compare May 28, 2026 23:34

@b8zhong b8zhong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/tag-and-rerun-ci

@b8zhong b8zhong self-assigned this May 28, 2026
@b8zhong

b8zhong commented May 29, 2026

Copy link
Copy Markdown
Collaborator

@trevor-m Can you please fix the conflicts

@trevor-m

Copy link
Copy Markdown
Collaborator Author

Hi @SkqLiao thank you for testing it out! You will also need this PR #25702 to help the perf. Even so, for DSV4 Flash we only expect to see 1-5% end-to-end decode throughput improvement with the largest gains on prefill with 5-44% lower TTFT.

@nvpohanh

Copy link
Copy Markdown
Collaborator

All NVIDIA pipelines passed. @Fridge003 could you merge this? thanks

@Fridge003
Fridge003 disabled auto-merge June 22, 2026 02:33
@Fridge003

Copy link
Copy Markdown
Collaborator

@trevor-m Can we add a nightly test for dsv4 nvfp4 checkpoint, thanks
Could be either 8B200 or 4GB300 nightly test

@Fridge003 Fridge003 added the release-highlight Candidate PR for release note highlight label Jun 22, 2026
@Fridge003
Fridge003 merged commit c0bb04b into sgl-project:main Jun 22, 2026
196 of 212 checks passed
@trevor-m

Copy link
Copy Markdown
Collaborator Author

@Fridge003 Thanks for help getting this PR merged! I opened #28966 to add the nightly tests

dougyster added a commit to dougyster/sglang that referenced this pull request Jul 21, 2026
Restore the GB200 DeepSeek-V4 cells (were removed). Their numbers are PR sgl-project#25820
Mean-era, while everything re-measured this PR is P50. Add per-cell
latencyPercentile support in _deployment.jsx (entry.latencyPercentile falls back
to config.latencyPercentile) and tag the two GB200 nvfp4 cells 'Mean' so they
render 'TTFT (Mean)' while all other cells stay 'TTFT (P50)'.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blackwell SM100/SM120 deepseek documentation Improvements or additions to documentation nvidia quant LLM Quantization release-highlight Candidate PR for release note highlight run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants