Skip to content

[Feature] Support NVFP4 MoE on SM100 - #6003

Merged
zoooo0820 merged 47 commits into
PaddlePaddle:developfrom
Echo-Nie:fp4_moe
Jan 29, 2026
Merged

zoooo0820 merged 47 commits into
PaddlePaddle:developfrom
Echo-Nie:fp4_moe

Conversation

@Echo-Nie

@Echo-Nie Echo-Nie commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

Motivation

This pr supports modelopt format NVFP4 inference (currently, only Qwen/Ernie) by introducing Flashinfer as a backend. It requires GPU with sm>=100 and Flashinfer installtion.

Modifications

With paddle compatible api, this pr introdudaces Flashinfer as a backend. There may be coexistence issues with some third-party including pytorch code (e.g. xgrammar, triton). , Currenly we cannot use them at same time and we are working on resolving this.

Usage or Command

New Environment Variables

  • FD_FLASHINFER_MOE_BACKEND : FP4 MoE backend, could be flashinfer-cutlass, flashinfer-trtllm or None (default is None, will use flashinfer-cutass). Currently we only support flashinfer-cutlass.

  • FD_NVFP4_GEMM_BACKEND: FP4 dense GEMM backend, could be flashinfer-cutlass, flashinfer-trtllm, flashinfer-cudnn or None (default is None, will use flashinfer-cutlass). Currently we only support flashinfer-cutlass.

  • PADDLE_COMPATIBLE_API: This is an environment variable for Flashinfer with Paddle, set it to true to use paddle compatible api, default is false.

Start the Server

python -m fastdeploy.entrypoints.openai.api_server \
    --model nv-community/Qwen3-30B-A3B-FP4 \
    --port 8180 \
    --metrics-port 8181 \
    --engine-worker-queue-port 8182 \
    --cache-queue-port 8183 \
    --tensor-parallel-size 1 \
    --max-model-len  32768 \
    --max-num-seqs 128

Performance Benchmark Command

Reference: https://github.com/PaddlePaddle/FastDeploy/tree/develop/benchmarks

python benchmark_serving.py \
  --backend openai-chat \
  --model nv-community/Qwen3-30B-A3B-FP4 \
  --endpoint /v1/chat/completions \
  --host 0.0.0.0 \
  --port 8180 \
  --dataset-name EBChat \
  --dataset-path ./data/filtered_sharedgpt_2000_input_1136_output_200_fd.json \
  --hyperparameter-path ./yaml/request_yaml/qwen25-vl-32kyaml \
  --percentile-metrics ttft,tpot,itl,e2el,s_ttft,s_itl,s_e2el,s_decode,input_len,s_input_len,output_len \
  --metric-percentiles 80,95,99,99.9,99.95,99.99 \
  --num-prompts 1000 \
  --max-concurrency 64 \
  --save-result

Accuracy Tests

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot

paddle-bot Bot commented Jan 12, 2026

Copy link
Copy Markdown

Thanks for your contribution!

@codecov-commenter

codecov-commenter commented Jan 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.01742% with 43 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@27f8799). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/model_executor/layers/moe/moe.py 18.51% 21 Missing and 1 partial ⚠️
...deploy/model_executor/layers/quantization/nvfp4.py 93.62% 6 Missing and 10 partials ⚠️
...loy/model_executor/layers/quantization/__init__.py 20.00% 4 Missing ⚠️
fastdeploy/model_executor/utils.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #6003   +/-   ##
==========================================
  Coverage           ?   67.05%           
==========================================
  Files              ?      385           
  Lines              ?    51067           
  Branches           ?     7958           
==========================================
  Hits               ?    34243           
  Misses             ?    14330           
  Partials           ?     2494           
Flag Coverage Δ
GPU 67.05% <85.01%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tests/quantization/test_modelopt_nvfp4.py
Comment thread fastdeploy/model_executor/layers/quantization/nvfp4.py
Comment thread fastdeploy/flashinfer.py Outdated
Comment thread docs/zh/quantization/nvfp4.md Outdated
zoooo0820
zoooo0820 previously approved these changes Jan 27, 2026
@Echo-Nie Echo-Nie changed the title [Feature] Support NVFP4 MoE [Feature] Support NVFP4 MoE on SM100 Jan 27, 2026
@yuanlehome yuanlehome self-assigned this Jan 27, 2026
Comment thread fastdeploy/model_executor/layers/moe/moe.py
Comment thread fastdeploy/model_executor/utils.py Outdated
Comment thread fastdeploy/envs.py Outdated
Comment thread fastdeploy/flashinfer.py Outdated
@Echo-Nie

