Merged
fix(quant): 补齐 aclnnAscendQuant/V3 与 aclnnGroupQuant 第一段参数校验 #11387
fix(quant): 补齐 aclnnAscendQuant/V3 与 aclnnGroupQuant 第一段参数校验 #11387
Merged
cuijieAdd on Sep 29
cuijieCollaborators
Sep 29

描述

修复 issue #6272 与 #6298 指出的两个第一段接口参数校验问题:

  1. aclnnAscendQuant / aclnnAscendQuantV3:roundMode 传 nullptr 时返回 161002,与同族算子(quant_max/grouped_quant_max)整改后的 161001 范式不一致。本次将判空前移至 CheckNotNull 并返回 ACLNN_ERR_PARAM_NULLPTR(161001),CheckRoundMode 仅保留取值校验(非空非法值仍返回 161002)。
  2. aclnnGroupQuant:scale 第 0 维为 0(如 shape [0, 8])时第一段接口未拦截,错误落到 tiling 阶段返回 561103,与文档约束“scale 第 0 维大小不支持为 0”规定的 161002 不符。本次在 CheckDim 新增 scaleDim0 > 0 校验;同时将 offsetOptional 校验由 ShapeSize<=1 收紧为 ==1,拦截 shape 为 [0] 的空 offset(文档约束“为1个数”)。
  3. 同步更新三个算子文档:aclnnAscendQuant/aclnnAscendQuantV3 错误码表 161001 行补充 roundMode 空指针说明;aclnnGroupQuant 参数表三处“支持空Tensor”改为“不支持空Tensor”(scale 以单独 li 注明第 0 维大小不支持为 0),消除与约束说明的矛盾。

关联的Issue

关联Issue #6272、#6298

测试

A2(Ascend 910B3 / CANN 9.1.0)实机验证:

  • ophost UT:ascend_quant_v2 + group_quant 共 19 例全部通过;
  • opapi UT:共 54 例全部通过,含 roundMode=nullptr 期望改为 161001 的两算子用例、新增的 group_quant 空 scale(shape [0,8])/空 offset(shape [0])负向用例(均断言 161002);roundMode 非空非法值用例确认仍返回 161002;
  • example 实卡验证(基于修复代码打包 custom 包):aclnnAscendQuant/aclnnAscendQuantV3/aclnnGroupQuant 正常路径两段式跑通且输出数值与手算期望一致;roundMode=nullptr 返回 161001,scale 第 0 维为 0 与空 offset 均在第一段返回 161002;
  • 反向对照:撤回 group_quant 校验后新增负向用例失败,恢复后通过,确认用例有效。

文档更新

  • quant/ascend_quant_v2/docs/aclnnAscendQuant.md、aclnnAscendQuantV3.md:161001 错误码行补充 roundMode 空指针。
  • quant/group_quant/docs/aclnnGroupQuant.md:scale/groupIndex/offsetOptional 参数约束澄清。

类型标签

AI/Agent生成声明

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for cuijie's contribution.)
CcuijieCollaborators
Sep 29 Created pull request, commit eb1108dc
CcuijieCollaborators
Sep 29 Associated issue: [Bug-Report|缺陷反馈]: aclnnGroupQuant 在 scale 第 0 维为 0 时返回错误码 561103,与文档约束(161002)不符且第一段接口未拦截,[Bug-Report|缺陷反馈]: aclnnAscendQuant/aclnnAscendQuantV3 roundMode=nullptr 返回 161002 而非 161001(同族 quant_max/grouped_quant_max 已整改)
atomgit-bot
atomgit-bot
Sep 29 Comments:

变更摘要

本次变更统一并补齐了量化算子第一段接口的参数校验:将 aclnnAscendQuant / aclnnAscendQuantV3 中 roundMode 为空指针的判空逻辑前移至 CheckNotNull,使其返回 ACLNN_ERR_PARAM_NULLPTR(161001),与同族算子范式一致;同时在 aclnnGroupQuant 的 CheckDim 中新增对 scale 第 0 维为 0 的拦截,并收紧 offsetOptional 的空 Tensor 校验,避免错误下沉到 tiling 阶段。相关 UT 期望值与负向用例、以及对应算子文档同步更新。

