[CI]【Hackathon 10th Spring No.44】fused_moe_deepgemm_backend unit test#7492
Open
bobby-cloudforge wants to merge 3 commits intoPaddlePaddle:developfrom
Open
Conversation
|
Thanks for your contribution! |
Address bot review: replace for-loop with parametrize so each ue8m0 value runs as an independent test case.
a08343a to
420867c
Compare
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-20 04:50 CST
📋 Review 摘要
PR 概述:为 fused_moe_deepgemm_backend.py 补充单元测试,覆盖 helper 函数、权重管理、apply_tp (per_token_quant) 路径及 apply_ep_prefill/decode 的 shared_experts 分支。
变更范围:tests/layers/(纯新增测试文件)
影响面 Tag:CI OP
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | test_fused_moe_deepgemm_backend.py:102 |
module-scope fixture 持有全局可变状态 dgb,建议加注释说明线程安全限制 |
总体评价
测试文件设计合理,通过精心构造的 stub/mock 机制在无 GPU 环境下验证了多条关键代码路径(masked GEMM、shared_experts、per_token_quant 输入等),显著提升了覆盖率。代码结构清晰,teardown 逻辑完善,无阻塞性问题。
| dgb = None # populated by _install_stubs fixture | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True, scope="module") |
There was a problem hiding this comment.
🟡 建议 scope="module" 的 fixture 配合全局变量 dgb 可能在并行测试 (pytest-xdist) 下存在竞态风险。
当前注释已说明 monkeypatch 是 function-scoped 会自动恢复,但如果未来引入 pytest-xdist 的 worker 粒度为 module 级别,多个 worker 可能同时修改 sys.modules。
建议:
- 在文件顶部或 fixture docstring 中明确注明 不支持 pytest-xdist loadscope=module 并行
- 或考虑改为
scope="session"+tmp_path_factory隔离(如果后续测试量增大)
当前实现在单进程运行下无问题,仅为防御性建议。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
No.44 功能模块 fastdeploy/model_executor/layers/moe/fused_moe_deepgemm_backend.py 补充单测覆盖
Modifications
增加单元测试 tests/layers/test_fused_moe_deepgemm_backend.py
develop 分支:覆盖率64%,Miss行数76(44, 49-50, 76-81, 102-104, 117, 156-157, 171-176, 212, 247-315, 337, 341, 359->362, 374, 379, 410-482, 493-494, 538, 557-560, 580, 605, 609->612, 616, 619, 623, 643->647, 703, 709, 749, 766-768, 823)
当前PR:覆盖率92%,Miss行数19
新覆盖行数 76-19 = 57 → 四舍五入 100 → 预计贡献度 0.1⭐
Usage or Command
Accuracy Tests
not applicable
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.