Skip to content

[CI]【Hackathon 10th Spring No.44】fused_moe_deepgemm_backend unit test#7492

Open
bobby-cloudforge wants to merge 3 commits intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-44-fused-moe-deepgemm-unittest-v2
Open

[CI]【Hackathon 10th Spring No.44】fused_moe_deepgemm_backend unit test#7492
bobby-cloudforge wants to merge 3 commits intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-44-fused-moe-deepgemm-unittest-v2

Conversation

@bobby-cloudforge
Copy link
Copy Markdown

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

注:截图为本测试文件独立执行 pytest --cov 的输出(含 branch coverage),上方文字为 develop 现有测试与本 PR 合并后的 statement 覆盖率预估,两者口径不同,以 CI 实际合并结果为准。

新覆盖行数 76-19 = 57 → 四舍五入 100 → 预计贡献度 0.1⭐

Usage or Command

pytest tests/layers/test_fused_moe_deepgemm_backend.py

Accuracy Tests

not applicable

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
Copy link
Copy Markdown

paddle-bot bot commented Apr 19, 2026

Thanks for your contribution!

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 19, 2026

CLA assistant check
All committers have signed the CLA.

@paddle-bot paddle-bot bot added the contributor External developers label Apr 19, 2026
@bobby-cloudforge bobby-cloudforge deleted the task/h10-44-fused-moe-deepgemm-unittest-v2 branch April 19, 2026 19:45
@bobby-cloudforge bobby-cloudforge restored the task/h10-44-fused-moe-deepgemm-unittest-v2 branch April 19, 2026 19:46
@bobby-cloudforge bobby-cloudforge deleted the task/h10-44-fused-moe-deepgemm-unittest-v2 branch April 19, 2026 19:55
@bobby-cloudforge bobby-cloudforge restored the task/h10-44-fused-moe-deepgemm-unittest-v2 branch April 19, 2026 19:55
PaddlePaddle-bot

This comment was marked as outdated.

Address bot review: replace for-loop with parametrize so each
ue8m0 value runs as an independent test case.
@bobby-cloudforge bobby-cloudforge force-pushed the task/h10-44-fused-moe-deepgemm-unittest-v2 branch from a08343a to 420867c Compare April 19, 2026 20:24
PaddlePaddle-bot

This comment was marked as outdated.

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

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

🤖 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/(纯新增测试文件)
影响面 TagCI 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")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 scope="module" 的 fixture 配合全局变量 dgb 可能在并行测试 (pytest-xdist) 下存在竞态风险。

当前注释已说明 monkeypatch 是 function-scoped 会自动恢复,但如果未来引入 pytest-xdist 的 worker 粒度为 module 级别,多个 worker 可能同时修改 sys.modules

建议:

  1. 在文件顶部或 fixture docstring 中明确注明 不支持 pytest-xdist loadscope=module 并行
  2. 或考虑改为 scope="session" + tmp_path_factory 隔离(如果后续测试量增大)

当前实现在单进程运行下无问题,仅为防御性建议。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants