已合并
fix(matmul): 修复量化 MatMul shape 报错缺少方括号(master) #11033
fix(matmul): 修复量化 MatMul shape 报错缺少方括号(master) #11033
已合并
Hu1L1创建于 9月22日
Hu1L1
Hu1L1成员
9月22日

描述

修复 QBMMv3、QBMMIA 和 QuantMatmulActivationQuant 在 shape 校验失败时,错误信息中的实际 shape 缺少方括号的问题。例如实际 shape 为 [16] 时,错误信息由 incorrect shape 16 改为 incorrect shape [16]。

  • QBMMv3:为一维 bias 和 x1Scale/x2Scale 的 4 处 shape 上报补上方括号。
  • QBMMIA:9 处 shape 上报直接使用 op::ToString(shape).GetString() 保留完整 shape。
  • QuantMatmulActivationQuant:8 处 shape 上报同样保留完整 shape,覆盖 x1/x2、scale 和输出校验。
  • 删除公共头文件 matmul/common/op_host/log_format_util.h 中的 StripEnclosingSquareBrackets(),清理全部调用和 using 声明。

改动涉及 API 日志格式及公共日志工具清理。校验条件、返回值和计算逻辑保持不变,QBMMv4 tiling 不在本次修改范围内。

目标分支:master。

关联的Issue

关联并修复 #6129。

测试

  • 本地使用 pre-commit 4.3.0 对完整 PR 的 6 个文件执行 pre-commit run --show-diff-on-failure --files ...,所有适用检查通过(退出码 0)。
  • clang-format 18.1.8 已修正 QuantMatmulActivationQuant 的 6 处参数换行,复检通过;这次格式修复没有改变代码 token 或日志字符串。
  • OAT 实际扫描 6 个文件通过;复检按脚本规则复用该结果。
  • git diff --check 通过。
  • 已静态复核两个分支的补丁一致,完整 PR 涉及 6 个文件、21 处 shape 日志及公共函数和无用 using 清理。
  • 全仓搜索确认 StripEnclosingSquareBrackets 已无定义或引用。
  • 已复核 shape 字符串在日志宏内复制到 std::string 的生命周期。
  • 本次改动未执行算子编译、UT 或设备测试。

文档更新

无。

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Hu1L1 的贡献)
Hu1L1Hu1L1成员
9月22日 创建了 pull request,commit bde510cb
atomgit-bot
atomgit-bot
9月22日 评论:

变更摘要

本 PR 针对 QuantBatchMatMulV3 在一维 bias 的 shape 校验失败时,报错信息中实际维度缺少方括号的问题进行修复。在 matmul/quant_batch_matmul_v3/op_api/quant_matmul_checker.cpp 的 QuantMatmulChecker::CheckBiasShape 中,将 OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON 的实际 shape 参数由 std::to_string(biasFirstDim).c_str() 改为拼接方括号的 "[" + std::to_string(biasFirstDim) + "]",使实际维度以 [0] 的形式呈现,与期望 shape 的书写格式一致。该改动仅涉及错误信息格式,校验条件、返回值与计算逻辑均未变化。

主要改动

  • 错误信息实际 shape 补上方括号: 在 QuantMatmulChecker::CheckBiasShape 中,OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON 的 shape 参数改为 "[" + std::to_string(biasFirstDim) + "]",使一维 bias 校验失败时实际维度显示为带方括号的形式(如 [0])。
  • 普通日志与 EZ0009 上报格式统一: 修改后普通日志与 EZ0009 上报使用相同的 shape 字符串,避免再出现缺少方括号的 incorrect shape 0。
  • 校验逻辑保持不变: 仅调整报错参数的拼接方式,biasFirstDim == x2NDim_ 的校验条件、return false/return true 返回值及计算逻辑均未改动。
likedislike
不准确?
atomgit-bot
atomgit-bot
9月22日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
9月22日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
9月22日 评论:

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
*/*/op_api/*.h ✅ 汤磊, 杨阳, 王子韬 (3/2) ✅ 汤磊 (1/1)
matmul ✅ 王子韬, 杨阳 (2/2) ✅ 王子韬, 杨阳 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
此处折叠了54条消息 查看更多
CANN-robotCANN-robot成员
9月23日 添加了label:lgtm
tang-lei01成员
9月23日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
9月23日 添加了label:approved
CANN-robotCANN-robot成员
9月23日 合入了pull request
wangyongguang成员
9月23日 评论:

/approve

likedislike