已合并
bugfix: golden行无效逻辑修复+ lse适配 #10157
Ccccccc创建于 3 天前
bugfix: golden行无效逻辑修复+ lse适配 #10157
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Ccccccc 的贡献)atomgit-bot
3 天前 评论:
3 天前 评论:
变更摘要
本 PR 主要针对稀疏/量化 MLA 测试链路做 bugfix,围绕三方面:修复 golden 参考实现中 ori_mask_mode == 3 等“行无效”场景的判断逻辑、修复测试用例“精度失败却被判为 Pass”的问题,以及为 return_softmax_lse 场景补齐 LSE 输出。核心改动集中在 *_golden.py 参考实现与各测试入口文件:移除了提前置零并 continue 的旧逻辑,改为在窗口为空时构造空张量并仅在 cur_ori_k_bnsd 与 cur_cmp_k 均为空时才将输出行置零;同时调整了 sinks_softmax 的返回值以支持 LSE 计算,并将多个测试文件的失败判定从 == "Failed" 等改为 != "Pass"。
主要改动
- Golden 行无效逻辑修复:
mixed_quant_sparse_flash_mla_golden.py、quant_sparse_flash_mla_golden.py与sparse_flash_mla_golden.py均删除了按ori_mask_mode == 3提前置零并continue的旧逻辑,改为在ori_win_start >= ori_win_end时构造空的cur_ori_k_bnsd,仅在cur_ori_k_bnsd与cur_cmp_k都为空时才将attn_out对应行置零并continue。 - LSE 计算适配:
mixed_quant_sparse_flash_mla_golden.py中sinks_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.py中ori_win_end改为max(ori_threshold, 0),并针对cur_ori_k_bnsd或cur_cmp_k单侧为空的情况调整了k_concat的拼接方式;当empty_flag_ori时total_s2_loop_time由0改为cmp_s2_loop_time。 - 测试失败判定修复:
test_mixed_quant_sparse_flash_mla_batch.py、test_mixed_quant_sparse_flash_mla_batch_graph.py、test_mixed_quant_sparse_flash_mla_single.py及test_sparse_flash_mla_batch_graph.py将result == "Failed"的判断改为result != "Pass",test_quant_sparse_flash_mla_batch.py与test_quant_sparse_flash_mla_single.py将result in ("NPU ERROR", "Failed")改为result != "PASS",避免非通过结果被漏判。 - 图模式测试参数化补全:
test_mixed_quant_sparse_flash_mla_batch_graph.py与test_sparse_flash_mla_batch_graph.py补充了testcase_ids列表,并对环境变量读取、引号风格等进行了统一整理。


Ccccccc
3 天前 评论:
3 天前 评论:
compile


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


1 天前 添加了label:lgtm
1 天前 关闭了关联的issue
1 天前 合入了pull request
描述
原始bug:
1:原始gloden 对lse没有行无效刷0的逻辑,且只判断ori_kv行无效。
2:此外还存在run_mode部分场景下维适配lse。
修复后:
1:适配ori_kv和cmp_kv都是行无效场景才触发行无效刷0的逻辑
2:适配run_mode部分场景的lse
关联的Issue
关联Issue #4381
测试
文档更新
类型标签