已合并
A5 BlockSparseAttention FP8场景性能改进 #6620
tangkaidi创建于 6月9日
A5 BlockSparseAttention FP8场景性能改进 #6620
已合并
tangkaidi创建于 6月9日
已删除 :master合入到cann/ops-transformermaster
tangkaidi成员
6月9日

描述

A5 BlockSparseAttention FP8场景性能改进。
修改点1:末尾阶段的O矩阵乘以FP8最大值的倒数,原本操作是单独再调用封装的方法,Load + Muls + Store,现在融合进rescale的方法内做,减少多余的Load + Store。
修改点2:P矩阵的量化过程指令过多,可以优化。
以双发射一阶段为例:
修改前:1次Muls + 2次DeInterleave + 3次Or + 6次Cast。
修改后:1次Muls + 1次DeInterleave + 1次Or + 4次Cast。

关联的Issue

[Requirement|需求建议]: A5 BlockSparseAttention FP8场景性能改进 #3007

测试

文档更新

类型标签

  • 🐛 Bug 修复
  • ✨ 新特性
  • ⚡ 性能优化
  • ♻️ 重构
  • 🧪 测试
  • 📦 构建/CI
  • 🔧 配置变更
  • 📝 文档更新
  • ⬆️ 依赖升级
  • 🔒 安全修复
  • 🧹 代码清理
  • ❓ 其他,请描述:
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 tangkaidi 的贡献)
Ttangkaidi成员
6月9日 创建了 pull request,commit 18dabad0
Ttangkaidi成员
6月9日 关联了issue:[Requirement|需求建议]: A5 BlockSparseAttention FP8场景性能改进
CANN-robotCANN-robot成员
6月9日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
6月9日 评论:

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
attention 黄俊健, shen_weiling (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

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

likedislike
tangkaidi成员
6月9日 评论:

compile

likedislike
Ttangkaidi成员
6月9日 update merge request[project id: 7673863, iid: 6620, commit_id: 19652d508ed4d49de50c07774e74d2178eab2238] virtual merging success
Ttangkaidi成员
6月9日 修改了pull request 的描述
CANN-robotCANN-robot成员
6月9日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月9日 评论:

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Pre ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>

[2026-06-09 15:02:15]    CI执行结束

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

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_style ✅ SUCCESS >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_checkpr ✅ SUCCESS
codecheck_precommit ⚠️ WARNING >>>>> >>>>>

[2026-06-09 14:52:44]    CI执行结束

likedislike
CANN-robotCANN-robot成员
6月9日 添加了label:api-check-pass
CANN-robotCANN-robot成员
6月9日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月9日 添加了label:ci-pipeline-passed
liwenguihw
liwenguihw成员6月9日进行代码检视2
attention/block_sparse_attention/op_kernel/attn_infra/epilogue/block/block_epilogue_online_softmax_arch35_reg_low_prec.hpp
@@ -705,3 +658,1 @@
705- Cast<float, ElementInput, castTraitOneUNKNOWN>(floatVreg1, expDstVreg0Fp8, pRegFp16All);
706- Cast<float, ElementInput, castTraitZeroUNKNOWN>(floatVreg2, expDstVreg1Fp8, pRegFp16All);
707- Cast<float, ElementInput, castTraitOneUNKNOWN>(floatVreg3, expDstVreg1Fp8, pRegFp16All);
658+ Cast<float, ElementInput, castTraitZeroUNKNOWN>(floatExpVreg0, expDstVreg0Fp8, pRegFp16All);
liwenguihw
liwenguihw6月9日评论:

image.pngvf是否要考虑下划线代替驼峰

likedislike
tangkaidi成员
6月9日 评论:
likedislike
lccchh
lccchh成员
6月9日 评论:

合入前可以更新一下源端,避免落后过多提交

likedislike
Ttangkaidi成员
6月9日 update merge request[project id: 7673863, iid: 6620, commit_id: 9cd6d8655fb2809765bb71ea2812f23af289322a] virtual merging success
Ttangkaidi成员
6月9日 强制推送  36 个提交:01639f95-35 commits from branch masterb018e3d2-try
Ttangkaidi成员
6月9日 update merge request[project id: 7673863, iid: 6620, commit_id: 111ba5d983d52b4c939b90db113e3ce502dc4d89] virtual merging success
CANN-robotCANN-robot成员
6月9日 删除了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
6月9日 评论:

Notification

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

likedislike
tangkaidi成员
6月9日 评论:

compile

likedislike
Ttangkaidi成员
6月9日 update merge request[project id: 7673863, iid: 6620, commit_id: 86b67c11a82ea926b52144735db16beede2cac03] virtual merging success
tangkaidi成员
6月9日 评论:

合入前可以更新一下源端,避免落后过多提交

@lccchh
已更新。

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

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Pre ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>

[2026-06-09 15:49:52]    CI执行结束

likedislike
Ttangkaidi成员
6月9日 解决了最后一个问题
CANN-robot
CANN-robot成员
6月9日 评论:

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_style ✅ SUCCESS >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_checkpr ✅ SUCCESS
codecheck_precommit ⚠️ WARNING >>>>> >>>>>

[2026-06-09 15:37:43]    CI执行结束

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

/approve

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

/lgtm

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