This comment was marked as outdated.

@Echo-Nie

Copy link
Copy Markdown
Contributor Author

/re-run all-failed

@zoooo0820
zoooo0820 merged commit 44b5270 into PaddlePaddle:develop Jan 29, 2026
45 of 61 checks passed
@Echo-Nie
Echo-Nie deleted the fp4_moe branch January 29, 2026 06:41
kesmeey pushed a commit to kesmeey/FastDeploy that referenced this pull request Feb 22, 2026
* fp4 dense

* [WIP] support nvfp4, dense part

* [wip] developing loading qwen model

* loading

* update

* dense fp4 OK, cudagraph error

* [WIP] moe forward part

* with flashinfer-backend

* qwen3_moe_fp4

* update

* support flashinfer-cutlass moe, qwen3-moe-fp4 OK

* support ernie4.5-fp4

* fix load error

* add some ut

* add docs

* fix CLA, test

* fix the apply() in ModelOptNvFp4FusedMoE

* fix CodeStyle

* del the PADDLE_COMPATIBLE_API

* fix broken url: nvidia_gpu.md

* fix docs

* fix token_ids

* fix CI in Hopper

* move flashinfer imports inside the function

* fix model_runner

Removed the logic for generating random padding IDs.

* Remove skip condition for CUDA version in nvfp4 test

* add test for nvfp4

* fix according to review

* Add Chinese translation link to NVFP4 documentation

* del flashinfer.py

* fix unittest

---------

Co-authored-by: zoooo0820 <zoooo0820@qq.com>
Co-authored-by: bukejiyu <395822456@qq.com>
chang-wenbin pushed a commit to chang-wenbin/FastDeploy that referenced this pull request Mar 2, 2026
* fp4 dense

* [WIP] support nvfp4, dense part

* [wip] developing loading qwen model

* loading

* update

* dense fp4 OK, cudagraph error

* [WIP] moe forward part

* with flashinfer-backend

* qwen3_moe_fp4

* update

* support flashinfer-cutlass moe, qwen3-moe-fp4 OK

* support ernie4.5-fp4

* fix load error

* add some ut

* add docs

* fix CLA, test

* fix the apply() in ModelOptNvFp4FusedMoE

* fix CodeStyle

* del the PADDLE_COMPATIBLE_API

* fix broken url: nvidia_gpu.md

* fix docs

* fix token_ids

* fix CI in Hopper

* move flashinfer imports inside the function

* fix model_runner

Removed the logic for generating random padding IDs.

* Remove skip condition for CUDA version in nvfp4 test

* add test for nvfp4

* fix according to review

* Add Chinese translation link to NVFP4 documentation

* del flashinfer.py

* fix unittest

---------

Co-authored-by: zoooo0820 <zoooo0820@qq.com>
Co-authored-by: bukejiyu <395822456@qq.com>
xiaoguoguo626807 pushed a commit to xiaoguoguo626807/FastDeploy that referenced this pull request May 7, 2026
* fp4 dense

* [WIP] support nvfp4, dense part

* [wip] developing loading qwen model

* loading

* update

* dense fp4 OK, cudagraph error

* [WIP] moe forward part

* with flashinfer-backend

* qwen3_moe_fp4

* update

* support flashinfer-cutlass moe, qwen3-moe-fp4 OK

* support ernie4.5-fp4

* fix load error

* add some ut

* add docs

* fix CLA, test

* fix the apply() in ModelOptNvFp4FusedMoE

* fix CodeStyle

* del the PADDLE_COMPATIBLE_API

* fix broken url: nvidia_gpu.md

* fix docs

* fix token_ids

* fix CI in Hopper

* move flashinfer imports inside the function

* fix model_runner

Removed the logic for generating random padding IDs.

* Remove skip condition for CUDA version in nvfp4 test

* add test for nvfp4

* fix according to review

* Add Chinese translation link to NVFP4 documentation

* del flashinfer.py

* fix unittest

---------

Co-authored-by: zoooo0820 <zoooo0820@qq.com>
Co-authored-by: bukejiyu <395822456@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants