Skip to content

【Hackathon 9th No.39】add test_moe_expert_ffn_wint2 [cf]#7710

Open
ghost wants to merge 1 commit intoPaddlePaddle:developfrom
CloudForge-Solutions:task/039-unit-test-moe-expert-ffn-wint2-v3
Open

【Hackathon 9th No.39】add test_moe_expert_ffn_wint2 [cf]#7710
ghost wants to merge 1 commit intoPaddlePaddle:developfrom
CloudForge-Solutions:task/039-unit-test-moe-expert-ffn-wint2-v3

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented May 2, 2026

Motivation

Modifications

Usage or Command

Accuracy Tests

Checklist

  • I have submitted the CLA (only first PR)
  • My PR title follows the convention
  • My changes pass all tests

@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 2, 2026

CLA assistant check
All committers have signed the CLA.

@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@ghost ghost temporarily deployed to Metax_ci May 2, 2026 17:15 — with GitHub Actions Inactive
@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented May 2, 2026

Thanks for your contribution!

@paddle-bot paddle-bot Bot added the contributor External developers label May 2, 2026
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.

🤖 Paddle-CI-Agent | pr_review | 2026-05-03 01:24:51

📋 Review 摘要

PR 概述:PR 标题声称新增 test_moe_expert_ffn_wint2 单测,但实际变更仅为 README_EN.md 末尾新增一个空行,未见任何测试文件提交
变更范围README_EN.md
影响面 Tag[Docs]

📝 PR 规范检查

存在以下规范问题:① 标题未使用官方 [Tag] 描述 格式(当前使用了 【】 书名号格式);② PR 描述各 section 内容均为 TODO 占位符,未填写实际信息;③ Checklist 结构与 §D2 模板不符。

标题建议(可直接复制):

  • [Docs] Add trailing newline in README_EN.md

PR 描述建议(可直接复制,必须复刻 checklist §D2 模板的完整结构):

## Motivation`README_EN.md` 末尾补充换行符,修复文件末尾缺少换行的格式问题。

## Modifications
- `README_EN.md`:在文件末尾新增一个空行

## Usage or Command
N/A

## Accuracy Tests
N/A

## 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.

问题

级别 文件 概述
📝 PR 规范 标题未使用 [Tag] 描述 格式,且各描述 section 均为 TODO 占位符
🟡 建议 PR 标题声称新增 test_moe_expert_ffn_wint2 单测,但 diff 仅含 README_EN.md 末尾空行,测试文件未见提交,请确认是否漏提交

总体评价

本次 PR 实际变更仅为 README_EN.md 末尾新增一个空行,与标题所描述的新增单测内容不符;PR 描述各 section 均未填写实际内容,建议作者补全描述,并确认是否漏提交测试文件后再合入。

@PaddlePaddle-bot
Copy link
Copy Markdown

PaddlePaddle-bot commented May 2, 2026

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-05-03 22:01:11

CI报告基于以下代码生成(30分钟更新一次):


1 任务总览

所有 Required 任务均已通过(当前未检测到 Required 任务配置)。有 1 个可选任务失败,7 个工作流等待人工审批。

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
2(0) 2 1 1 0 0 0

⚠️ 注意:以下 7 个 Workflow 处于 action_required 状态(等待审批后才会执行):ILUVATAR-CI、CI_XPU、PR Build and Test、Check PR Template、Approval、Codestyle-Check、CI_HPU。这些 Workflow 需人工审批触发。

注意:action_required workflows 不计入上表的任务统计。


2 任务状态汇总

2.1 Required任务 : 0/0 通过

当前未检测到配置了 Branch Protection Rules 的 Required 任务,GitHub API 未返回 Required 任务列表(可能权限不足或该分支无保护规则)。所有任务均视为可选任务。

2.2 可选任务 — 1/2 通过

可选任务不阻塞合并,失败仅供参考。

状态 任务 耗时 日志 重跑
Trigger Jenkins for PR 49s Job -
其余 1 个可选任务通过 - - -

3 失败详情(仅 required)

无 required 失败任务。

ℹ️ 当前唯一失败任务 Trigger Jenkins for PR(CI_METAX workflow)为可选任务,不阻塞合并,无需深度分析。该 Job 未返回 annotations 信息,可直接查看 Job 日志 了解详情。

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.

🤖 Paddle-CI-Agent | pr_review | 2026-05-03 21:47:17

