Merged
fix issue #13356
liuyun_njAdd on 20 days ago
fix issue #13356
Merged
liuyun_njAdd on 20 days ago
liuyun_nj
liuyun_njCollaborators
20 days ago

描述

批量修复issue,主要改动点:
AddLayerNorm tiling 中权重缓冲区不再乘 bufferNum:add_layer_norm_tiling.cpp 中 betaGammaBufSize、biasBufSize、ubCacheSize、singleRowBufSize、ubConstSlice、ubColNumSlice 等公式均去掉 * bufferNum,并在注释中说明 gamma/beta/bias 为常驻参数、只在 Process() 起始处加载一次并全核复用,不参与 CopyIn->Compute->CopyOut 轮转。
RmsNorm 增加非 regbase 平台的 rstd 元素数校验:在 CheckInputShape4RmsNorm 中,当 shape 全部已知时校验 rstd 元素数等于归一化行数 x.numel / gamma.numel,不满足则通过 OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON 报错返回失败,防止内核按行写 rstd 造成越界写。
aclnnRmsNormQuant 的 scale 校验与错误码表达统一:将 scale 维度/长度及 x、y 形状相关的 OP_LOGE 替换为 OP_LOGE_FOR_INVALID_SHAPEDIM、OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON 等结构化错误宏,并把 scaleLength 的取值移入各平台分支内部。
x/y 前置维度一致性校验扩展到所有平台:DT_INT32 输出分支中 CheckShapeDimWithFrontN 不再仅在 regbase 生效;非 INT32 分支也新增了对 x、y 前置 n 维一致性的校验,不一致时报 "x shape should be the same as y shape"。
INT4 打包条件收紧与非 regbase 空 Tensor 空转:Int42Int32PackedTensor 仅在 yType == DT_INT4 且 y 的 dtype 为 DT_INT32 时执行;非 regbase 路径在 CheckParams 通过后若 x->IsEmpty(),直接返回 workspaceSize = 0 与 ACLNN_SUCCESS,不进入第二段计算。相应 UT 用例被替换为 scale 非法、x/y 前置维不匹配及空 Tensor 成功返回等新场景。

关联的Issue

#7400 #7401 #7402 #7403 #7333 #7213 #7348 #7405

测试

文档更新

aclnnGemmaRmsNorm.md
aclnnGroupNorm.md
aclnnRmsNormQuant.md

类型标签

AI/Agent生成声明

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for liuyun_nj's contribution.)
liuyun_njliuyun_njCollaborators
20 days ago Created pull request, commit ad0261e0
atomgit-bot
atomgit-bot
20 days ago Comments:

变更摘要

本次变更聚焦 AddLayerNorm、RmsNorm 与 RmsNormQuant 三个算子的 tiling 与 aclnn 接口校验逻辑,属于缺陷修复类改动。核心是修正 UB 空间预算中 gamma/beta/bias 常驻参数被重复计入双缓冲导致的 UB 占用估算偏差,补齐非 regbase 平台下 rstd 元素数与归一化行数的校验以避免越界写,并统一 aclnnRmsNormQuant 的 shape 校验与错误信息、调整 INT4 输出打包条件及空 Tensor 的成功空转行为。

主要改动

  • AddLayerNorm tiling 中权重缓冲区不再乘 bufferNum:add_layer_norm_tiling.cpp 中 betaGammaBufSize、biasBufSize、ubCacheSize、singleRowBufSize、ubConstSlice、ubColNumSlice 等公式均去掉 * bufferNum,并在注释中说明 gamma/beta/bias 为常驻参数、只在 Process() 起始处加载一次并全核复用,不参与 CopyIn->Compute->CopyOut 轮转。
  • RmsNorm 增加非 regbase 平台的 rstd 元素数校验:在 CheckInputShape4RmsNorm 中,当 shape 全部已知时校验 rstd 元素数等于归一化行数 x.numel / gamma.numel,不满足则通过 OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON 报错返回失败,防止内核按行写 rstd 造成越界写。
  • aclnnRmsNormQuant 的 scale 校验与错误码表达统一:将 scale 维度/长度及 x、y 形状相关的 OP_LOGE 替换为 OP_LOGE_FOR_INVALID_SHAPEDIM、OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON 等结构化错误宏,并把 scaleLength 的取值移入各平台分支内部。
  • x/y 前置维度一致性校验扩展到所有平台:DT_INT32 输出分支中 CheckShapeDimWithFrontN 不再仅在 regbase 生效;非 INT32 分支也新增了对 x、y 前置 n 维一致性的校验,不一致时报 "x shape should be the same as y shape"。
  • INT4 打包条件收紧与非 regbase 空 Tensor 空转:Int42Int32PackedTensor 仅在 yType == DT_INT4 且 y 的 dtype 为 DT_INT32 时执行;非 regbase 路径在 CheckParams 通过后若 x->IsEmpty(),直接返回 workspaceSize = 0 与 ACLNN_SUCCESS,不进入第二段计算。相应 UT 用例被替换为 scale 非法、x/y 前置维不匹配及空 Tensor 成功返回等新场景。

🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
atomgit-bot
atomgit-bot
20 days ago Comments:

代码审查

✅ 未发现问题


🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
20 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
20 days ago 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 ✅ 杜慧萍, 冯英, 陈昊文, 刘杰 (4/2) ✅ 冯英, 杜慧萍 (2/1)
norm ✅ 陈昊文, 刘杰 (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

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

likedislike
64 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
18 days ago Added label: approved
liujie12345678
liujie12345678Collaborators
17 days ago Comments:

/approve
/lgtm

likedislike
CANN-robotCANN-robotCollaborators
17 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
17 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
17 days ago Merged pull request