Closed
[Documentation|文档反馈]: SparseFlashMla README 未准确说明 `cmp_topk_length` 的支持条件 #6484
KaranocaVeAdd on  22 days agoClosed at  22 days ago
KaranocaVe
KaranocaVe
22 days ago Create

[Documentation|文档反馈]: SparseFlashMla README 未准确说明 cmp_topk_length 的支持条件

问题

attention/sparse_flash_mla/README.md 将 cmp_topk_length 标为预留输入,并称当前版本不支持非空 Tensor;后文通用约束也将它列入预留输入。这把 Atlas A2/A3 的限制误写成全平台限制。

代码与测试对照

  • Host 校验在 cmp_sparse_indices 非空且 cmp_mask_mode=0 时要求 cmp_topk_length,并校验 shape:TND 为 (q_t, 1),BSND 为 (b, q_s, 1)(sparse_compression_checker.cpp:147-150,208-227)。
  • Arch35 的 test_tiling_950_csa_omit_seqused_cmp_success 设置 cmp_sparse_indices={512,1,512}、cmp_topk_length={512,1}、cmp_mask_mode=0,预期 tiling 成功(test_sparse_flash_mla_tiling.cpp:564-575)。
  • Arch35 kernel 根据 cmp_topk_length 的值限制每个 q token 实际处理的压缩稀疏索引数量(sparse_flash_mla_kvcache.h:356-370),因此该输入并非仅被接受而未使用。
  • 平台限制仍然成立:Host 在非 A5 架构拒绝非空 cmp_topk_length(sparse_flash_mla_tiling.cpp:1007-1010);910B UT 也覆盖该拒绝路径(test_sparse_flash_mla_tiling.cpp:936-948)。Arch35 的成功 UT 明确使用 Ascend950 配置。

修复范围

README 参数表改为说明 Ascend 950PR/950DT 的 CSA 场景支持该输入、mask mode 0 且传入 cmp_sparse_indices 时必须传入,并注明 shape 与稀疏索引去掉末维后一致;同时保留 Atlas A2/A3 不支持非空输入的限制,移除通用约束中的“预留输入”归类。没有改动算子实现。
实现校验、kernel 输入读取及 Ascend 950 成功与 910B 拒绝路径的 UT 源码形成直接对照;本轮未执行完整 UT 或设备运行。

关联 PR: https://gitcode.com/cann/ops-transformer/merge_requests/14363

likedislike
周云飞
周云飞Collaborators
22 days ago Comments:

感谢您提供详细的实现与测试对照。按您描述的校验和 kernel 行为,cmp_topk_length 在特定平台和 CSA 场景下不仅可以传入,还会参与限制每个 q token 实际处理的压缩稀疏索引数量。因此,将其统一描述为“预留输入,当前不支持非空 Tensor”,会让使用者误以为该限制适用于所有平台。

建议将文档调整集中在以下两处:

  • 参数表:按您提供的支持范围,说明 Ascend 950PR/950DT 的 CSA 场景支持该输入;当 cmp_sparse_indices 非空且 cmp_mask_mode=0 时必须传入。明确列出 TND 的形状为 (q_t, 1)、BSND 的形状为 (b, q_s, 1),并说明其与对应稀疏索引形状的关系。
  • 约束说明:移除通用约束中将其归为“预留输入”的表述,同时保留 Atlas A2/A3 不支持非空 cmp_topk_length 的平台限制,避免将局部支持误写为全平台支持。

这一调整方向针对文档中的支持条件说明,不涉及扩大算子能力。您列出的成功与拒绝路径可用于核对文档边界;其中成功用例的预期结果不等同于本轮已通过完整 UT 或设备验证。

likedislike
KaranocaVeKaranocaVe
22 days ago Associated pull request
KaranocaVeKaranocaVe
22 days ago Modify description of issue
周云飞
周云飞Collaborators
22 days ago Comments:

/assign @KaranocaVe

likedislike
CANN-robotCANN-robotCollaborators
22 days ago Assign KaranocaVe as responsible person
KaranocaVe
KaranocaVe
22 days ago Comments:

已按建议更新 PR !14363:说明 950PR/950DT CSA 场景下的必传条件和 TND/BSND shape,并保留 A2/A3 对非空输入的限制。

likedislike
CANN-robotCANN-robotCollaborators
22 days ago Close issue
CANN-robotCANN-robotCollaborators
22 days ago Added label: resolved
周云飞
周云飞Collaborators
2 days ago Comments:

已更新 SparseFlashMla README 中 cmp_topk_length 的说明:明确 Ascend 950PR/950DT 的 CSA 场景下,当 cmp_mask_mode=0 且传入 cmp_sparse_indices 时必须传入该参数,并补充 TND、BSND 格式对应的形状。同时保留 Atlas A2/A3 不支持传入非空 Tensor 的限制。

关联 PR:PR #14363

likedislike