已合并
bugfix: golden行无效逻辑修复+ lse适配 #10157
bugfix: golden行无效逻辑修复+ lse适配 #10157
已合并
Ccccccc创建于 3 天前
Ccccccc
Ccccccc成员
3 天前

描述

原始bug:
1:原始gloden 对lse没有行无效刷0的逻辑,且只判断ori_kv行无效。
2:此外还存在run_mode部分场景下维适配lse。
修复后:
1:适配ori_kv和cmp_kv都是行无效场景才触发行无效刷0的逻辑
2:适配run_mode部分场景的lse

关联的Issue

关联Issue #4381

测试

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Ccccccc 的贡献)
CccccccCcccccc成员
3 天前 创建了 pull request,commit 114081f1
atomgit-bot
atomgit-bot
3 天前 评论:

变更摘要

本 PR 主要针对稀疏/量化 MLA 测试链路做 bugfix,围绕三方面:修复 golden 参考实现中 ori_mask_mode == 3 等“行无效”场景的判断逻辑、修复测试用例“精度失败却被判为 Pass”的问题,以及为 return_softmax_lse 场景补齐 LSE 输出。核心改动集中在 *_golden.py 参考实现与各测试入口文件:移除了提前置零并 continue 的旧逻辑,改为在窗口为空时构造空张量并仅在 cur_ori_k_bnsdcur_cmp_k 均为空时才将输出行置零;同时调整了 sinks_softmax 的返回值以支持 LSE 计算,并将多个测试文件的失败判定从 == "Failed" 等改为 != "Pass"

主要改动

  • Golden 行无效逻辑修复mixed_quant_sparse_flash_mla_golden.pyquant_sparse_flash_mla_golden.pysparse_flash_mla_golden.py 均删除了按 ori_mask_mode == 3 提前置零并 continue 的旧逻辑,改为在 ori_win_start >= ori_win_end 时构造空的 cur_ori_k_bnsd,仅在 cur_ori_k_bnsdcur_cmp_k 都为空时才将 attn_out 对应行置零并 continue
  • LSE 计算适配mixed_quant_sparse_flash_mla_golden.pysinks_softmax 的返回值由 (y, x_sum) 改为 (y, x_max, x_sum),并在 return_softmax_lse 为真时向 softmax_lse 写入 x_max[:, 0] + torch.log(softmax_sum[:, 0] + 1e-10)
  • 空窗口拼接与循环次数修复sparse_flash_mla_golden.pyori_win_end 改为 max(ori_threshold, 0),并针对 cur_ori_k_bnsdcur_cmp_k 单侧为空的情况调整了 k_concat 的拼接方式;当 empty_flag_oritotal_s2_loop_time0 改为 cmp_s2_loop_time
  • 测试失败判定修复test_mixed_quant_sparse_flash_mla_batch.pytest_mixed_quant_sparse_flash_mla_batch_graph.pytest_mixed_quant_sparse_flash_mla_single.pytest_sparse_flash_mla_batch_graph.pyresult == "Failed" 的判断改为 result != "Pass"test_quant_sparse_flash_mla_batch.pytest_quant_sparse_flash_mla_single.pyresult in ("NPU ERROR", "Failed") 改为 result != "PASS",避免非通过结果被漏判。
  • 图模式测试参数化补全test_mixed_quant_sparse_flash_mla_batch_graph.pytest_sparse_flash_mla_batch_graph.py 补充了 testcase_ids 列表,并对环境变量读取、引号风格等进行了统一整理。
likedislike
Ccccccc
Ccccccc成员
3 天前 评论:

compile

likedislike
CANN-robotCANN-robot成员
3 天前 添加了label:cann-cla/yes
CccccccCcccccc成员
3 天前 update merge request[project id: 7673863, iid: 10157, commit_id: 65b84321c800bd1a790af7547727440a285334d6] virtual merging success
此处折叠了74条消息 查看更多
CccccccCcccccc成员
2 天前 修改了pull request 的描述
tang-hao-hw-gitcode成员
2 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
2 天前 添加了label:lgtm
CANN-robotCANN-robot成员
2 天前 关闭了关联的issue
CANN-robotCANN-robot成员
2 天前 合入了pull request