📋 Review 摘要

PR 概述:为 WINT2 权重量化的 MoE Expert FFN 算子新增单元测试,验证融合算子与分解参考实现的数值一致性。
变更范围tests/operators/test_moe_expert_ffn_wint2.py(新增)
影响面 Tag[OP]

📝 PR 规范检查

PR 标题未使用 [Tag] 描述 标准格式(当前使用 【】 中文书名号,且末尾 [cf] 非官方 Tag);PR 描述各 section 内容均为 TODO 占位符,需补充具体内容。

标题建议(可直接复制):

  • [OP] Add unit test for moe_expert_ffn_wint2 operator

PR 描述建议(可直接复制,必须复刻 checklist §D2 模板的完整结构):

## Motivation
为 WINT2 权重量化的 MoE Expert FFN 算子(`moe_expert_ffn_wint2`)补充单元测试,验证融合算子的输出与分解参考实现(winx_unzip 反量化 + matmul + SwiGLU + matmul)在 BF16/FP16 数据类型及不同 token 分布下的数值一致性。

## Modifications
- 新增 `tests/operators/test_moe_expert_ffn_wint2.py`- `_cutlass_rearrange`:按 CUTLASS WINT2 权重布局重排辅助函数
  - `_build_inputs`:生成随机输入张量(权重、scale、zero-point 等)
  - `_call_op`:调用 `moe_expert_ffn_wint2` 融合算子
  - `_reference_moe_expert_ffn`:基于 `winx_unzip` 的分解参考实现
  - `TestMoeExpertFFNWint2`:包含 BF16、FP16 及非均匀 token 分布三组正确性测试

## Usage or Command
`python -m pytest tests/operators/test_moe_expert_ffn_wint2.py -v`

## Accuracy Tests
N/A(单元测试通过 `np.testing.assert_allclose(rtol=5e-2, atol=5e-2)` 验证融合算子与分解实现的数值一致性,无端到端精度对比数据)

## Checklist

- [x] 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]`, `[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.
- [x] 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.

问题

级别 文件 概述
📝 PR 规范 标题 / 描述 标题未使用官方 Tag 格式;描述各 section 为 TODO 占位符
❓ 疑问 tests/operators/test_moe_expert_ffn_wint2.py:93 _call_op 末尾参数 False 含义未注释,可读性差
🟡 建议 tests/operators/test_moe_expert_ffn_wint2.py:99 _up_weight_raw 仅用于取 E,实际权重数据未使用,属冗余字段
❓ 疑问 tests/operators/test_moe_expert_ffn_wint2.py:124 if end <= start 零 token 分支未被现有测试覆盖

总体评价

测试结构清晰,使用 winx_unzip 分解参考验证融合算子数值正确性的思路合理。建议修复 PR 规范问题并补充零 token 专家测试用例后合入。

inputs["down_proj_local_scale"],
inputs["down_proj_code_scale"],
inputs["down_proj_code_zp"],
False,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❓ 疑问 _call_op 末尾第 14 个位置参数 False 含义未注释,可读性差,读者无法从代码判断该布尔值控制什么行为。

建议添加注释说明:

        False,  # TODO: 说明该参数含义,例如 use_bias=False

或在函数 docstring 中补充各参数说明。


def _reference_moe_expert_ffn(inputs):
"""Decomposed reference: winx_unzip dequant -> matmul -> SwiGLU -> matmul."""
E = inputs["_up_weight_raw"].shape[0]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 _up_weight_raw 在此处仅用于取专家数 E,其实际权重数据在引用实现中并未使用(传给 _winx_unzip_op 的是经过重排的 up_gate_proj_weight)。

建议改为:

E = inputs["up_gate_proj_weight"].shape[0]

并移除 _build_inputs 返回字典中的 _up_weight_raw_down_weight_raw 两个冗余字段,减少误导。

for e in range(E):
start, end = int(starts[e]), int(prefix[e])
if end <= start:
continue
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❓ 疑问 if end <= start: continue 分支(某专家分配 0 个 token)在现有所有测试用例中均未被触发(TOKENS=[4,6,2,4][1,5,3,7] 均无零分配),该分支的正确性未经验证。

建议补充一个覆盖零 token 专家的测试用例,例如:

def test_correctness_zero_token_expert(self):
    """Expert receiving 0 tokens is silently skipped."""
    self._check_output(tokens=[4, 0, 2, 4])

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.

2 participants