已合并
fix(norm): guard optional output_rstd attribute access #10023
fix(norm): guard optional output_rstd attribute access #10023
已合并
raoliang_sac创建于 18 天前
raoliang_sac成员
18 天前

描述

RmsNormQuantV2 与 RmsNormQuantV3 共用 RegBase tiling 实现。V2 仅注册 epsilon、div_mode、dst_type 三个属性,但共享实现此前会无条件读取索引 3 的 output_rstd,导致每次 V2 tiling 都产生 GetPointerByIndex: index 3 out of range 3 的 GE ERROR 日志。由于空指针回退,计算仍可完成且 rstdFlag 为 0。

本 PR 做最小修复:先将 rstdFlag 置 0,仅当属性数量大于 output_rstd 的索引时才读取该属性。V2 不再越界访问,且继续保持不输出 rstd;V3 仍读取第 4 个属性,原有 output_rstd=true/false 行为不变。未修改 ACLNN、PTA 或 Kernel 计算逻辑。

关联的Issue

#5652

https://gitcode.com/cann/ops-nn/issues/5652

测试

  • Ascend950 / CANN 9.2.0,目标 host 编译通过。
  • ACLNN 直调 aclnnRmsNormQuant,BF16 输入、scalar BF16 scale、scalar INT8 offset:[256, 6144] 与 [256, 2048] 两个现场 shape 均 GetWorkspace/launch/sync 返回 0。
  • 两个场景输出与 CPU 参考逐元素完全一致,max_abs_diff=0。
  • 修复后 debug plog 中 index 3 out of range 3 出现次数由每次调用 1 次降为 0,tiling 保持 rstdFlag=0。
  • RmsNormQuantV3 的 15 个 tiling 用例全部通过,覆盖 output_rstd=true/false。
  • 联合 op_host UT 共 40 项,39 项通过;现有 rms_norm_quant_v2_tiling_scales2_zeropoints_mismatch 用例因 context 中仍提供 scales2 shape 而与当前主线行为不一致,本次修改未涉及该校验路径。
  • 新分支提交前检查通过:clang-format、codespell、OAT 等仓库 pre-commit 检查全部通过。

文档更新

无需更新文档。

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 raoliang_sac 的贡献)
Rraoliang_sac成员
18 天前 创建了 pull request,commit cfb0262f
atomgit-bot
atomgit-bot
18 天前 评论:

变更摘要

本 PR 修复 RmsNormQuantV2 在共用 RegBase tiling 实现时越界读取 output_rstd 属性的问题。RmsNormQuantV2 与 RmsNormQuantV3 共用 RmsNormQuantV2RegbaseTilingBase::SetInputParams() 实现,但 V2 仅注册了 3 个属性(epsilon、div_mode、dst_type),原实现无条件调用 attrs->GetBool(OUTPUT_RSTD_ATTR_INDEX) 读取索引 3 的属性,导致每次 V2 tiling 均产生 GetPointerByIndex: index 3 out of range 3 的错误日志。修复后先将 rstdFlag 置 0,仅当属性数量大于 OUTPUT_RSTD_ATTR_INDEX 时才读取该属性:V2 不再越界且保持不输出 rstd,V3 仍读取第 4 个属性、output_rstd=true/false 行为不变;未修改 ACLNN、PTA 及 Kernel 计算逻辑。

主要改动

  • 修复越界读取:在 RmsNormQuantV2RegbaseTilingBase::SetInputParams() 中移除对 attrs->GetBool(OUTPUT_RSTD_ATTR_INDEX) 的无条件调用,改为先判断 attrs->GetAttrNum() > static_cast<size_t>(OUTPUT_RSTD_ATTR_INDEX),仅属性数量足够时才读取,消除 V2 场景下的越界访问及对应错误日志。
  • 默认值调整:将 tilingParams.rstdFlag 的赋值改为先统一置 0,再在满足属性数量条件且读取到的 outputRstdPtr 非空且为真时置 1,保证 V2(无该属性)稳定保持 rstdFlag=0。
  • 保持 V3 行为不变:新增的边界判断不影响 V3(已注册第 4 个属性)的原有读取路径,output_rstd=true/false 对应的 tiling 行为与修复前一致。
likedislike
不准确?
atomgit-bot
atomgit-bot
18 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
18 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
18 天前 评论:

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
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

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

likedislike
CANN-robotCANN-robot成员
18 天前 将zengjuan,chaotang233,kevin_huang1234,crystalhu,yangyang016,fanqirui,wangrui_,renruhai,su-yueming,zhajianqing123,chenqi317,wang-xing001,liubo75,tangweiwei2,chenxingyu18,liujie12345678,pingchuantang,Chen_HaoWen,qianzehong设为评审人
CANN-robotCANN-robot成员
18 天前 将kevin_huang1234,wangrui_,renruhai,su-yueming,zhajianqing123,wang-xing001,chenxingyu18,liujie12345678,pingchuantang,Chen_HaoWen,qianzehong设为审查人
Rraoliang_sac成员
18 天前 修改了pull request 的描述
yuning_chen
yuning_chen成员
18 天前 评论:

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

likedislike
raoliang_sac成员
18 天前 评论:

compile

likedislike
Rraoliang_sac成员
18 天前 预合并成功(commit_id: b1b39f456281c5f7005753e376fab0e0cb0e490c)
CANN-robot
CANN-robot成员
18 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
18 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
18 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
18 天前 添加了label:ci-pipeline-passed
qianzehong成员
18 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
18 天前 添加了label:approved
TangPC
TangPC成员
18 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
18 天前 添加了label:lgtm
CANN-robotCANN-robot成员
18 天前 关闭了关联的issue
CANN-robotCANN-robot成员
18 天前 合入了pull request