已合并
修复WeightQuantBatchMatmulV2 W4A16 PerGroup-ND场景OOM问题 #3895
sunduiyang创建于 4月16日
修复WeightQuantBatchMatmulV2 W4A16 PerGroup-ND场景OOM问题 #3895
已合并
sunduiyang创建于 4月16日
sunduiyang
sunduiyang成员
4月16日

描述

问题成因:当N非16对齐情况下,antiquantScale和antiquantOffset存在读越界访问问题,两者在UB上的搬运长度bubNLen根据vecNBL1Len进行计算,但对于antiquantScale和antiquantOffset无需按对齐后长度搬运,导致尾块部分读取GM越界。

修改方法:
避免在搬运或计算前对长度做对齐,bubNLen用于表示实际长度,仅在搬运或计算过程中进行对齐。

关联的Issue

#2131

测试

本地环境复现OOM问题,本地修复并修复验证。RDV批跑WeightQuantBatchMatmulV2相关用例。

文档更新

不涉及

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 sunduiyang 的贡献)
sunduiyangsunduiyang成员
4月16日 创建了 pull request,commit 6dc33ba2
sunduiyangsunduiyang成员
4月16日 关联了issue:[Bug-Report|缺陷反馈]: WeightQuantBatchMatmulV2 W4A16 PerGroup-ND场景存在内存越界访问问题
CANN-robot
CANN-robot成员
4月16日 评论:

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


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
matmul 陈琦, 王子韬 (2/2) 陈琦 (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
4月16日 添加了label:cann-cla/yes
CANN-robotCANN-robot成员
4月16日 将sxb154714,chaotang233,crystalhu,yangyang016,fanqirui,zhou-qilong,chenqi317,liubo75,tangweiwei2,wangzitao_leo,zhang-wu设为评审人
CANN-robotCANN-robot成员
4月16日 将sxb154714,chaotang233,crystalhu,yangyang016,fanqirui,chenqi317,liubo75,tangweiwei2,wangzitao_leo,zhang-wu设为审查人
CANN-robot
CANN-robot成员
4月16日 评论:

问题/功能描述

修复了在特定场景下(weightNzfalseantiQuantTypePER_GROUP时)计算bubNLen(UB中B矩阵N方向处理长度)的逻辑错误。原代码在计算时对结果进行了不必要的CeilAlign对齐操作,可能导致实际处理长度超过预期,引发潜在的缓冲区溢出或数据访问越界问题。

修改方案描述

移除了BL1ProcessNK1Vs1函数中计算bubNLen时多余的CeilAlign对齐操作,将其简化为直接取vecNBL1Len_tiling_->nBubSize的最小值。这确保了bubNLen的值严格受限于这两个参数,避免了因对齐导致的长度膨胀,从而保证了后续数据拷贝和反量化计算的安全性。

likedislike
sunduiyang
sunduiyang成员
4月17日 评论:

compile

likedislike
CANN-robotCANN-robot成员
4月17日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
4月17日 评论:

流水线任务触发成功
任务链接 [0485f4998420403086e053a97f9b04c6][流水线指导]

任务名称状态日志下载链接
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 >>>>> >>>>>
Pre_Compile ✅ 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 ✅ SUCCESS >>>>> >>>>>
Compile_ARM_monitor ✅ SUCCESS >>>>> >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
Smoke_A900_npupool ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
ATK_Test_A2 ✅ SUCCESS

[2026-04-17 18:38:40]    CI执行结束

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

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_style ✅ SUCCESS

[2026-04-17 18:37:27]    CI执行结束

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

/compile

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

流水线任务触发成功
任务链接 [422d591704da4b19aead7b54fcbcdbf5][流水线指导]

任务名称状态日志下载链接
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 >>>>> >>>>>
Pre_Compile ✅ 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 ✅ SUCCESS >>>>> >>>>>
Compile_ARM_monitor ✅ SUCCESS >>>>> >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
Smoke_A900_npupool ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
ATK_Test_A2 ✅ SUCCESS

[2026-04-20 09:11:52]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
4月20日 评论:

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_style ✅ SUCCESS

[2026-04-20 09:11:39]    CI执行结束

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

/lgtm

likedislike
chenqi317成员
4月20日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
4月20日 添加了label:lgtmapproved
CANN-robot
CANN-robot成员
4月20日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: 陈琦.
Reviewers who wrote a comment of /lgtm are: 王子韬, 陈琦.

likedislike
CANN-robotCANN-robot成员
4月20日 关闭了关联的issue
CANN-robotCANN-robot成员
4月20日 合入了pull request