已合并
knowledge(triton) 新增 A2 SparseFlashAttentionGrad triton 算子优化知识 #174
guomc创建于 8 天前
knowledge(triton) 新增 A2 SparseFlashAttentionGrad triton 算子优化知识 #174
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 guomc 的贡献)8 天前 添加了label:stat/needs-squash
8 天前 添加了label:cann-cla/yes
CANN-robot
8 天前 评论:
8 天前 评论:
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 |
|---|---|---|
| repo-cann/cannbot-knowledge | ✅ zhanghz1, qq_41667743 (2/2) | ✅ zhanghz1 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
guomc9, thanks for your pull request. All authors of the commits have signed the CLA. 👍


8 天前 将qq_41667743,wangsj0012,jon_jin,zhanghz1,fafahan,zhengshencn_hwca,linghuis,OpSphere,xfwang_ecnu设为评审人
8 天前 将qq_41667743,wangsj0012,jon_jin,zhanghz1,fafahan,zhengshencn_hwca,linghuis,OpSphere,xfwang_ecnu设为评审人
此处折叠了213条消息 查看更多
7 天前 添加了label:ci-pipeline-passed
zhanghz1
7 天前 评论:
7 天前 评论:
/approve


7 天前 添加了label:lgtmapproved
7 天前 合入了pull request
Pull Request 说明
变更说明
将原
sparse_attention_grad_optimization.md拆分为两张单算子 Runbook,分别维护块掩码与 topK 索引两种稀疏注意力反向形态:block_sparse_attention_grad_optimization.md,记录 device 侧掩码转置与选择表构建、连续写回、归约方向和独立 tile 规则。sparse_flash_attention_grad_optimization.md,记录微基准定位、dense-k 大 GEMM 重构、中间布局、精度修复和调试方法。attention_writing_classification.md,不新增设计期约束卡,既有block_sparse_attention_constraints.md不改动。sources: [],正文保留触发条件、探针方法、原始观测与验证信号。所有结论仅声明在实测平台 a2 有效,frontmatter 的 platforms 与实测范围一致。性能证据
SparseFlashAttentionGrad 评测集 18 个 case,覆盖 B 从 1 到 8、S1 从 512 到 8192 含非 2 幂边界、S1 与 S2 不等长、N1 从 4 到 128、K 四档、两种 sparseMode 和 fp16/bf16。Triton 实现经 4 轮 profile 驱动优化,总核时从 6764.3ms 降到 199.5ms,提升 33.9 倍。对 AscendC 标杆算子 npu_sparse_flash_attention_grad 的核时系数,逐 case 独立进程加 profiler kernel_details 口径,全 18 个 case 大于 0.6,最小 0.7424,几何平均 2.6177,官方精度验证 18 个 case 全部通过。
BlockSparseAttentionGrad 的对照数据为:总核时 5934.7ms 降到 21.67ms,提升 273.8 倍,几何平均系数 0.9283,17 个 case 全部大于 0.6。
SFAG 逐 case 明细如下,系数为 AscendC 核时除以 Triton 核时,大于 1 表示 Triton 更快:
变更类型
验证
本地已通过全库 Lint,检查 9058 页且 P0/P1/P2 均为 0;索引检查 712 项且无过期;两个目标算子均可召回新卡;36 项 trace 测试和字段检查通过。完整
check.sh未通过:检索质量门禁的失败项位于本次未修改的 Ascend C 用例,Windows 下部分 evals 存在编码与路径兼容性失败,本机也无法从可用包源安装ruff。