Merged
fix(cmake): 补装 a6 适配 py 并统一 a6 源码目录登记 #15323
fix(cmake): 补装 a6 适配 py 并统一 a6 源码目录登记 #15323
Merged
李政君Add on 4 days ago
李政君Collaborators
4 days ago

背景

线上回黄(BUILD_OPS_RTY_KERNEL)编出的 ascend960dt 包中缺少 moe_distribute_dispatch_v2_a6.py 等 A6 适配 py。

排查确认:py 已由 generate_transformer_adapt_py 生成到 build/impl/dynamic/,但两条打包路径的 install 白名单只包含 .py / _a2 / _a3 / _apt,_a6.py 在安装阶段被丢弃。

修改内容

  1. CMakeLists.txt:回黄路径的安装后缀列表增加 a6。
  2. cmake/custom_build.cmake:custom 路径补装 <op>_a6.py。
  3. cmake/func.cmake:add_bin_compile_target 统一登记 <op>_a6_dir,避免各算子手工 set(... PARENT_SCOPE)。
  4. 移除 moe_distribute_dispatch_v2 / moe_distribute_dispatch_v3 / moe_distribute_combine_add_rms_norm 中重复的 _a6_dir 定义。

验证

  • 保留各算子的 un-suffixed _depends,host 侧符号链接与依赖 kernel 头文件安装行为不变。
  • --pkg --soc=ascend960dt 后,build/impl/dynamic/ 与安装树 dynamic/ 均出现 moe_distribute_dispatch_v2_a6.py。
  • 其余 SoC(910b / 910_93 / 950)无行为变化。

影响范围

仅影响 A6(ascend960dt / ascend960pr)适配 py 的安装。

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 李政君's contribution.)
李李政君Collaborators
4 days ago Created pull request, commit 7023d401
atomgit-bot
atomgit-bot
4 days ago Comments:

变更摘要

本 PR 修复线上回黄(BUILD_OPS_RTY_KERNEL)编出的 ascend960dt 包中缺失 A6 适配 py(如 moe_distribute_dispatch_v2_a6.py)的问题。A6 适配 py 已由 generate_transformer_adapt_py 生成到 build/impl/dynamic/,但打包 install 白名单只覆盖 .py、_a2、_a3、_apt,导致 _a6.py 在安装阶段被丢弃。改动围绕两条打包路径补齐 a6 后缀安装,并在构建框架层面统一 A6 源码目录登记方式,整体仅影响 A6(ascend960dt / ascend960pr)适配 py 的安装,其余 SoC 行为不变。

主要改动

  • custom 路径补装 _a6.py:cmake/custom_build.cmake 在算子动态文件安装循环中新增对 ${ASCEND_IMPL_OUT_DIR}/dynamic/${_op_name}_a6.py 的 install(FILES ...) 条目(OPTIONAL),使自定义构建路径也能将 A6 适配 py 安装到 ${IMPL_DYNAMIC_INSTALL_DIR}。
  • 统一登记 <op>_a6_dir:cmake/func.cmake 的 add_bin_compile_target 中,在原有 _a2_dir、_a3_dir、_apt_dir 之外增加 set(${_op_name}_a6_dir ${_op_info}),由框架统一写入 A6 源码目录变量,避免各算子手工 set(... PARENT_SCOPE)。
  • 回黄路径安装后缀增加 a6:按 PR 描述,CMakeLists.txt 中回黄路径的安装后缀白名单加入 a6,使该路径同样保留 _a6.py。
  • 清理重复定义:按 PR 描述,移除 moe_distribute_dispatch_v2、moe_distribute_dispatch_v3、moe_distribute_combine_add_rms_norm 中重复的 _a6_dir 定义,改由上述统一登记逻辑提供;保留各算子未加后缀的 _depends,host 侧符号链接与依赖 kernel 头文件安装行为不变。

🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
4 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
4 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
CMakeLists.txt ✅ wang-minbo, 蒋礼锐 (2/2) ✅ wang-minbo, 蒋礼锐 (2/1)
cmake ✅ wang-minbo, 蒋礼锐 (2/2) ✅ 蒋礼锐, wang-minbo (2/1)
mc2 ✅ 蒋礼锐, luobaiqing, wang-minbo (3/2) ✅ wang-minbo, 蒋礼锐, luobaiqing (3/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
李政君Collaborators
4 days ago Comments:

compile

likedislike
李李政君Collaborators
4 days ago Pre merge succeeded (commit_id: 416f8e5c0194c12e78e99e011f6faeefccba1256)
CANN-robotCANN-robotCollaborators
4 days ago Set zzg_code,monologue815,zhu-mingzhe71,jiang-lirui,Allan_Yu,yayahello,wang-minbo,tgwsakiko_,xtqh,liudan12,chenjunjian11,yangzeheng,liuboxi,ryan_li,luobaiqing,zhong-zixin,gaoxiang618,mabing1118,dingwei002,macech,chuguowei,huangshuai59,adamlwang,zzzzzzyf_ as approver
CANN-robotCANN-robotCollaborators
4 days ago Set zzg_code,monologue815,zhu-mingzhe71,jiang-lirui,Allan_Yu,yayahello,wang-minbo,tgwsakiko_,xtqh,liudan12,chenjunjian11,yangzeheng,liuboxi,ryan_li,luobaiqing,zhong-zixin,gaoxiang618,mabing1118,dingwei002,macech,chuguowei,huangshuai59,adamlwang,zzzzzzyf_ as approver
CANN-robot
CANN-robotCollaborators
4 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
4 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
4 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
4 days ago Added label: ci-pipeline-passed
wang-minboCollaborators3 days agoStart code review1
cmake/func.cmake
@@ -964,6 +964,7 @@ function(add_bin_compile_target)
964964 set(${_op_name}_a2_dir ${_op_info})
965965 set(${_op_name}_a3_dir ${_op_info})
966966 set(${_op_name}_apt_dir ${_op_info})
967+ set(${_op_name}_a6_dir ${_op_info})
wang-minbo3 days agoComments:

这里把 a6 和 a2/a3/apt 平级登记了,不过同函数里 ASCEND_OP_NAME 那段后缀剥离正则还是 _(a2|a3|apt)$,不认 a6——分片构建传 ASCEND_OP_NAME=,3-1 这种时,a2/a3/apt 变体能跟着组号分核编译,a6 匹配不上就回落默认组 1-0,每个分片 worker 都会全量编 a6,重复编译不说还可能并发写同一个 kernel 输出目录,把 a6 一并补进 MATCH/REPLACE 那两处正则呗

likedislike
wang-minboCollaborators3 days agoStart code review1
CMakeLists.txt
@@ -662,3 +662,3 @@
662662 )
663663 
664- foreach (_suffix a2 a3 apt)
664+ foreach (_suffix a2 a3 apt a6)
wang-minbo3 days agoComments:

