[Cherry-Pick][RL] Support moe_topk_select using Paddle native operators and Add fused stack-transpose-quant for BlockWiseFP8 MoE weight quantization and swiglu-fp8-quant op for DeepGemmFusedMoE for training alignment (#6850) - #6935
Conversation
|
Thanks for your contribution! |
There was a problem hiding this comment.
Pull request overview
该 PR 主要围绕 MoE 的 TopK 选择与 FP8(含 UE8M0 scale)量化路径做增强:在 DeepGemmFusedMoE 侧引入基于 Paddle 原生算子的 moe_topk_select 选择逻辑,并新增/对齐 Fleet 侧的 fused 算子接入(stack+transpose+fp8 quant、以及带 routed prob 的 fused swiglu+fp8 quant),同时补充对应单测与环境开关。
Changes:
- 在 DeepGemm MoE 路径新增
moe_topk_select(Paddle native)并通过FD_USE_PHI_TOPK控制启用。 - 新增
fp8_utils.fused_stack_transpose_quant并在 Triton MoE 的 UE8M0 量化权重处理里通过FD_USE_FLEET_FP8_QUANT切到 Fleet fused kernel。 - 新增
FD_MOE_PROB_IN_ADVANCE/FD_USE_FLEET_FP8_QUANT/FD_USE_PHI_TOPK环境变量,并补充 deepgemm/fused-quant 相关测试用例。
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/operators/test_noaux_tc_redundant.py | 增加基于 moe_topk_select 的 group-topk 对齐测试 |
| tests/layers/test_fp8_ue8m0.py | 增加 Fleet fused stack+transpose+quant 及 fused_stack_transpose_quant 的单测覆盖 |
| tests/layers/test_deepgemm_fused_moe.py | 新增 DeepGemmFusedMoE 多路径(TP/EP、prob-in-advance、phi permute 等)对齐测试 |
| fastdeploy/model_executor/layers/quantization/fp8_utils.py | 新增 try_import、paddlefleet_ops 引入与 fused_stack_transpose_quant 等量化辅助能力 |
| fastdeploy/model_executor/layers/moe/fused_moe_triton_backend.py | UE8M0 权重量化新增 Fleet fused 路径(chunk 化处理) |
| fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py | 引入 moe_topk_select 与 FD_MOE_PROB_IN_ADVANCE 下的 fused swiglu+fp8 quant 路径,并调整 unpermute combine 开关 |
| fastdeploy/envs.py | 新增 MoE TopK/Fleet FP8 quant/prob-in-advance 等环境变量开关 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release/2.5 #6935 +/- ##
==============================================
Coverage ? 69.18%
==============================================
Files ? 389
Lines ? 53474
Branches ? 8394
==============================================
Hits ? 36995
Misses ? 13812
Partials ? 2667
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
该 PR(Cherry-pick)主要围绕 MoE 路由与 FP8 权重量化路径做增强:一方面在 DeepGemm MoE 中新增基于 Paddle 原生算子的 moe_topk_select(用于 noaux_tc 训练对齐),另一方面引入 Fleet 的 fused stack-transpose-fp8-quant / fused weighted swiglu-fp8-quant 相关能力,并补充/扩展对应单测覆盖。
Changes:
- 新增
moe_topk_select(Paddle 原生算子实现)并在 DeepGemm MoE 的 TP/EP prefill 路径按开关启用 - 在 BlockWiseFP8 MoE 权重量化中接入
fused_stack_transpose_quant(支持按 chunk 处理专家权重) - 增加/扩展多份测试文件以覆盖 Triton/DeepGemm/ue8m0 分支与 fused quant 行为
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/operators/test_noaux_tc_redundant.py | 新增用例对比 moe_topk_select 与参考实现的一致性 |
| tests/layers/test_fused_moe_triton_backend.py | 新增 Triton MoE backend 的大量单测(mock/patch 覆盖多分支) |
| tests/layers/test_fp8_ue8m0.py | 扩展 ue8m0 与 fused_stack_transpose_quant 等分支的测试覆盖 |
| tests/layers/test_deepgemm_fused_moe.py | 新增 DeepGemmFusedMoE 训练对齐相关路径的测试(含 EP/TP 分支) |
| fastdeploy/model_executor/layers/quantization/fp8_utils.py | 增加 try_import、paddlefleet_ops 探测与 fused_stack_transpose_quant 封装 |
| fastdeploy/model_executor/layers/moe/fused_moe_triton_backend.py | BlockWiseFP8 MoE 动态量化 ue8m0 分支中接入 fused stack-transpose-quant |
| fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py | 新增 moe_topk_select 并引入 prob-in-advance + fused swiglu-fp8-quant 的分支 |
| fastdeploy/envs.py | 新增/调整若干 env 开关(MoE TopK / prob-in-advance 等) |
| # Whether to use phi MOE permute,if 1,use paddle op. | ||
| "FD_USE_PHI_MOE_PERMUTE": lambda: bool(int(os.getenv("FD_USE_PHI_MOE_PERMUTE", "0"))), | ||
| # Whether to use phi TopK, when need select moe by noaux_tc method if 1,use paddle default. | ||
| "FD_USE_PHI_TOPK": lambda: bool(int(os.getenv("FD_USE_PHI_TOPK", "0"))), |
There was a problem hiding this comment.
这里是不是合并代码的时候漏了,同时加了2个topk环境变量
There was a problem hiding this comment.
解决conflict的时候漏删掉了。现在已经删掉了
Motivation
Modifications
Usage or Command
Accuracy Tests
Checklist
[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]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.