Merged
refactor: chunk_gated_delta_rule 拆分架构目录,支持 ascend950 #8318
refactor: chunk_gated_delta_rule 拆分架构目录,支持 ascend950 #8318
Merged
huang-chuhongAdd on Jul 6
huang-chuhong
huang-chuhongCollaborators
Jul 6

描述

chunk_gated_delta_rule 算子原有 kernel 头文件按 stage 划分,不区分芯片架构,无法支持 ascend950 的差异化实现。本 PR 将 kernel 头文件按架构拆分到 arch22/ 和 arch35/ 目录,并为 ascend950 新增专用 kernel 入口文件和算子配置。

改动

  • 将原有共享头文件(chunk_gated_delta_rule.h、stage1.h、stage2.h、stage3.h、utils.h)移入 arch22/ 目录,保持 910b 逻辑不变
  • 新增 arch35/ 目录下的同名头文件,适配 ascend950 架构
  • 新增 chunk_gated_delta_rule_apt.cpp 作为 ascend950 的 kernel 入口
  • chunk_gated_delta_rule.cpp 的 include 路径改为 arch22/ 子目录
  • chunk_gated_delta_rule_def.cpp 新增 ascend950 算子配置,指定 opFile 为 chunk_gated_delta_rule_apt

关联的Issue

#3614

