已合并
matmul类算子kernel入口添加InitSocState初始化寄存器状态 #6445
AlbertYoung192创建于 6月24日
matmul类算子kernel入口添加InitSocState初始化寄存器状态 #6445
已合并
AlbertYoung192创建于 6月24日
AlbertYoung192成员
6月24日

描述

当前存在部分算子计算过程中,kernel内修改硬件寄存器状态且使用后未还原,引发后续算子计算过程中未知错误的问题。在算子kernel入口添加InitSocState,重置硬件寄存器状态,规避上述问题。

关联的Issue

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

测试

本地自验证、二级冒烟

文档更新

不涉及

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 AlbertYoung192 的贡献)
AAlbertYoung192成员
6月24日 创建了 pull request,commit 3690f57e
AAlbertYoung192成员
6月24日 关联了issue:[Bug-Report|缺陷反馈]: 当前存在部分算子计算过程中,kernel内修改硬件寄存器状态且使用后未还原,引发后续算子计算过程中未知错误的问题。
CANN-robotCANN-robot成员
6月24日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
6月24日 评论:

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robot成员
6月24日 评论:

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)
quant 商晓波, 王子韬 (2/2) 商晓波 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
AlbertYoung192成员
6月24日 评论:

compile

likedislike
AAlbertYoung192成员
6月24日 update merge request[project id: 7665709, iid: 6445, commit_id: 3b83c39727acc7b1514250dca4733cce9ee51e00] virtual merging success
CANN-robotCANN-robot成员
6月24日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月24日 评论:

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

任务名称状态日志下载链接
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_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>

[2026-06-24 10:35:36]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6月24日 评论:

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ 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 >>>>>
codecheck_precommit ⚠️ WARNING >>>>> >>>>>
SCA ✅ SUCCESS >>>>>

[2026-06-24 10:27:27]    CI执行结束

likedislike
atomgit-bot
atomgit-bot
6月24日 评论:

变更摘要

此 PR 针对 matmul 类算子的 kernel 入口统一添加 AscendC::InitSocState() 调用,用于在每次 kernel 执行前重置硬件寄存器状态。背景是部分算子在计算过程中会修改硬件寄存器且使用后未还原,导致后续算子计算出现未知错误。通过在 kernel 入口处调用初始化函数,规避了寄存器状态遗留问题。

主要改动

  • 6 个 kernel 入口函数添加 AscendC::InitSocState():在 batch_mat_mul_v3fused_mat_mulmat_mul_v3rotate_quanttranspose_batch_mat_mulflat_quant 共 6 个 __global__ __aicore__ kernel 函数体中,于首行业务逻辑前增加 AscendC::InitSocState(); 调用,确保每次 kernel 启动时硬件寄存器状态被重置为默认值。
  • 变更范围集中在 matmul 和 quant 算子目录:涉及 matmul/batch_mat_mul_v3matmul/fused_mat_mulmatmul/mat_mul_v3matmul/rotate_quantmatmul/transpose_batch_mat_mulquant/flat_quant 六个算子模块,每个文件仅新增一行代码,不涉及业务逻辑修改。
likedislike
atomgit-bot
atomgit-bot
6月24日 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
6月24日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月24日 添加了label:ci-pipeline-passed
sxb154714
sxb154714成员
6月24日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
6月24日 添加了label:approved
wangzitao
wangzitao成员
6月24日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
6月24日 添加了label:lgtm
CANN-robotCANN-robot成员
6月24日 合入了pull request