【Hackathon 10th Spring No.39】[CI] 功能模块 fused_moe_marlin_backend.py 单测补充#7750
【Hackathon 10th Spring No.39】[CI] 功能模块 fused_moe_marlin_backend.py 单测补充#7750yu0809 wants to merge 1 commit intoPaddlePaddle:developfrom
Conversation
|
Thanks for your contribution! |
2f19b94 to
270c7dc
Compare
270c7dc to
516ff93
Compare
516ff93 to
f5429df
Compare
CI报告基于以下代码生成(30分钟更新一次): 1 任务总览所有已执行任务均已通过。
2 任务状态汇总2.1 Required任务 : 0/0 通过
当前无 required 任务(GitHub Branch Protection Rules 未配置,或 API 权限不足,所有任务均标记为可选)。 2.2 可选任务 — 2/2 通过
3 失败详情(仅 required)无 required 失败任务。 |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-05-08 16:05:27
📋 Review 摘要
PR 概述:为 Marlin MoE backend(fused_moe_marlin_backend.py)新增单元测试,通过 stub 模块加载策略在无 GPU/Triton 环境下完整覆盖 helper、dispatch 及 apply 逻辑。
变更范围:tests/model_executor/test_fused_moe_marlin_backend.py
影响面 Tag:[OP]
📝 PR 规范检查
描述结构通过(§D2 所有必填 section 均存在且内容充实)。
标题中 [CI] Tag 按 FastDeploy checklist 对应 .github/workflows/、scripts/(CI 配置文件),而本 PR 新增的是 tests/model_executor/ 单元测试,被测模块位于 model_executor/layers/moe/,更符合 [OP] 语义。考虑到 Hackathon 任务编号中已将 CI 测试补充标记为 [CI],以下仅作参考:
标题建议(可直接复制):
【Hackathon 10th Spring No.39】[OP] 功能模块 fused_moe_marlin_backend.py 单测补充
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | tests/model_executor/test_fused_moe_marlin_backend.py:250 |
apply 系列测试中直接给模块属性赋 Mock,未使用 monkeypatch.setattr |
总体评价
测试设计合理,stub 策略有效隔离了 GPU kernel 依赖,8 项用例本地全部通过且目标文件覆盖率达 100%。建议在 apply 系列测试中改用 monkeypatch.setattr 替换模块属性,以提升写法规范性与可维护性。
| topk_ids = paddle.to_tensor([[0, 1], [1, 2], [2, 3]], dtype="int32") | ||
| topk_weights = paddle.ones([3, layer.top_k], dtype="float32") | ||
| hook = Mock() | ||
|
|
There was a problem hiding this comment.
🟡 建议 apply 系列测试中通过直接赋值给模块属性打 Mock:
marlin.tritonmoe_preprocess_func = Mock(...)
marlin.MoeWna16MarlinGemmApi = Mock(...)当前结构下(每次测试均通过 _load_marlin_backend 重新加载模块),不会造成跨测试污染,但直接修改模块属性未经 monkeypatch 管理,后续若有人复用 marlin 对象可能产生意外副作用。
建议改为:
monkeypatch.setattr(marlin, "tritonmoe_preprocess_func", Mock(...))
monkeypatch.setattr(marlin, "MoeWna16MarlinGemmApi", Mock(...))同样的写法也出现在 test_apply_uses_noaux_tc_score_path(约第 316、323 行)。
Motivation
【Hackathon 10th Spring No.39】功能模块
fastdeploy/model_executor/layers/moe/fused_moe_marlin_backend.py单测补充,覆盖 Marlin MoE backend 中无需真实 GPU kernel 即可稳定验证的 helper 和 dispatch 逻辑。Modifications
新增
tests/model_executor/test_fused_moe_marlin_backend.py,通过最小模块 stub 加载目标文件,避免 CPU/macOS 本地环境依赖 Triton 或真实 Marlin kernel。覆盖内容:
get_scale_perms的 scale permutation 顺序marlin_permute_scales的 grouped / per-channel scale permutationmarlin_moe_permute_scales的 per-expert scale permutationgptq_marlin_moe_repack对 Marlin repack op 的逐 expert dispatch,以及非法size_k校验MarlinWeightOnlyMoEMethod.create_weights注册的参数 shape / dtypeprocess_loaded_weights的 quantization / packing 流程apply的topk与noaux_tc两条 top-k 路径,以及后续 GPU 预处理与 Marlin GEMM dispatchUsage or Command
本地结果:
Coverage CI 最终结果以仓库 CI 为准;本地目标文件覆盖率为 100%。
Accuracy Tests
无准确率影响。本 PR 只补充单元测试,不修改推理逻辑或模型输出。
Checklist
pre-commitbefore commit.pre_commit模块;已执行git diff --check和py_compile。releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.develop.