测试

  • ascend910b 原有行为不受影响(include 路径变更但内容一致)
  • ascend950 新增配置与 kernel 入口待 CI 编译验证

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for huang-chuhong's contribution.)
huang-chuhonghuang-chuhongCollaborators
Jul 6 Created pull request, commit f3803ccc
CANN-robotCANN-robotCollaborators
Jul 6 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Jul 6 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


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 ✅ 汤磊, 蒋礼锐 (2/2) ✅ 汤磊 (1/1)
attention ✅ 蒋礼锐, zzy__ (2/2) ✅ 蒋礼锐, zzy__ (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Jul 6 Set hz36amy_00,juyangokok,monologue815,xuanyuandy,crystalhu,yu-xinjie62,huangwei791,jiang-lirui,yang-binrong,Allan_Yu,liudan12,huang_li,wangzhe123456789,cc-z,shen_weiling,gaoxiang618,songjionghui,wenxin_fight,miaofangzheng,mabing1118,tang-hao-hw-gitcode,wangyongguang,haijie_699874,zzy__,yuhao_,L_Euler as approver
CANN-robotCANN-robotCollaborators
Jul 6 Set hz36amy_00,juyangokok,monologue815,xuanyuandy,crystalhu,yu-xinjie62,huangwei791,jiang-lirui,yang-binrong,Allan_Yu,liudan12,huang_li,wangzhe123456789,cc-z,shen_weiling,gaoxiang618,songjionghui,wenxin_fight,miaofangzheng,mabing1118,tang-hao-hw-gitcode,wangyongguang,haijie_699874,zzy__,yuhao_,L_Euler as approver
huang-chuhonghuang-chuhongCollaborators
Jul 6 Modify description of pull request
huang-chuhong
huang-chuhongCollaborators
Jul 6 Comments:

compile

likedislike
huang-chuhonghuang-chuhongCollaborators
Jul 6 Pre merge succeeded (commit_id: 901e65acb2e4867f065328de8b36c73927d95a35)
huang-chuhong
huang-chuhongCollaborators
Jul 6 Comments:

compile

likedislike
huang-chuhonghuang-chuhongCollaborators
Jul 6 Pre merge succeeded (commit_id: a079e23f01111026276973b9569e72826fcf6feb)
CANN-robotCANN-robotCollaborators
Jul 6 Added label: ci-pipeline-running
CANN-robot
CANN-robotCollaborators
Jul 6 Comments:

流水线任务触发成功
任务链接 [a14b8365999744b9991968f303b57d6d][流水线指导]

任务名称状态日志下载链接

[2026-07-06 17:30:37]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Jul 6 Comments:

流水线任务触发成功
任务链接 [4d7ea9cedff64964987f74e7a9c292bc][流水线指导]

任务名称状态日志下载链接

[2026-07-06 17:30:38]    CI执行结束

likedislike
CANN-robotCANN-robotCollaborators
Jul 6 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Jul 6 Added label: ci-pipeline-running
CANN-robot
CANN-robotCollaborators
Jul 6 Comments:

流水线任务触发成功
任务链接 [188594808d1a41f3bff28fe0ffad8881][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Pre ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_classify ✅ SUCCESS >>>>>
Compile_harmony-infer-chs-transformer ✅ SUCCESS >>>>>
UT_Test ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ⚠️ WARNING >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
UT_Test_report_lcov ⚠️ WARNING >>>>>

[2026-07-06 17:49:04]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Jul 6 Comments:

流水线任务触发成功
任务链接 [b27f0fafc30649998257a414c9634e53][流水线指导]

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_style ✅ SUCCESS >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_checkpr ✅ SUCCESS
codecheck_precommit ⚠️ WARNING >>>>> >>>>>

[2026-07-06 17:34:20]    CI执行结束

likedislike
CANN-robotCANN-robotCollaborators
Jul 6 Added label: api-check-failed
CANN-robotCANN-robotCollaborators
Jul 6 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Jul 6 Added label: ci-pipeline-passed
atomgit-bot
atomgit-bot
Jul 6 Comments:

变更摘要

此 PR 对 chunk_gated_delta_rule 算子进行架构目录拆分重构,将原本按 stage 划分的共享 kernel 头文件按芯片架构分离到 arch22/(ascend910b)和 arch35/(ascend950)两个子目录,并为 ascend950 新增专用 kernel 入口文件与算子配置,使不同架构可以独立演进差异化实现。

主要改动

  • 架构目录拆分:将原有 5 个头文件(chunk_gated_delta_rule.h、chunk_gated_delta_rule_stage1.h、chunk_gated_delta_rule_stage2.h、chunk_gated_delta_rule_stage3.h、chunk_gated_delta_rule_utils.h)移入 op_kernel/arch22/ 目录,内部 #include 路径统一改为 ../chunk_gated_delta_rule_tiling_data.h,保持 ascend910b 原有行为不变。

  • 新增 arch35 架构实现:在 op_kernel/arch35/ 下新增 5 个同名头文件,提供适配 ascend950 的完整实现。其中 Stage1 采用 AIC/AIV 混合并行架构(KERNEL_TYPE_MIX_AIC_1_2),通过 Broadcast+Mul+Exp 实现 Gamma 计算、自定义 InverseAIV 实现对角块求逆等差异化逻辑;Stage2 和 Stage3 同样基于 AIC/AIV 协同模式,与 arch22 的实现结构有明显差异。

  • 新增 ascend950 kernel 入口:新增 chunk_gated_delta_rule_apt.cpp,通过 #include "arch35/chunk_gated_delta_rule.h" 引入 arch35 实现,注册 kernel 函数并采用 KERNEL_TYPE_MIX_AIC_1_2 任务类型,模板实例化为 CGDR<bfloat16_t, float>。

  • 算子配置注册 ascend950:在 chunk_gated_delta_rule_def.cpp 中新增 OpAICoreConfig config_950,设置动态编译/格式/秩/形状支持,并通过 ExtendCfgInfo("opFile.value", "chunk_gated_delta_rule_apt") 指定 ascend950 使用 chunk_gated_delta_rule_apt 作为 opFile。

  • 已有入口路径更新:chunk_gated_delta_rule.cpp 的 include 从 "chunk_gated_delta_rule.h" 改为 "arch22/chunk_gated_delta_rule.h",使 ascend910b/910_93 继续使用 arch22 实现。

likedislike
Incorrect?
tang-lei01
tang-lei01Collaborators
Jul 6 Comments:

/approve

likedislike
jiang-lirui
jiang-liruiCollaborators
Jul 7 Comments:

/approve
/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Jul 7 Added label: approved
赵志勇
赵志勇Collaborators
Jul 7 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Jul 7 Added label: lgtm
CANN-robotCANN-robotCollaborators
Jul 7 Closed associated issue
CANN-robotCANN-robotCollaborators
Jul 7 Merged pull request