已合并
fix(dequant_swiglu_quant): 修复arch35 tmpBuffer stride不匹配导致VEC越界AIC Error #8561
caorenlei创建于 8月11日
fix(dequant_swiglu_quant): 修复arch35 tmpBuffer stride不匹配导致VEC越界AIC Error #8561
已合并
caorenlei创建于 8月11日
caorenlei成员
8月11日

描述

修复 dequant_swiglu_quant 算子 arch35 kernel 中 tmpBuffer stride 不匹配导致 VEC 越界 AIC Error 的问题。

改动原因

tmpBuffer 在分配时使用 xUbAlignB32_ 作为行 stride(line 220),但在后续访问 tmpXPtr(指向 tmpBuffer)时,错误使用了 xTypeUbAlignB32_ 作为行 stride 计算地址。当输入数据类型为 bfloat16 时,xTypeUbAlignB32_ 与 xUbAlignB32_ 取值不同,导致地址计算偏移与实际 buffer 布局不匹配,引发 VEC 越界访问,产生 AIC Error。

改动方法

将 dequant_swiglu_quant.h 中 4 处 tmpXPtr 地址计算从 xTypeUbAlignB32_ 修改为 xUbAlignB32_,与 tmpBuffer 分配时的 stride 保持一致:

  • line 510:dstAddr = tmpXPtr + i * xUbAlignB32_ + j * sizePerRepeat
  • line 665:tmpXAddr = tmpXPtr + i * xUbAlignB32_ + j * sizePerRepeat(尾块处理)
  • line 682:tmpXAddr = tmpXPtr + i * xUbAlignB32_ + j * sizePerRepeat(整块处理)
  • line 749:tmpXAddr = tmpXPtr + i * xUbAlignB32_ + j * sizePerRepeat(FP4 量化路径)

关联的Issue

测试

使用 ttk 工具对 bfloat16 输入场景进行精度验证,修复后 AIC Error 消失,精度验证通过。

文档更新

无

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 caorenlei 的贡献)
Ccaorenlei成员
8月11日 创建了 pull request,commit 40146435
atomgit-bot
atomgit-bot
8月11日 评论:

变更摘要

此 PR 修复了 arch35 平台下 dequant_swiglu_quant 算子中由于 tmpBuffer stride 不匹配导致的 VEC 越界 AIC Error。核心问题在于 kernel 中 tmpBuffer 地址计算使用的对齐参数(xTypeUbAlignB32_)与 buffer 初始化时分配的对齐基准(xUbAlignB32_)不一致,导致 stride 偏移错误。修复方案包括:在 host 端 tiling 引入 vecRegLen_ 参与 UB 可用空间计算以预留向量寄存器 padding,同时在 kernel 端统一 tmpXAddr 的 stride 计算为 xUbAlignB32_,并在 tmpBuffer 初始化时追加 AscendC::GetVecLen() 的额外 padding。

主要改动

  • 新增 vecRegLen_ 字段用于 tmpBuffer padding 计算:在 DequantSwigluQuantV35DskTiling 类中添加 uint32_t vecRegLen_ = 256 成员变量,并在 GetPlatformInfo() 中通过 ascendcPlatform.GetVecRegLen() 获取实际向量寄存器宽度,用于 host 端 tiling 的 padding 预留计算。

  • host 端 UB 可用空间计算纳入向量寄存器 padding:DoOpTilingNotFull() 和 DoOpTiling() 中的 ubAvailable 计算均额外减去 vecRegLen_,确保预留足够的向量寄存器对齐空间,避免因 padding 不足导致的越界。

  • kernel 端 tmpBuffer 初始化追加向量寄存器 padding:InitBuffer(tmpBuffer, ...) 的 size 参数从 tl_->UbFactorDimx * xUbAlignB32_ * sizeof(float) 改为追加 + AscendC::GetVecLen(),与 host 端 padding 策略保持一致。

  • 统一 tmpXAddr 地址计算的 stride 参数:kernel 中所有 tmpXAddr 计算从使用 xTypeUbAlignB32_(类型相关对齐)改为使用 xUbAlignB32_(统一对齐),包括 dequant 阶段、量化阶段的整块与尾块处理分支,消除了 stride 不匹配的根因。

