Pull Request has been successfully merged by CANN-robot.
(Thank you for DaiHuina1's contribution.)变更摘要
该 PR 主要对 BlockSparseAttentionGrad 算子在 arch35 平台上的 Block 粒度支持进行扩展:将 Block Shape 的合法性约束从「必须是 64 的倍数」放宽为「必须是 16 的倍数」,并相应调整了 Tiling 计算逻辑,使算子能够支持 16、32、48 等更小的非 64 对齐块粒度。同时修复了 cube_op.h 中 L1 缓冲偏移量计算错误以及 madParams.m 的处理,并新增了泛化测试脚本与 Tiling 单元测试用例,覆盖 16/32/48/64 及非对称块、序列尾部、GQA 等场景。
主要改动
- Block Shape 校验放宽为 16 对齐:在
block_sparse_attention_grad_tiling_arch35.cpp和aclnn_block_sparse_attention_grad.cpp中,将blockShapeX_、blockShapeY_及blockShapeOptional的约束由「64 的倍数」改为「16 的倍数」,并同步更新错误提示信息。 - Tiling 计算逻辑调整以支持小粒度 Block:
block_sparse_attention_grad_tiling_arch35.cpp中重写了baseM与singleM的计算,当blockShapeX_小于等于 32 时使用blockShapeX_ * 2,当blockShapeX_或blockShapeY_小于 128 时singleM直接取blockShapeX_,从而支持 16/32/48 等块大小。 - 修复 L1 偏移与 MMA 参数:
cube_op.h中value_l1_tensor_ping_和value_l1_tensor_pong_的偏移累加由base_m改为base_n,并将madParams.m由条件表达式改为直接使用mProcessAlign。 - 新增泛化测试脚本:新增
test_bsa_generalization.py,通过复用参考脚本并做文本替换来生成覆盖block16/32/48/64、非对称块、尾部序列、BNSD/BSND布局及 GQA 的用例,支持--dry-run校验和独立子进程执行。 - 重构并扩充 Tiling 单元测试:
test_block_sparse_attention_grad_tiling.cpp抽取RunArch35BnsdTilingCase辅助函数,新增block64回归、block16尾部、非对称block16x32以及拒绝非 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.
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 |
|---|---|---|
| */*/README.md | ✅ 蔡雯雯, hz36amy_00 (2/2) | ✅ 蔡雯雯 (1/1) |
| */*/docs/acl*.md | ✅ 蔡雯雯, hz36amy_00 (2/2) | ✅ 蔡雯雯 (1/1) |
| attention | ✅ yuhao_, hz36amy_00 (2/2) | ✅ yuhao_ (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
DaiHuina1, thanks for your pull request. All authors of the commits have signed the CLA. 👍


问题 :当前校验会影响arch22路径,改后会新增 blockShape 对齐要求,非对齐会被拦截。
建议 :增加arch35判断条件,以免影响arch22原本路径。


/compile


/compile


/lgtm


无效注释,可以删除


/approve


/check-pr


The following labels are not ready.
lgtm: Please wait for reviewers to review the code.
approved: Please wait for committers to review the code.


/check-pr


The following labels are not ready.
lgtm: Please wait for reviewers to review the code.
approved: Please wait for committers to review the code.


/lgtm
/approve


描述
关联的Issue
测试
文档更新
类型标签