Merged
fix(cmake): 补装 a6 适配 py 并统一 a6 源码目录登记 #15323
fix(cmake): 补装 a6 适配 py 并统一 a6 源码目录登记 #15323
Merged
李政君Add on 5 days ago
Total: 6 files changed+8-9
@@ -661,7 +661,7 @@ if (BUILD_OPS_RTY_KERNEL)
661 OPTIONAL661 OPTIONAL
662 )662 )
663 663 
664- foreach (_suffix a2 a3 apt)664+ foreach (_suffix a2 a3 apt a6)
WBartonFang
Wwang-minbo4 days ago

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

likedislike
BartonFangBartonFang4 days ago

【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
665 if(EXISTS ${ASCEND_IMPL_OUT_DIR}/dynamic/${_op_name}_${_suffix}.py)665 if(EXISTS ${ASCEND_IMPL_OUT_DIR}/dynamic/${_op_name}_${_suffix}.py)
666 install(FILES ${ASCEND_IMPL_OUT_DIR}/dynamic/${_op_name}_${_suffix}.py666 install(FILES ${ASCEND_IMPL_OUT_DIR}/dynamic/${_op_name}_${_suffix}.py
667 DESTINATION ${IMPL_DYNAMIC_INSTALL_DIR}667 DESTINATION ${IMPL_DYNAMIC_INSTALL_DIR}
@@ -1086,6 +1086,10 @@ if (NOT ENABLE_AICPU_KERNEL)
1086 DESTINATION ${IMPL_DYNAMIC_INSTALL_DIR}1086 DESTINATION ${IMPL_DYNAMIC_INSTALL_DIR}
1087 OPTIONAL1087 OPTIONAL
1088 )1088 )
1089+ install(FILES ${ASCEND_IMPL_OUT_DIR}/dynamic/${_op_name}_a6.py
luobq
luobqluobq3 days ago

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

likedislike
李政君
3 days ago Comments:
李政君
3 days ago Comments:
1090+ DESTINATION ${IMPL_DYNAMIC_INSTALL_DIR}
1091+ OPTIONAL
1092+ )
1089 endforeach ()1093 endforeach ()
1090 1094 
1091 install(DIRECTORY ${OPS_ADV_UTILS_KERNEL_INC}/1095 install(DIRECTORY ${OPS_ADV_UTILS_KERNEL_INC}/
@@ -964,6 +964,7 @@ function(add_bin_compile_target)
964 set(${_op_name}_a2_dir ${_op_info})964 set(${_op_name}_a2_dir ${_op_info})
965 set(${_op_name}_a3_dir ${_op_info})965 set(${_op_name}_a3_dir ${_op_info})
966 set(${_op_name}_apt_dir ${_op_info})966 set(${_op_name}_apt_dir ${_op_info})
967+ set(${_op_name}_a6_dir ${_op_info})
W
Wwang-minbo4 days ago

这里把 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
967 endforeach()968 endforeach()
968 969 
969 set(_ops_target_list)970 set(_ops_target_list)
@@ -1087,9 +1088,9 @@ function(add_bin_compile_target)
1087 set(_group "1-0")1088 set(_group "1-0")
1088 if (DEFINED ASCEND_OP_NAME AND NOT "${ASCEND_OP_NAME}" STREQUAL "")1089 if (DEFINED ASCEND_OP_NAME AND NOT "${ASCEND_OP_NAME}" STREQUAL "")
1089 if (NOT "${ASCEND_OP_NAME}" STREQUAL "all" AND NOT "${ASCEND_OP_NAME}" STREQUAL "ALL")1090 if (NOT "${ASCEND_OP_NAME}" STREQUAL "all" AND NOT "${ASCEND_OP_NAME}" STREQUAL "ALL")
1090- string(REGEX MATCH "^(.+)_(a2|a3|apt)$" _match_suffix ${op_file})1091+ string(REGEX MATCH "^(.+)_(a2|a3|apt|a6)$" _match_suffix ${op_file})
1091 if(_match_suffix)1092 if(_match_suffix)
1092- string(REGEX REPLACE "_(a2|a3|apt)$" "" _op_file_strip_suffix ${op_file})1093+ string(REGEX REPLACE "_(a2|a3|apt|a6)$" "" _op_file_strip_suffix ${op_file})
1093 list(FIND ASCEND_OP_NAME ${_op_file_strip_suffix} _index)1094 list(FIND ASCEND_OP_NAME ${_op_file_strip_suffix} _index)
1094 else()1095 else()
1095 list(FIND ASCEND_OP_NAME ${op_file} _index)1096 list(FIND ASCEND_OP_NAME ${op_file} _index)
@@ -23,8 +23,6 @@ if (BUILD_OPEN_PROJECT) # custom
23 set(moe_distribute_combine_add_rms_norm_a3_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 mc2/moe_distribute_combine_v2 mc2/moe_distribute_dispatch_v3 mc2/moe_distribute_combine_v3 PARENT_SCOPE)23 set(moe_distribute_combine_add_rms_norm_a3_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 mc2/moe_distribute_combine_v2 mc2/moe_distribute_dispatch_v3 mc2/moe_distribute_combine_v3 PARENT_SCOPE)
24 set(moe_distribute_combine_add_rms_norm_apt_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 mc2/moe_distribute_combine_v2 mc2/moe_distribute_dispatch_v3 mc2/moe_distribute_combine_v3 PARENT_SCOPE)24 set(moe_distribute_combine_add_rms_norm_apt_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 mc2/moe_distribute_combine_v2 mc2/moe_distribute_dispatch_v3 mc2/moe_distribute_combine_v3 PARENT_SCOPE)
25 set(moe_distribute_combine_add_rms_norm_a6_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 mc2/moe_distribute_combine_v2 mc2/moe_distribute_dispatch_v3 mc2/moe_distribute_combine_v3 PARENT_SCOPE)25 set(moe_distribute_combine_add_rms_norm_a6_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 mc2/moe_distribute_combine_v2 mc2/moe_distribute_dispatch_v3 mc2/moe_distribute_combine_v3 PARENT_SCOPE)
26- # 为 _a6 opFile 提供源码目录(等价于 func.cmake 里硬编码的 _a2/_a3/_apt_dir 白名单),避免改共享 func.cmake
27- set(moe_distribute_combine_add_rms_norm_a6_dir ${CMAKE_CURRENT_SOURCE_DIR}/.. PARENT_SCOPE)
28 install(26 install(
29 DIRECTORY27 DIRECTORY
30 ${OPS_ADV_DIR}/mc2/3rd/rms_norm28 ${OPS_ADV_DIR}/mc2/3rd/rms_norm
@@ -24,8 +24,6 @@ if (BUILD_OPEN_PROJECT) # custom
24 set(moe_distribute_dispatch_v2_a2_depends mc2/common mc2/3rd PARENT_SCOPE)24 set(moe_distribute_dispatch_v2_a2_depends mc2/common mc2/3rd PARENT_SCOPE)
25 set(moe_distribute_dispatch_v2_apt_depends mc2/common mc2/3rd PARENT_SCOPE)25 set(moe_distribute_dispatch_v2_apt_depends mc2/common mc2/3rd PARENT_SCOPE)
26 set(moe_distribute_dispatch_v2_a6_depends mc2/common mc2/3rd PARENT_SCOPE)26 set(moe_distribute_dispatch_v2_a6_depends mc2/common mc2/3rd PARENT_SCOPE)
27- get_filename_component(_dispatch_v2_a6_dir "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE)
28- set(moe_distribute_dispatch_v2_a6_dir "${_dispatch_v2_a6_dir}" PARENT_SCOPE)
29 27 
30 # --cce-auto-sync=off:指定CCE编译器是否自动执行线程间或模块间的同步操作28 # --cce-auto-sync=off:指定CCE编译器是否自动执行线程间或模块间的同步操作
31 add_ops_compile_options(29 add_ops_compile_options(
@@ -23,8 +23,6 @@ if (BUILD_OPEN_PROJECT) # custom
23 set(moe_distribute_dispatch_v3_a3_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 PARENT_SCOPE)23 set(moe_distribute_dispatch_v3_a3_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 PARENT_SCOPE)
24 set(moe_distribute_dispatch_v3_apt_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 PARENT_SCOPE)24 set(moe_distribute_dispatch_v3_apt_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 PARENT_SCOPE)
25 set(moe_distribute_dispatch_v3_a6_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 PARENT_SCOPE)25 set(moe_distribute_dispatch_v3_a6_depends mc2/common mc2/3rd mc2/moe_distribute_dispatch_v2 PARENT_SCOPE)
26- get_filename_component(_dispatch_v3_a6_dir "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE)
27- set(moe_distribute_dispatch_v3_a6_dir "${_dispatch_v3_a6_dir}" PARENT_SCOPE)
28 26 
29 # --cce-auto-sync=off:指定CCE编译器是否自动执行线程间或模块间的同步操作27 # --cce-auto-sync=off:指定CCE编译器是否自动执行线程间或模块间的同步操作
30 add_ops_compile_options(28 add_ops_compile_options(