Pull Request has been successfully merged by CANN-robot.
(Thank you for Yuan Bin's contribution.)变更摘要
本 PR 为 CSA 模式下的 sparse_flash_mla 算子扩展 topK 的合法取值范围,从原先仅支持固定值扩展为支持 [1, 8192] 的任意索引数。核心思路是放宽 sparse_flash_mla_meta 中对 cmpTopk 的拦截条件、在 sparse_flash_mla 的 tiling 检查中新增对 cmp_sparse_indices 最后一维长度的校验,并调整 CSA 内核在 v0 阶段对压缩块切片(s2)的处理逻辑,使其支持完整的循环与部分末块;同时更新了相关算子的 README 与接口文档。
主要改动
- 新增
TOPK_LIMIT常量与 tiling 参数校验: 在sparse_flash_mla_tiling.h中新增TOPK_LIMIT = 8192;在sparse_flash_mla_tiling.cpp的CheckSingleParaCmpSparseIndices中新增对cmp_sparse_indices最后一维(即topk)的检查,要求在 DAV_2201 架构下取值位于[1, TOPK_LIMIT],否则返回GRAPH_FAILED。 - 放宽
cmp_topk拦截条件: 在sparse_flash_mla_metadata_check.h的CheckSingleParamSmla中,将cmpTopk的合法性判断由仅允许0/512/1024(非 Ascend950 场景)放宽为cmpTopk <= 8192即可通过校验。 - 统一 CSA 内核 v0 阶段的
s2切片逻辑: 在sparse_flash_mla_csa_kernel.h的CalcParams中删除HEAD_RATIO_ONE分支,统一使用s2Offset作为v0S2Start、以actualSingleProcessSInnerSize作为v0S2DealSize,使每个压缩块读取自身对应的切片(含不完整的末块)。 - 文档更新: 依据 PR 描述,同步更新了
sparse_flash_mla与sparse_flash_mla_meta的 README 和接口文档中topK的合法与拦截范围。


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 | ✅ wangxun21, 蔡雯雯, 杨露, guijianwei (4/2) | ✅ 杨露, 蔡雯雯 (2/1) |
| */*/docs/acl*.md | ✅ 蔡雯雯, 杨露, guijianwei, wangxun21 (4/2) | ✅ 蔡雯雯, 杨露 (2/1) |
| attention | ✅ tang-hao-hw-gitcode, guijianwei, wangxun21 (3/2) | ✅ tang-hao-hw-gitcode (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
aaaakai, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm
/approve


\compile


compile


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm
/approve


/lgtm


/lgtm


/approve


描述
改动原因
为CSA模式添加topK的[1,8192]的泛化,使其支持更广泛的索引数范围。
改动方法
放宽对sparse_flash_mla_meta中cmpTopk的拦截条件,在sparse_flash_mla中增加对cmp_sparse_indices中最后一维的长度检查。在sparse_flash_mla的v0阶段中中使s2进行正常的完整循环和获取循环长度。
关联的Issue
https://gitcode.com/cann/ops-transformer/issues/5261
测试
经过360条白盒泛化测试用例,以及200条泛化前后的性能测试
文档更新
更新了sparse_flash_mla与sparse_flash_mla_meta的README文档与接口文档,更新了topK的合法与拦截的范围。
类型标签