Closed
【Feature】:QuantBatchMatmulV3/V4/InplaceAdd/QuantMatmulActivationQuant 缺图级 InferDataType 交付件与 proto 防重定义宏 #7010
lijinghaoAdd on  Oct 21Closed at  Oct 21
lijinghao
lijinghaoCollaborators
Oct 21 Create

【问题描述】

  1. ops-nn 侧 QuantBatchMatmulV3/V4 的 op_graph proto.h 已有 REG_OP 但无 OPS_PROTO_DEF_* 防重定义宏,与 canndev op_proto 头文件同编译单元包含时存在 REG_OP 重定义风险;QuantBatchMatmulInplaceAdd 在 ops-nn 缺整个原型文件。
  2. 图级 InferDataType 交付件缺口:V3 无 InferDataType 注册;InplaceAdd、QuantMatmulActivationQuant 的 InferDataType 挂在 op_host infershape.cpp 的 IMPL_OP_INFERSHAPE 链上,与“infershape 归 op_host、inferdatatype 归 op_graph”目录约定不一致;V4 官方实现(!10929)缺空指针与 dtype 枚举校验,非法 dtype 属性会透传到下游。

【影响】
图模式输出 dtype 推导缺失或不可控;双仓头文件混编时注册冲突;rt1.0 注册隔离(canndev#82596)后 2.0 侧推导路径不完整。

【建议方案】
新增/归一 op_graph/*_graph_infer.cpp 的 InferDataType 注册(含空指针、白名单、swiglu 约束校验);v3/v4 proto.h 补防重定义宏;按 ops_proto_legacy.h 注册体新增 InplaceAdd proto.h;op_host 链上 InferDataType 移除避免双注册。

【关联】
PR:cann/ops-nn#12342;配套 canndev PR:cann/canndev#82596

likedislike
lijinghaolijinghaoCollaborators
Oct 21 changed custom state from 待办的 to 开发中
lijinghaolijinghaoCollaborators
Oct 21 Change title to "【Feature】:QuantBatchMatmulV3/V4/InplaceAdd/QuantMatmulActivationQuant 缺图级 InferDataType 交付件与 proto 防重定义宏", originally titled "【Feature】:QuantBatchMatmulV3/V4 rt1.0 推导/verify 注册未按 TILING_REG_FLAG 隔离,与 2.0 开源仓注册并存".
lijinghaolijinghaoCollaborators
Oct 21 Modify description of issue
lijinghaolijinghaoCollaborators
Oct 21 Associated pull request
lijinghaolijinghaoCollaborators
Oct 21 Deleted associated pull request: inferdatatype和infershape补充rt2.0注册和信息库实现
lijinghaolijinghaoCollaborators
Oct 21 Associated pull request
yuning_chenyuning_chenCollaborators
Oct 21 Assign lijinghao as responsible person
HuangRZzzz
HuangRZzzzCollaborators
Oct 21 Comments:

逐条核对 master(d3ed2375),三项属实:

1)proto 防护缺失:matmul/quant_batch_matmul_v3/op_graph/quant_batch_matmul_v3_proto.h:262、matmul/quant_batch_matmul_v4/op_graph/quant_batch_matmul_v4_proto.h:70 的 REG_OP 外层只有文件级 include guard,无 OPS_PROTO_DEF_*;同仓样例见 matmul/mat_mul_v3/op_graph/mat_mul_proto_extend.h:45-46、matmul/batch_mat_mul_v3/op_graph/batch_mat_mul_proto_extend.h:41-42。InplaceAdd 确缺原型文件:op_graph 下只有 fallback 与 fusion_pass,全仓无 REG_OP(QuantBatchMatmulInplaceAdd)。

2)InferDataType 缺口属实:V3 全目录无实现/注册;InplaceAdd 在 matmul/quant_batch_matmul_inplace_add/op_host/quant_batch_matmul_inplace_add_infershape.cpp:86-98、QuantMatmulActivationQuant 在 matmul/quant_matmul_activation_quant/op_host/quant_matmul_activation_quant_infershape.cpp:334-381。目录约定见 docs/zh/install/dir_structure.md:31;但 op_host 注册 InferDataType 的存量文件仍多(约 343 vs op_graph 168),宜按新交付件规范归一到 op_graph,不宜表述为全仓既有强制约束。

3)V4 校验缺失:op_graph/quant_batch_matmul_v4_graph_infer.cpp:22 未判空即解引用,:23-24 无 dtype 白名单(proto.h:82-83 输出仅 FP16/BF16)直接 SetOutputDataType 且未校验返回值;非法属性透传的下游表现需运行期确认。

落点:新增 op_graph/*_graph_infer.cpp、v3/v4 proto.h 补宏、InplaceAdd 补 proto.h、op_host 链上移除 InferDataType。PR #12342 即该方案,当前 open 未合入;与 canndev ops_proto_legacy.h 同 TU 的重定义验证需 canndev 侧配合,本仓静态无法覆盖。

likedislike
HuangRZzzz
HuangRZzzzCollaborators
Oct 21 Comments:

关联修复 PR:!12342(评审中,未合入 master)。本单转入 PR 跟踪并关闭;PR 合入后即完全闭环,如方案调整可随时重开。

likedislike
HuangRZzzzHuangRZzzzCollaborators
Oct 21 Close issue
CANN-robotCANN-robotCollaborators
19 days ago Added label: resolved
luckdog111luckdog111
16 days ago Associated pull request
luckdog111luckdog111
16 days ago Deleted associated pull request: 更新quant_batch_matmul_inplace_add算子原型定义