Merged
feat(moe_ep_combine): 拆分combine为moe_ep_combine和moe_ep_combine_epilogue #10249
feat(moe_ep_combine): 拆分combine为moe_ep_combine和moe_ep_combine_epilogue #10249
Merged
jvjvzhilianAdd on Aug 18
jvjvzhilian
jvjvzhilianCollaborators
Aug 18

描述

moe_ep_combine(发送阶段):

  • 只保留SendPhaseExpertToToken,发送expert输出到远端rank的HCCL Window
  • 移除combined_x/combined_topk_weights输出,改为无输出
  • kernel entry移除输出GM_ADDR参数

moe_ep_combine_epilogue(接收+归约阶段,新增):

  • 从原始combine kernel提取RecvPhaseReduce/ProcessTopKToken/WaitDispatch/BuffInit
  • 输入: context, topk_idx; 输出: combined_x, combined_topk_weights(optional)
  • 新建op_def/op_api/op_tiling/op_kernel完整工程
  • tiling计算combineStateWinOffset/combineDataWinOffset与combine保持一致

elastic_buffer.cpp:

  • MoeEpCombine改为void(仅发送),MoeEpCombineEpilogue返回tuple(接收+归约)
  • pybind11注册moe_ep_combine_epilogue

elastic_buffer.py:

  • combine()预分配输出后依次调用moe_ep_combine和moe_ep_combine_epilogue

关联的Issue

测试

文档更新

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for jvjvzhilian's contribution.)
jvjvzhilianjvjvzhilianCollaborators
Aug 18 Created pull request, commit a555ce4d
atomgit-bot
atomgit-bot
Aug 18 Comments:

变更摘要

本 PR 将原有 moe_ep_combine 算子拆分为两个独立的算子:moe_ep_combine 仅负责发送阶段(将本卡专家输出 token 发送到远端 rank 的 HCCL Window 缓冲区),新算子 moe_ep_combine_epilogue 负责收包与规约阶段(从 Window 读取专家输出、按 token 累加 topK 结果并写出 combined_x / combined_topk_weights)。拆分后算子边界更清晰,发送与收包规约可分别编译与调度。

主要改动

  • 算子接口拆分:MoeEpCombineGetWorkspaceSize / aclnnMoeEpCombineGetWorkspaceSize 移除 combinedX、combinedTopkWeights 输出参数,同时 moe_ep_combine_def.cpp 删除 combined_x 与 combined_topk_weights 输出定义,改为仅由新算子 MoeEpCombineEpilogue(含 context、topk_idx 输入及 combined_x、combined_topk_weights 输出)承接收包规约。
  • 新增 moe_ep_combine_epilogue 算子全套实现:新增 aclnn_moe_ep_combine_epilogue.cpp(aclnnMoeEpCombineEpilogue、aclnnMoeEpCombineEpilogueGetWorkspaceSize)、moe_ep_combine_epilogue_def.cpp、moe_ep_combine_epilogue_tiling.cpp(含 Window 布局计算与参数/形状/数据类型校验)、moe_ep_combine_epilogue.cpp/.h 内核(MoeEpCombineEpilogue 类,实现 SplitToCore、WaitDispatch、ProcessTopKToken、RecvPhaseReduce 等收包规约逻辑)及对应 tiling.h、tiling_key.h。
  • 内核职责裁剪:moe_ep_combine.h 移除 RecvPhaseReduce、WaitDispatch、ProcessTopKToken、BuffInit、MaskAlign、MaskCheck 等收包阶段实现及相关成员变量/缓冲区,保留发送逻辑 SendPhaseExpertToToken / SendSlot / SendLocalToken,并将双缓冲常量更名为 SEND_DOUBLE_BUFFER_NUM,Process() 仅执行发送阶段。
  • 框架/前端适配:elastic_buffer.cpp 中 MoeEpCombine 返回值改为 void(不再在 C++ 侧分配输出张量),新增 MoeEpCombineEpilogue 返回 CombineEpilogueTensorList 并在 pybind11 注册 moe_ep_combine_epilogue;elastic_buffer.py 在 Python 侧先分配 combined_x / combined_topk_weights,再依次调用 moe_ep_combine 与 moe_ep_combine_epilogue 完成两阶段流程。
  • 规则/路径更新:classify_rule.yaml 将 fused_infer_attention_score 的 kernel 路径从 arch22/arch35 子目录改为平铺路径,并新增 moe_ep_combine_epilogue 的 op_host、op_api、op_kernel 与 CMakeLists.txt 归集规则。
likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 18 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 18 Comments:

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
*/*/op_host/*_def.cpp ✅ 王永光, 俞郑中, 刘丹 (3/2) ✅ 王永光 (1/1)
classify_rule.yaml ✅ 刘丹, 俞郑中 (2/2) ✅ 刘丹, 俞郑中 (2/1)
mc2 ✅ tgwsakiko_, 俞郑中, chenjunjian11, 刘丹 (4/2) ✅ 俞郑中, chenjunjian11, 刘丹 (3/1)
sig-ops-transformer ✅ 俞郑中, 刘丹 (2/2) ✅ 俞郑中, 刘丹 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

l00858142, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robotCollaborators
Aug 18 Set captainmiaow,monologue815,jiang-lirui,Allan_Yu,wang-minbo,tgwsakiko_,tang-lei01,xtqh,liudan12,chenjunjian11,yangzeheng,liuboxi,luobaiqing,libohao6,mabing1118,wangyongguang,macech as approver
136 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Aug 24 Added label: lgtm
wangyongguang
wangyongguangCollaborators
Aug 24 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 24 Added label: approved
CANN-robotCANN-robotCollaborators
Aug 24 Closed associated issue
CANN-robotCANN-robotCollaborators
Aug 24 Merged pull request