Closed
【cleancode】matmulallreduce cleancode整改 #8636
Simple_Bright&ManAdd on  4 days agoClosed at  3 days ago
Simple_Bright&Man
Simple_Bright&Man
4 days ago Create

文件 告警函数(行数 / 圈复杂度)
op_kernel/arch22/matmul_all_reduce.cpp quant_matmul_allreduce(81 行 / CC 49)、weight_quant_matmul_allreduce(58 行 / CC 64)
op_kernel/arch22/matmul_all_reduce_dequant_perchannel.h Process(87 行)、MatmulAllReduceDequantPerchannelCommInt8(81 行)
op_kernel/arch22/matmul_all_reduce_quant_perchannel.h Process(78 行)、MatmulAllReduceQuantPerchannelCommInt8(81 行)
op_kernel/arch22/matmul_all_reduce_quant_pertoken_comm_int8_arch22.h InnerProcess(51 行)
op_kernel/arch22/matmul_all_reduce_quant_reduce_sum.h Process(80 行)、MatmulAllReduceReduceSumInt8(54 行)
op_kernel/arch31/matmul_all_reduce.cpp matmul_all_reduce(230 行 / CC 145)

mc2/all_gather_matmul、mc2/all_gather_matmul_v2 略

likedislike
Simple_Bright&ManSimple_Bright&Man
4 days ago Associated pull request
周云飞
周云飞Collaborators
4 days ago Comments:

这些告警可以作为 MatmulAllReduce 代码可读性和维护性的优化线索,但函数行数或圈复杂度较高本身不代表功能错误。

可以考虑分别梳理 arch22 的量化处理函数和 arch31 的 matmul_all_reduce,按职责拆分较长的处理流程,并评估拆分对分支行为、计算结果和性能的影响;也可以保留有必要的复杂分支,避免为降低指标而增加理解成本。具体拆分范围仍需结合相关实现确认。

likedislike
周云飞周云飞Collaborators
4 days ago Assign SimpleBright_Man as responsible person
Simple_Bright&ManSimple_Bright&Man
3 days ago Modify description of issue
Simple_Bright&ManSimple_Bright&Man
3 days ago Associated pull request
CANN-robotCANN-robotCollaborators
3 days ago Close issue
周云飞
周云飞Collaborators
3 days ago Comments:

已针对 matmul_all_reduce 的 CleanCode 告警进行重构:拆分量化及权重量化的分支分发逻辑,并将反量化 scale 加载、乘法计算和 UB 大小计算提取为辅助函数,以降低函数长度和复杂度。

PR 描述中记录 A2/A3 RDV 通过,A5 编译通过。

关联 PR:PR #17068、PR #17214

likedislike
CANN-robotCANN-robotCollaborators
3 days ago Added label: resolved