likedislike
不准确?
atomgit-bot
atomgit-bot
8月11日 评论:

代码审查

✅ 未发现问题

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

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

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

likedislike
CANN-robotCANN-robot成员
8月11日 将zengjuan,sxb154714,chenfeng61,chaotang233,crystalhu,yangyang016,fanqirui,su-yueming,zhajianqing123,chenqi317,LinPX,wang-xing001,liubo75,tangweiwei2,wangzitao_leo,xubinglin,liujie12345678,pingchuantang,Chen_HaoWen,liuyang_806设为评审人
此处折叠了8条事件消息 查看更多
Ccaorenlei成员
8月12日 修改了pull request 的描述
caorenlei成员
8月12日 评论:

compile

likedislike
Ccaorenlei成员
8月12日 预合并成功(commit_id: 232baa02ed45012db504f867e552aea8425bb3a1)
CANN-robotCANN-robot成员
8月12日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
8月12日 评论:

流水线任务触发成功
任务链接 [2775c7d073234a40bc576fb9b9ec8acd][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950 ✅ SUCCESS >>>>> >>>>>
Compile_Pre ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_classify ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_9030_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
UT_Test_report_lcov ✅ SUCCESS >>>>>

[2026-08-12 17:31:22]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
8月12日 评论:

流水线任务触发成功
任务链接 [07daa8a349bf4a9ca0d09697d86b8294][流水线指导]

任务名称状态日志下载链接
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_precommit ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>

[2026-08-12 17:08:24]    CI执行结束

likedislike
CANN-robotCANN-robot成员
8月12日 添加了label:api-check-pass
CANN-robotCANN-robot成员
8月12日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
8月12日 添加了label:ci-pipeline-passed
tangweiwei2成员
8月13日 评论:

/lgtm
/approve

likedislike
Ccaorenlei成员
8月17日 预合并成功(commit_id: 497ca6cee7e7ee6b8ea800ae374e6961c132c1f0)
Ccaorenlei成员
8月17日 强制推送  150 个提交:9c0ef253-149 commits from branch master,944f6805-fix(dequant_swiglu_quant): 修复arch35 tmpBuffer stride不匹配导致VEC越界AIC Error
Ccaorenlei成员
8月17日 预合并成功(commit_id: baa90aea49d27dc3b0ec67c81cded38654908ed9)
CANN-robotCANN-robot成员
8月17日 删除了label:cann-cla/yes
CANN-robotCANN-robot成员
8月17日 删除了label:ci-pipeline-passed
CANN-robotCANN-robot成员
8月17日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
8月17日 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
CANN-robotCANN-robot成员
8月17日 将qianzehong设为评审人
CANN-robotCANN-robot成员
8月17日 将qianzehong设为审查人
caorenlei成员
8月17日 评论:

compile

likedislike
Ccaorenlei成员
8月17日 预合并成功(commit_id: f57601838c45f9769082eda99202d3c5d8077ca8)
CANN-robotCANN-robot成员
8月17日 删除了label:api-check-pass
CANN-robotCANN-robot成员
8月17日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
8月17日 评论:

流水线任务触发成功
任务链接 [030b9705d0e64a52acb1b14c6f2c519f][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950 ✅ SUCCESS >>>>> >>>>>
Compile_Pre ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_classify ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_9030_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
UT_Test_report_lcov ✅ SUCCESS >>>>>

[2026-08-17 15:43:44]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
8月17日 评论:

流水线任务触发成功
任务链接 [7839acdf24864dddb6b94b518c1dd07b][流水线指导]

任务名称状态日志下载链接
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_precommit ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>

[2026-08-17 15:29:54]    CI执行结束

likedislike
CANN-robotCANN-robot成员
8月17日 添加了label:api-check-pass
CANN-robotCANN-robot成员
8月17日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
8月17日 添加了label:ci-pipeline-passed
chenfeng
chenfeng成员
8月17日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
8月17日 添加了label:approved
TangPC
TangPC成员
8月17日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
8月17日 添加了label:lgtm
CANN-robotCANN-robot成员
8月17日 关闭了关联的issue
CANN-robotCANN-robot成员
8月17日 合入了pull request