验证一节写的还是「预期」——这个问题的现象就是安装树里丢文件,最直接的就是真跑一次 --pkg --soc=ascend960dt,确认安装树 dynamic/ 下 moe_distribute_dispatch_v2_a6.py 真的落盘了,比「预期」踏实

likedislike
李李政君Collaborators
3 days ago Pre merge succeeded (commit_id: 183195c69399b2ff43371a3265079e1d9d5c3e25)
李李政君Collaborators
3 days ago Force-pushed 1 commits:5a28b744-fix(cmake): 补装 a6 适配 py 并统一 a6 源码目录登记
李李政君Collaborators
3 days ago Pre merge succeeded (commit_id: 1fe29c4dcb57e47d00ac92a331641ac248c956db)
CANN-robotCANN-robotCollaborators
3 days ago Removed label: cann-cla/yes
CANN-robotCANN-robotCollaborators
3 days ago Removed label: ci-pipeline-passed
CANN-robot
CANN-robotCollaborators
3 days ago Comments:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
CANN-robotCANN-robotCollaborators
3 days ago Added label: cann-cla/yes
BartonFang
BartonFangCollaborators3 days agoStart code review1
CMakeLists.txt
@@ -662,3 +662,3 @@
662662 )
663663 
664- foreach (_suffix a2 a3 apt)
664+ foreach (_suffix a2 a3 apt a6)
BartonFang
BartonFang3 days agoComments:

【review】
问题分类:正确性
位置:CMakeLists.txt:664,代码:foreach (_suffix a2 a3 apt a6)
问题:在 BUILD_OPS_RTY_KERNEL=ON 的干净构建目录中,新增 a6 后缀仍受下一行 if(EXISTS ...) 的配置期检查控制。适配文件由第638行 generate_transformer_adapt_py 构建目标运行后才生成,首次配置时 dynamic/<算子名>_a6.py 尚不存在,因此不会生成对应 install(FILES ...) 规则;后续生成文件并执行安装不会重新执行这个条件。custom_build.cmake 中本次新增的 a6 安装规则没有此配置期条件,两条构建路径行为不一致。
可能导致的结果:完成首次构建后直接安装时,安装树仍缺失 a6 适配 py 文件,必须再次配置才可能补装,本次针对 a6 漏装的修复在该路径的干净构建中仍不生效。
建议的修改方法:去掉该循环内配置期的 if(EXISTS ...) 条件,对各后缀始终登记已有 OPTIONAL 的 install(FILES ...) 规则,让安装阶段判断文件是否存在;补一次“干净配置、构建适配文件、安装且不二次配置”的检查,确认 a6 文件落盘。

likedislike
李李政君Collaborators
3 days ago Resolved final issue
李李政君Collaborators
3 days ago Modify description of pull request
李政君Collaborators
3 days ago Comments:

compile

likedislike
李李政君Collaborators
3 days ago Pre merge succeeded (commit_id: d35e91fd96cb4fce7f588248cc76a3fd02870570)
CANN-robot
CANN-robotCollaborators
3 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
3 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
3 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
3 days ago Added label: ci-pipeline-passed
luobq
luobqCollaborators2 days agoStart code review3
cmake/custom_build.cmake
@@ -1086,6 +1086,10 @@ if (NOT ENABLE_AICPU_KERNEL)
10861086 DESTINATION ${IMPL_DYNAMIC_INSTALL_DIR}
10871087 OPTIONAL
10881088 )
1089+ install(FILES ${ASCEND_IMPL_OUT_DIR}/dynamic/${_op_name}_a6.py
luobq
luobq2 days agoComments:

a系列放在一起呗,上面也是,a2 a3 a6 apt。不过为什么没有a5,apt是a5的指代吗,如果是那现在这个顺序倒是没问题,但是引出另一个问题,a6是一个对外的合适的后缀吗?

likedislike
李政君Collaborators
2 days ago Comments:

合适的。a5比较特殊,问了说是历史原因

李政君Collaborators
2 days ago Comments:

apt是a5

李李政君Collaborators
2 days ago Resolved final issue
luobq
luobqCollaborators
2 days ago Comments:

/approve

likedislike
wang-minboCollaborators
2 days ago Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
2 days ago Added label: approved
jiang-liruiCollaborators
1 day ago Comments:

/approve
/lgtm

likedislike
CANN-robotCANN-robotCollaborators
1 day ago Added label: lgtm
CANN-robotCANN-robotCollaborators
1 day ago Merged pull request