主要改动

  • roundMode 判空前移: aclnnAscendQuant 与 aclnnAscendQuantV3 的 CheckNotNull 新增 roundMode == nullptr 校验并返回 ACLNN_ERR_PARAM_NULLPTR,CheckRoundMode 中原来的空指针分支被移除,仅保留取值合法性校验。
  • aclnnGroupQuant 新增 scale 第 0 维校验: 在 CheckDim 中新增 scaleDim0 > 0 的 OP_CHECK,使 scale 第 0 维为 0 时第一段接口直接返回 ACLNN_ERR_PARAM_INVALID(161002),不再下沉至 tiling。
  • offsetOptional 约束收紧: 由原来的 ShapeSize <= 1 收紧为 ShapeSize == 1,拦截 shape 为 [0] 的空 offset,并在报错信息中输出实际 shape。
  • UT 期望值与负向用例更新: 两个 roundMode=nullptr 用例的期望由 ACLNN_ERR_PARAM_INVALID 改为 ACLNN_ERR_PARAM_NULLPTR;group_quant 新增空 scale(shape [0,8])与空 offset(shape [0])两个负向用例,均断言返回 ACLNN_ERR_PARAM_INVALID。
  • 文档同步: aclnnAscendQuant.md / aclnnAscendQuantV3.md 错误码表 161001 行补充 roundMode 空指针说明,aclnnGroupQuant.md 将相关参数的“支持空 Tensor”改为“不支持空 Tensor”并注明 scale 第 0 维大小不支持为 0。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 29 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 29 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 29 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
*/*/docs/acl*.md ✅ 刘杰, 陈娇, 陈昊文 (3/2) ✅ 陈娇 (1/1)
quant ✅ 陈昊文, 刘杰 (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

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 29 Set zengjuan,u010470851,sxb154714,chenfeng61,chaotang233,crystalhu,yangyang016,fanqirui,gitee-duhuiping,su-yueming,zhajianqing123,yourealize,chenqi317,LinPX,wang-xing001,liubo75,tangweiwei2,wangzitao_leo,xubinglin,gitcode-chenjiao,liujie12345678,pingchuantang,Chen_HaoWen,qianzehong,fengying555682,liuyang_806,caiwenwen,yanglu-1 as approver
CANN-robotCANN-robotCollaborators
Sep 29 Set u010470851,sxb154714,chenfeng61,gitee-duhuiping,su-yueming,zhajianqing123,yourealize,LinPX,wang-xing001,wangzitao_leo,xubinglin,gitcode-chenjiao,liujie12345678,pingchuantang,Chen_HaoWen,qianzehong,fengying555682,liuyang_806,caiwenwen,yanglu-1 as approver
cuijieCollaborators
Sep 29 Comments:

compile

likedislike
CcuijieCollaborators
Sep 29 Pre merge succeeded (commit_id: 9c0ec90c53ed95749b1d0984d72ae5e7f232e679)
CANN-robot
CANN-robotCollaborators
Sep 29 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 29 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 29 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 29 Added label: ci-pipeline-passed
yuning_chen
yuning_chenCollaborators
Sep 29 Comments:

您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!

likedislike
Chen_HaoWenCollaborators
Sep 29 Comments:

/approve
/lgtm

likedislike
liujie12345678Collaborators
Sep 29 Comments:

/approve
/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Sep 29 Added label: lgtm
Chen_HaoWenCollaborators
Sep 30 Comments:

/approve
/lgtm

likedislike
Chen_HaoWenCollaborators
Sep 30 Comments:

/approve
/lgtm

likedislike
chenjiaoCollaborators
Sep 30 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 30 Added label: approved
CANN-robotCANN-robotCollaborators
Sep 30 Closed associated issue
CANN-robotCANN-robotCollaborators
Sep 30 Merged pull request