Pull Request已成功合入, 合并人@CANN-robot
(感谢 景明 的贡献)变更摘要
本 PR 在 mc2/common/torch_extension 中新增 MoonEP(冗余专家均衡)适配包装 MoonEPElasticBuffer,以组合 ElasticBuffer 的方式复用 ep 四件套 kernel(moe_ep_dispatch/epilogue/combine/combine_epilogue),不改动任何 kernel。包装固化了两个已验证的关键语义:一是把 plan 输出的虚拟专家 id 直通扩充空间 E' = 2E,使 ep 的 home(v) 推导自动正确;二是因 ep 的 combine 为纯求和,改由包装层对专家输出按 recv_topk_weights 预乘实现加权,再走标准 combine 回收。__init__.py 同步导出新类。
主要改动
- 新增
MoonEPElasticBuffer包装类: 在mc2/common/torch_extension/moonep_buffer.py中新增该类,__init__校验num_experts为正且为 world size 的整数倍,并在num_experts语义上保留 MoonEP 原始专家数E,内部组合一个ElasticBuffer。 dispatch自动扩充虚拟专家空间:dispatch对一维vtopk自动reshape为[num_tokens, num_topk],并以num_experts=2 * self._num_experts、expert_alignment=1、do_cpu_sync=False调用底层dispatch,返回recv_x、与recv_x行序一致的recv_topk_weights及EPHandle。combine_weighted实现加权回收: 先按num_recv_tokens(handle)的有效行数构造权重向量并对专家输出main预乘recv_topk_weights(fp8 的(main, scales)场景仅预乘main、scales透传),再调用底层combine得到combined_x[t] = Σ_k w·x。combine_sum与combine_transpose支持反向:combine_sum走 ep 原生纯 sum 语义用于grad_x;combine_transpose通过 ep 的topk_weights透传通道把份级标量发回 home 的combined_topk_weights[t, k],用于grad_w。- 导出新包装类:
mc2/common/torch_extension/__init__.py的__all__增加MoonEPElasticBuffer并新增对应from .moonep_buffer import MoonEPElasticBuffer导入。
🧩 本次 Review 已使用自定义 Skill:


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| docs | ✅ 刘丹, 蒋礼锐 (2/2) | ✅ 刘丹, 蒋礼锐 (2/1) |
| scripts | ✅ 刘丹, 蒋礼锐 (2/2) | ✅ 刘丹, 蒋礼锐 (2/1) |
| sig-ops-transformer | ✅ 刘丹, 蒋礼锐 (2/2) | ✅ 刘丹, 蒋礼锐 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
gitcode_lijd, thanks for your pull request. All authors of the commits have signed the CLA. 👍


The MR can not be merged, because of CodeReview discussion not resolved
If you want to solve this problem, you can click here to do it in the FAQs.


关联Issue https://gitcode.com/cann/ops-transformer/issues/6573
描述
🔧 配置变更
按社区统一接入方式(issue #6573,chenyx_2012)切换:OAT 合规检查由「仓内自维护 oat_check.sh + repo: local」切换为「HiAgent/compliance 远程 Python hook」,业务仓不再维护 OAT 脚本,OAT 版本由 rev 标签(v1.0.6)统一管控。
改动(3 文件)
.pre-commit-config.yaml:repo: local的 oat-check 块替换为repo: https://gitcode.com/HiAgent/compliance, rev: v1.0.6(id: oat-check,pass_filenames/stages/verbose 与原配置一致)scripts/oat_check.sh(本地脚本退役).gitignore补oat_reports/(远程 hook 报告目录)行为等价性评估(已读 compliance v1.0.6 源码)
本地脚本的全部修复点均由远程 hook 覆盖,且架构更优:
report_file.is_file()守卫:无报告且 RC!=0 → return 1 阻断 ✅_cleanup_stale_run_state清理同 HEAD 残留 ✅_resolve_oat_xml读仓根 OAT.xml ✅测试
pre-commit run oat-check实测通过(hook 环境自动克隆 compliance 仓并安装 OAT)pre_commit_reports/oat_result.txt→oat_reports/result.txt(已 gitignore)类型标签