Skip to content

[Feature] Support MegaMoE - #7943

Merged
Jiang-Jia-Jun merged 17 commits into
PaddlePaddle:developfrom
Wanglongzhi2001:mega_moe
Jun 10, 2026
Merged

[Feature] Support MegaMoE#7943
Jiang-Jia-Jun merged 17 commits into
PaddlePaddle:developfrom
Wanglongzhi2001:mega_moe

Conversation

@Wanglongzhi2001

@Wanglongzhi2001 Wanglongzhi2001 commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Motivation

💡 If this PR is a Cherry Pick, the PR title needs to follow the format by adding the [Cherry-Pick] label at the very beginning and appending the original PR ID at the end. For example, [Cherry-Pick][CI] Add check trigger and logic(#5191)

💡 如若此PR是Cherry Pick,PR标题需遵循格式,在最开始加上[Cherry-Pick]标签,以及最后面加上原PR ID,例如[Cherry-Pick][CI] Add check trigger and logic(#5191)

支持 MegaMoE (wfp4afp8)

Modifications

支持 MegaMoE (wfp4afp8)

Usage or Command

  • 预备环境
    拉取下面两个 wheel 包进行编译,或者联系本人获取编译好的 wheel 包
  1. [Feature] support symmetric_memory Paddle#79204
  2. Update DeepGEMM PFCCLab/DeepGEMM#11
  • 在线量化(需搭配 v1 loader)
    在服务启动参数中加入下面的参数(两种方法皆可)
--load-choices "default_v1" \
--quantization '{"quantization": "mix_quant","kv_cache_quant_type": "block_wise_fp8","dense_quant_type": "block_wise_fp8","moe_quant_type": "wfp4afp8"}' \

或者

--load-choices "default_v1" \
--enable-mega-moe \
  • 离线量化模型加载(需搭配 v0 lodaer)
--load-choices "default" \

然后模型 config.json 中加入:

"quantization_config": {
  "is_moe_quantized": true,
  "quantization": "mix_quant",
  "dense_quant_type": "block_wise_fp8",
  "kv_cache_quant_type": "block_wise_fp8",
  "moe_quant_type": "wfp4afp8",
  "moe_dynamic_quant": false
}

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.

Copilot AI review requested due to automatic review settings May 27, 2026 11:30
@paddle-bot

paddle-bot Bot commented May 27, 2026

Copy link
Copy Markdown

Thanks for your contribution!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

该 PR 旨在为 FastDeploy 的 MoE 路径引入 MegaMoE 支持:新增一个用于 pre-dispatch/量化准备的 CUDA 自定义算子,并在 DeepGEMM MoE backend 中接入对应的 buffer 与执行流程,同时补充算子级别的单测。

Changes:

  • 新增 mega_moe_pre_dispatch CUDA 自定义算子,并在 custom ops 构建脚本中按架构条件编译进包。
  • DeepGemmFusedMoeMethod 中新增 MegaMoE 相关 buffer 初始化、权重量化布局处理与 apply_mage_moe 执行路径。
  • 增加 tests/operators/test_mega_moe_pre_dispatch.py 用于校验 pre-dispatch 输出正确性。

另外:PR 标题格式符合要求,但当前 PR 描述的 Motivation/Modifications/Usage/Accuracy Tests 均未补全,建议补充(尤其是启用方式如环境变量、适用硬件/算子依赖与精度结果)。

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/operators/test_mega_moe_pre_dispatch.py 新增 MegaMoE pre-dispatch 单测(当前存在导入与分布式初始化可用性问题)
fastdeploy/model_executor/layers/quantization/fp8_utils.py 增加权重交织与 scale layout 变换辅助函数以适配 MegaMoE 权重格式
fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py DeepGEMM MoE backend 接入 MegaMoE:buffer、量化流程与执行入口
fastdeploy/model_executor/layers/moe/fused_moe_backend_base.py 在基类 apply 中根据环境变量切换到 MegaMoE 路径
fastdeploy/envs.py 新增环境变量 FD_ENABLE_MAGE_MOE 开关
custom_ops/setup_ops.py mega_moe_pre_dispatch.cu 加入 SM100/103 构建源文件
custom_ops/gpu_ops/mega_moe_pre_dispatch.cu 新增 MegaMoE pre-dispatch CUDA Kernel 与静态算子注册

Comment thread fastdeploy/model_executor/layers/moe/fused_moe_backend_base.py Outdated
Comment thread fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py
Comment thread fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py
return ffn_out


@singleton
Comment thread fastdeploy/envs.py Outdated
Comment thread tests/operators/test_mega_moe_pre_dispatch.py Outdated
Comment thread tests/operators/test_mega_moe_pre_dispatch.py
Comment thread tests/operators/test_mega_moe_pre_dispatch.py Outdated
@PaddlePaddle-bot

PaddlePaddle-bot commented May 27, 2026

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-06-09 06:28:31 UTC+08:00

CI报告基于以下代码生成(30分钟更新一次):
PR commit: 7dbbd8f | Merge base: f18078f (branch: develop)


1 Required任务 : 1/10 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
42(0) 42 29 11 0 0 0
任务 错误类型 置信度 日志
xpu_8cards_case_test / run_xpu_8cards_cases PR问题:XPU EP 调用 GPU moe_topk_select Job
Run Base Tests / base_tests 环境问题:Paddle DeepEP Buffer 缺失 Job
Run FastDeploy LogProb Tests / run_tests_logprob 环境问题:服务启动前 DeepEP 导入失败 Job
Run Four Cards Tests / run_4_cards_tests 环境问题:多用例 DeepEP 导入失败 Job
Run Stable Tests / stable_tests 环境问题:Paddle DeepEP Buffer 缺失 Job
Approval 需要 Approval Job
Extracted partial CE model tasks to run in CI. / run_ce_cases 未知:分析省略 Job

2 失败详情

🔴 xpu_8cards_case_test / run_xpu_8cards_cases — PR问题(置信度: 高)

错误类型: PR问题 | 置信度: 高
分析器: ci_analyze_unittest_fastdeploy
失败用例:

用例 错误摘要
XPU 8 cards MoE EP 服务启动 ops.gpu 中不存在 moe_topk_select,worker 退出后 PD 分离服务启动超时

关键日志:

PD分离服务启动超时:经过 10 分钟服务仍未启动!
File "/workspace/FastDeploy/fastdeploy/model_executor/layers/backends/xpu/moe/fused_moe.py", line 427, in apply_ep_prefill
  topk_idx, topk_weights = EPRunner.moe_select(layer, gate_out)
File "/workspace/FastDeploy/fastdeploy/model_executor/layers/moe/ep.py", line 551, in moe_select
  topk_idx, topk_weights = fastdeploy.model_executor.ops.gpu.moe_topk_select(
AttributeError: module 'fastdeploy.model_executor.ops.gpu' has no attribute 'moe_topk_select'
  • 根因摘要: XPU EP 选路调用了 GPU moe_topk_select
    PR 将 fastdeploy/model_executor/layers/backends/xpu/moe/fused_moe.py 的 EP prefill/decode 从实例 runner 改为 EPRunner.moe_select(layer, gate_out);该公共方法内部固定调用 fastdeploy.model_executor.ops.gpu.moe_topk_select。XPU 后端本文件原本导入的是 fastdeploy.model_executor.ops.xpu.moe_topk_select,因此 XPU 运行时走到了不存在的 GPU op。

修复建议:

  1. 在 XPU EP prefill/decode 保留 XPU 专属 topk 选择,或让 EPRunner.moe_select 按 backend/platform 分派到 ops.xpu.moe_topk_select,避免 XPU 路径访问 ops.gpu

关联变更: fastdeploy/model_executor/layers/backends/xpu/moe/fused_moe.py prefill/decode 调用点;fastdeploy/model_executor/layers/moe/ep.py:551

🔴 Run Base Tests / base_tests — 环境问题(置信度: 高)

错误类型: 环境问题 | 置信度: 高
分析器: ci_analyze_unittest_fastdeploy
失败用例:

用例 错误摘要
ERNIE-4.5-0.3B-Paddle 服务启动 模型注册扫描 glm4_mtp 时导入 Paddle DeepEP Buffer 失败

关键日志:

File "/usr/local/lib/python3.10/dist-packages/fastdeploy/model_executor/models/__init__.py", line 63, in auto_models_registry
  raise ImportError(f"{module_file=} import error, error message: {e}")
ImportError: module_file='glm4_mtp' import error, error message: cannot import name 'Buffer' from 'paddle.base.libpaddle'
(/usr/local/lib/python3.10/dist-packages/paddle/base/libpaddle.so)
  • 根因摘要: CI Paddle wheel 缺少 DeepEP Buffer
    失败发生在服务启动前的模型注册导入阶段,当前 CI 镜像中的 Paddle DeepEP Python 包尝试从 paddle.base.libpaddle 导入 Buffer,但底层动态库不包含该符号。PR 未修改 glm4_mtp / glm4_moe 模型文件,现象更像 CI Paddle/DeepEP wheel 版本不匹配。

修复建议:

  1. 环境问题,请 rerun;若持续复现,请更新 CI 镜像或 Paddle wheel,使 paddle.distributed.communication.deep_eplibpaddle.so 版本一致。

关联变更: 未发现 PR 直接修改 fastdeploy/model_executor/models/glm4_mtp.pyglm4_moe.py

🔴 Run FastDeploy LogProb Tests / run_tests_logprob — 环境问题(置信度: 高)

错误类型: 环境问题 | 置信度: 高
分析器: ci_analyze_logprob_fastdeploy
失败用例:

用例 错误摘要
logprob 服务启动 / 结果收集 服务因 DeepEP Buffer 导入失败未启动,未生成 *result.log

关键日志:

ImportError: cannot import name 'Buffer' from 'paddle.base.libpaddle'
ImportError: module_file='glm4_mtp' import error, error message: cannot import name 'Buffer' from 'paddle.base.libpaddle'
cat: '*result.log': No such file or directory
logprob test failed with exit code 1
  • 根因摘要: LogProb 未进入比对,服务启动失败
    按 LogProb 适配提取未命中“数量不一致/不匹配/mismatch/AssertionError”等比对错误;失败发生在 API server 初始化阶段,根因与 Base Tests 相同,是 Paddle DeepEP Buffer 符号缺失导致服务不可用。

修复建议:

  1. 环境问题,请 rerun;若仍失败,请先修复 CI Paddle/DeepEP 依赖版本,再重新执行 LogProb 比对。

关联变更: 未发现 LogProb baseline 或输出比对相关失败证据

🔴 Run Four Cards Tests / run_4_cards_tests — 环境问题(置信度: 高)

错误类型: 环境问题 | 置信度: 高
分析器: ci_analyze_unittest_fastdeploy
失败用例:

用例 错误摘要
test_GLM_45_AIR_mtp_tp4.py, test_GLM_45_AIR_tp4.py, test_determinism_long.py 等 6 个 API server/LLM 初始化阶段 DeepEP Buffer 导入失败,多个用例启动超时

关键日志:

[TIMEOUT] API server failed to start in 5 minutes.
ImportError: module_file='ernie4_5_moe' import error, error message: cannot import name 'Buffer' from 'paddle.base.libpaddle'
ERROR ep.py[line:65] import deep_ep failed! FD_USE_PFCC_DEEP_EP=False.
ImportError: cannot import name 'Buffer' from 'paddle.base.libpaddle'
6 test file(s) failed
  • 根因摘要: 四卡用例共享 DeepEP 依赖导入失败
    6 个 e2e 文件失败前均出现服务启动超时或 LLM 初始化失败,核心异常是 paddle.distributed.communication.deep_ep 无法从当前 libpaddle.so 导入 Buffer。这是跨用例的依赖环境问题,不是单个 4 cards 测试断言失败。

修复建议:

  1. 环境问题,请 rerun;如持续失败,请同步 CI 的 Paddle/DeepEP 版本后再跑四卡用例。

关联变更: 未发现这些 e2e 测试文件被 PR 修改

🔴 Run Stable Tests / stable_tests — 环境问题(置信度: 高)

错误类型: 环境问题 | 置信度: 高
分析器: ci_analyze_unittest_fastdeploy
失败用例:

用例 错误摘要
tests/ci_validation/stable_cases stable 服务启动失败,随后 clear_load_weight HTTP 000

关键日志:

ERROR ep.py[line:65] import deep_ep failed! FD_USE_PFCC_DEEP_EP=False.
ImportError: cannot import name 'Buffer' from 'paddle.base.libpaddle'
ImportError: module_file='glm_moe_dsa' import error, error message: cannot import name 'Buffer' from 'paddle.base.libpaddle'
Timeout: API server did not start within 300 seconds (port 8088)
Assertion failed: http://0.0.0.0:8088/clear_load_weight failed with HTTP 000
  • 根因摘要: Stable 服务因 DeepEP Buffer 缺失未启动
    Stable job 在启动模型服务时导入 DeepEP 失败,服务未在 300 秒内起来,后续请求 clear_load_weight 返回 HTTP 000。该失败链路与 Base/LogProb/Four Cards 的 Paddle wheel 符号缺失一致。

修复建议:

  1. 环境问题,请 rerun;若持续失败,请检查 CI 镜像中的 Paddle wheel 与 DeepEP Python 包是否来自同一构建。

关联变更: 未发现 stable case 脚本被 PR 修改

🔴 Approval — 需要 Approval(置信度: 高)

该 Job 需要人工 Approval,完成审批后 CI 才会继续执行。

🔴 Extracted partial CE model tasks to run in CI. / run_ce_cases — 未知(置信度: 低)

本轮 required 失败 job 中 cache miss 数量超过 5 个,按 Skill 预算限制未对该 Job 拉取深度日志;当前仅保留快速状态,错误摘要为“日志分析省略(超出失败 Job 量限制)”。

PaddlePaddle-bot

This comment was marked as outdated.

@codecov-commenter

codecov-commenter commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 17.00405% with 205 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@d7d7373). Learn more about missing BASE report.

Files with missing lines Patch % Lines
..._executor/layers/moe/fused_moe_deepgemm_backend.py 8.57% 160 Missing ⚠️
...loy/model_executor/layers/quantization/wfp4afp8.py 36.66% 19 Missing ⚠️
...oy/model_executor/layers/quantization/fp8_utils.py 14.28% 12 Missing ⚠️
...loy/model_executor/layers/quantization/__init__.py 28.57% 9 Missing and 1 partial ⚠️
fastdeploy/model_executor/layers/moe/ep.py 55.55% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7943   +/-   ##
==========================================
  Coverage           ?   67.48%           
==========================================
  Files              ?      471           
  Lines              ?    66356           
  Branches           ?    10215           
==========================================
  Hits               ?    44782           
  Misses             ?    18722           
  Partials           ?     2852           
Flag Coverage Δ
GPU 77.51% <17.00%> (?)
XPU 6.99% <1.61%> (?)

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

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.

Comment on lines +36 to +45
__device__ __forceinline__ float WarpReduceMax(float value) {
static_assert(kNumThreads >= 1 && kNumThreads <= WARP_SIZE,
"kNumThreads must be in [1, 32]");
static_assert((kNumThreads & (kNumThreads - 1)) == 0,
"kNumThreads must be a power of 2");
#pragma unroll
for (int mask = kNumThreads / 2; mask > 0; mask >>= 1) {
value = fmaxf(value, __shfl_xor_sync(0xffffffffu, value, mask, WARP_SIZE));
}
return value;
Comment thread tests/model_executor/test_ep.py
Comment thread tests/operators/test_mega_moe_pre_dispatch.py
Comment thread tests/operators/test_mega_moe_pre_dispatch.py
Comment thread tests/operators/test_mega_moe_pre_dispatch.py
Comment thread fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py
Comment thread fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py Outdated
Copilot AI review requested due to automatic review settings June 8, 2026 09:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Comment on lines +41 to +44
#pragma unroll
for (int mask = kNumThreads / 2; mask > 0; mask >>= 1) {
value = fmaxf(value, __shfl_xor_sync(0xffffffffu, value, mask, WARP_SIZE));
}
Comment thread tests/operators/test_mega_moe_pre_dispatch.py
Comment thread tests/operators/test_mega_moe_pre_dispatch.py
Comment thread fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py Outdated
Comment thread fastdeploy/model_executor/layers/quantization/fp8_utils.py
Comment on lines +54 to +56
def get_quant_method(self, layer) -> Optional[QuantMethodBase]:
logger.info("Currently only support DeepGEMMMegaMoE for wfp4afp8")
if isinstance(layer, FusedMoE):

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

custom_ops/setup_ops.py:526

  • 这里的注释格式是 pass # ...,会触发 pre-commit 的 flake8/pep8(# 前应至少两个空格)。建议改为 pass # ...
            # Add SM100 specific sources if any, e.g., for new hardware intrinsics
            # sources += ["gpu_ops/cutlass_kernels/w8a8/c4x_sm100.cu"] # Example
            pass  # No SM100 specific sources identified yet beyond what CUTLASS handles

Comment thread tests/operators/test_mega_moe_pre_dispatch.py
Comment thread tests/operators/test_mega_moe_pre_dispatch.py
Comment thread fastdeploy/model_executor/layers/quantization/fp8_utils.py
Comment thread fastdeploy/model_executor/layers/backends/xpu/moe/fused_moe.py
Comment thread fastdeploy/model_executor/layers/backends/xpu/moe/fused_moe.py
Comment thread fastdeploy/model_executor/layers/backends/xpu/moe/fused_moe.py
PaddlePaddle-bot

This comment was marked as outdated.

Copilot AI review requested due to automatic review settings June 9, 2026 06:51
Copilot AI review requested due to automatic review settings June 9, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 9 comments.

Comment thread fastdeploy/model_executor/layers/quantization/nvfp4.py
Comment thread fastdeploy/model_executor/layers/quantization/nvfp4.py
Comment thread fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py
Comment thread fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py
Comment thread fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py
Comment thread tests/operators/test_mega_moe_pre_dispatch.py
Comment on lines +76 to +79
@classmethod
def setUpClass(cls):
paddle.seed(2025)

Comment on lines +67 to +71
x_view = x_padded.reshape([m, padded_n // gran_k, gran_k])
x_amax = x_view.abs().astype("float32").amax(axis=2).reshape([m, padded_n // gran_k]).clip(min=1e-4)
sf = x_amax / 448.0
sf = ceil_to_ue8m0(sf) if use_ue8m0 else sf
x_fp8 = (x_view * (1.0 / sf.unsqueeze(2))).astype(paddle.float8_e4m3fn).reshape([m, padded_n])[:, :n]
Comment on lines +54 to +56
def get_quant_method(self, layer) -> Optional[QuantMethodBase]:
logger.info("Currently only support DeepGEMMMegaMoE for wfp4afp8")
if isinstance(layer, FusedMoE):
Comment thread fastdeploy/worker/worker_process.py Outdated
)
parser.add_argument(
"--enable_mega_moe",
"--enable-mega-moe",

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.

这里参数保留一个就可以吧

from ..moe import FusedMoE
from .quant_base import QuantConfigBase, QuantMethodBase

QUANT_SCALING_FACTOR = 6

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.

可以看看Copilot的review是否有必要

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Comment thread fastdeploy/model_executor/layers/quantization/nvfp4.py Outdated
Comment thread fastdeploy/model_executor/layers/quantization/nvfp4.py Outdated
Comment on lines +76 to +103
def _get_mega_moe_quantization_config():
return {
"quantization": "mix_quant",
"kv_cache_quant_type": "block_wise_fp8",
"dense_quant_type": "block_wise_fp8",
"moe_quant_type": "wfp4afp8",
"is_quantized": False,
}


def parse_quant_config(args, model_config, is_ernie, is_v1_loader):
if args.quantization is not None and isinstance(args.quantization, str):
args.quantization = parse_quantization(args.quantization)

enable_mega_moe = getattr(args, "enable_mega_moe", False)
if enable_mega_moe:
mega_moe_quantization_config = _get_mega_moe_quantization_config()

if args.quantization is None and model_config.quantization_config is None:
args.quantization = mega_moe_quantization_config
if args.quantization is not None and not _is_mega_moe_quantization_config(args.quantization):
raise ValueError("--enable-mega-moe requires moe_quant_type=wfp4afp8.")
if model_config.quantization_config is not None and not _is_mega_moe_quantization_config(
model_config.quantization_config
):
raise ValueError(
"--enable-mega-moe conflicts with model quantization_config. It requires moe_quant_type=wfp4afp8."
)
Comment thread custom_ops/gpu_ops/mega_moe_pre_dispatch.cu
Comment thread tests/operators/test_mega_moe_pre_dispatch.py
Copilot AI review requested due to automatic review settings June 10, 2026 06:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Comment on lines +42 to +44
for (int mask = kNumThreads / 2; mask > 0; mask >>= 1) {
value = fmaxf(value, __shfl_xor_sync(0xffffffffu, value, mask, WARP_SIZE));
}
Comment on lines +226 to +227
PD_CHECK(num_tokens_i64 <= num_max_tokens_per_rank,
"num_tokens must not exceed padded_max");
Comment thread fastdeploy/model_executor/layers/quantization/nvfp4.py
Comment on lines +21 to +25
from ..moe import FusedMoE
from .quant_base import QuantConfigBase, QuantMethodBase

QUANT_SCALING_FACTOR = 6

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Paddle-CI-Agent | pr_review | 2026-06-10 15:19:34

📋 Review 摘要

PR 概述:新增 Blackwell MegaMoE wfp4afp8 路径、pre-dispatch CUDA op、量化配置和 worker 参数传递。

变更范围:custom op、MoE DeepGEMM backend、quantization、Engine/worker 配置、算子测试。

影响面 Tag[OP] [Quantization] [FDConfig] [Engine]

问题

⚠️ 本 PR 变更量较大(15 文件 / 1134 行),建议拆分以降低审查难度和合入风险。

建议拆分方案

  • PR 1: MegaMoE pre-dispatch 算子与测试 — custom_ops/gpu_ops/mega_moe_pre_dispatch.cu, custom_ops/setup_ops.py, tests/operators/test_mega_moe_pre_dispatch.py
  • PR 2: MegaMoE 配置与进程参数传递 — fastdeploy/config.py, fastdeploy/engine/args_utils.py, fastdeploy/engine/engine.py, fastdeploy/worker/worker_process.py, tests/engine/test_engine.py
  • PR 3: wfp4afp8 quant 与 DeepGEMM MegaMoE backend — fastdeploy/model_executor/layers/moe/ep.py, fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py, fastdeploy/model_executor/layers/quantization/*.py, tests/model_executor/test_ep.py
级别 文件 概述
🔴 Bug fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py:1359 MegaMoE 前向忽略 shared experts / latent projections / routing hook 等 MoE 语义,相关模型输出会不正确
🟡 建议 PR整体 变更量较大,建议按算子、配置、backend 三块拆分

历史 Findings 修复情况

Finding 问题 状态
F1 --enable-mega-moe 默认量化配置写入时序 ⚠️ 仍存在
F2 wfp4afp8 未限制 EP MegaMoE 路径 ⚠️ 仍存在

📝 PR 规范检查

标题已有官方 [Feature] Tag;描述仍缺少 Accuracy Tests 实际内容,Checklist 仍未按现状勾选。

总体评价

本轮按风险优先审查了 MegaMoE 前向、量化配置时序、custom op 注册与测试路径,未全量覆盖其余机械改动。当前存在会导致带 shared experts 或 latent projection 的 MoE 模型输出错误的阻塞问题,需要修复后再合入。

@Jiang-Jia-Jun
Jiang-Jia-Jun merged commit edc885d into PaddlePaddle:develop Jun 10, 2026
39 of 43 checks passed
Jiang-Jia-Jun pushed a commit that referenced this pull request Jun 11, 2026
* [Feature] Support MegaMoE (#7943)

* [Feature] Support MegaMoE

* update code

* fix code style

* fix code style

* fix test

* fix test

* fix test

* fix test

* fix typo

* fix code style

* fix test

* fix xpu test

* fix test

* fix test

* fix code style

* fix typo

* fix typo

* delete log

* fix code style

* fix paddle compat

* fix code style

---------

Co-authored-by: root <root@tjzj-inf-sci-k8s-bzz2-00005.tjzj.baidu.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.

6 participants