Merged
refactor(moe_gating_top_k): hash模式拆分为独立kernel模板MoeGatingTopKHashRegbase #15062
refactor(moe_gating_top_k): hash模式拆分为独立kernel模板MoeGatingTopKHashRegbase #15062
Merged
CPZhouAdd on 9 days ago
CPZhou
CPZhouCollaborators
9 days ago

描述

hash 模式与 group-normal TopK 路径此前耦合在同一个 kernel 模板 MoeGatingTopKRegbase 中(原因详见关联 Issue)。本 PR 将 hash 模式拆分为独立 kernel 模板:

  • 新增 op_kernel/arch35/moe_gating_top_k_hash_regbase.h:MoeGatingTopKHashRegbase<T, IDXT, EIDXT>,继承精简后的 MoeGatingTopKRegbase<T>,复用输入拷贝 / 归一化 / CopyOut 公共通路,新增 inputIds / tid2eid 哈希查表专属逻辑;
  • 精简 op_kernel/arch35/moe_gating_top_k_regbase.h:移除 hash 相关分支与仅 hash 路径使用的模板参数,仅保留 group-normal TopK 路径;
  • op_kernel/moe_gating_top_k_apt.cpp:TILING_KEY_HASH_* 4 种 tiling key(int32/int32、int32/int64、int64/int64、int64/int32)全部改为实例化 MoeGatingTopKHashRegbase,TILING_KEY_REGBASE 保持 MoeGatingTopKRegbase 不变。

关联的Issue

关联Issue #7201

测试

TTK kernel 模式真机(Ascend950DT)动态编译执行 + golden 精度比对(用例取自 moe/moe_gating_top_k/tests/st/arch35/moe_gating_top_k.csv,golden 插件 moe/moe_gating_top_k/tests/assets/golden.py):

  • 全量 138 条用例:138 PASS / 0 FAIL(100%);
  • hash 模式 17 条:覆盖 inputIds/tid2eid 四种 dtype 组合、对齐/非对齐 expert 数、softmax/sigmoid/softplus 归一化、renorm、无 bias、out_flag、fp16/bf16/fp32、k=1/8/64、8192 行大 shape,全部通过;
  • 非 hash 用例 121 条:覆盖 group-normal(regbase)、without_group、e_k_fullload 各 tiling 路径及大 K / vms 奇偶等边界,全部通过,确认基类精简未引入回归;
  • hash 用例更换随机种子复跑:17/17 通过,结果稳定。

文档更新

无

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for CPZhou's contribution.)
CPZhouCPZhouCollaborators
9 days ago Created pull request, commit 20ab041f
CANN-robotCANN-robotCollaborators
9 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
9 days ago 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
moe ✅ cpy_123456, guoqiuhao (2/2) ✅ cpy_123456 (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
9 days ago Set cpy_123456,cheng_zhiwei,juyangokok,monologue815,chen-linxin4,yu-xinjie62,jiang-lirui,Allan_Yu,songkai111,liudan12,Wei_NaChuan,cc-z,kdy18482276080,xuchengyang,mabing1118,guoqiuhao,Julius47 as approver
CANN-robotCANN-robotCollaborators
9 days ago Set cpy_123456,cheng_zhiwei,juyangokok,monologue815,chen-linxin4,yu-xinjie62,jiang-lirui,Allan_Yu,songkai111,liudan12,Wei_NaChuan,cc-z,kdy18482276080,xuchengyang,mabing1118,guoqiuhao,Julius47 as approver
CPZhou
CPZhouCollaborators
9 days ago Comments:

/compile

likedislike
CPZhouCPZhouCollaborators
9 days ago Pre merge succeeded (commit_id: 554b3cc8c066e051ee2c1db9124eeff08408d9f3)
CANN-robot
CANN-robotCollaborators
9 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
9 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
9 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
9 days ago Added label: ci-pipeline-passed
CPZhou
CPZhouCollaborators
3 days ago Comments:

/compile

likedislike
CPZhouCPZhouCollaborators
3 days ago Pre merge succeeded (commit_id: 26dd8584843c95f422bf05b0b1b317b0aa2a351b)
CANN-robot
CANN-robotCollaborators
3 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
3 days ago Removed label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
3 days ago Added label: ci-pipeline-running
CPZhouCPZhouCollaborators
3 days ago Modify description of pull request
CANN-robotCANN-robotCollaborators
3 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
3 days ago Added label: ci-pipeline-passed
CPZhouCPZhouCollaborators
3 days ago Modify description of pull request
GuoqhCollaborators
3 days ago Comments:

/lgtm

likedislike
CPZhouCPZhouCollaborators
3 days ago Set as a draft.
CPZhouCPZhouCollaborators
3 days ago Draft state has been cancelled
cpy_123456Collaborators
3 days ago Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
3 days ago Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
3 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
3 days ago Merged pull request