已合并
smla/qsmla/mqsmla pytest bugfix #9664
smla/qsmla/mqsmla pytest bugfix #9664
已合并
郑文惠创建于 14 天前
郑文惠
郑文惠成员
14 天前

描述

smla/qsmla/mqsmla pytest bugfix

关联的Issue

测试

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 郑文惠 的贡献)
郑文惠郑文惠成员
14 天前 创建了 pull request,commit 179113e2
atomgit-bot
atomgit-bot
14 天前 评论:

变更摘要

此 PR 主要针对 smla(sparse flash mla)、qsmla(quant sparse flash mla)和 mqsmla(mixed quant sparse flash mla)三个模块的 pytest 测试框架进行 bug 修复,涉及 torch.load 兼容性适配、环境变量配置化、mask_modekv_topk_mode 的约束校验、元组解包修复以及安全的字典访问等多处修正。

主要改动

  • mask_mode 非零时强制 kv_topk_mode = "no":在 mixed_quant_sparse_flash_mla_golden.pyquant_sparse_flash_mla_golden.pysparse_flash_mla_golden.py 三个文件的 gen_sparse_indices_bsndgen_sparse_indices_tnd 函数中,新增 if mask_mode != 0: kv_topk_mode = "no" 逻辑,确保 mask 场景下 topk 模式被正确禁用。

  • torch.load 增加 weights_only=False 参数:在 test_mixed_quant_sparse_flash_mla_batch.pytest_quant_sparse_flash_mla_batch.pytest_sparse_flash_mla_batch.py 三个批测文件中,为 torch.load 调用统一添加 weights_only=False,修复新版 PyTorch 默认安全加载策略导致的兼容性问题。

  • 硬编码配置项改为环境变量读取:在 test_mixed_quant_sparse_flash_mla_single.pytest_quant_sparse_flash_mla_single.pytest_sparse_flash_mla_single.py 三个单测文件中,将 save_ptresult_path/pt_save_path 从硬编码常量改为通过 os.environ.get 读取环境变量(SAVE_PTMQSMLA_RESULT_SAVE_PATHQSMLA_RESULT_SAVE_PATHSMLA_PT_SAVE_PATH),提升测试灵活性。

  • 元组解包修正与安全的字典访问:在 sparse_flash_mla_golden.py 中,将 else None 改为 else None, None,修复条件表达式返回单值导致的元组解包错误;在 sparse_flash_mla_process.py 中将 metadata_input["K1"] 改为 metadata_input.get("K1"),避免键缺失时的 KeyError;同时将 max_seqlen_ori_kvmax_seqlen_cmp_kv 的计算提前到 metadata 字典构造之前,使取值更安全。

  • 结果比较字符串大小写修正:在 test_quant_sparse_flash_mla_single.py 中,将 main_res != "PASS"lse_res != "PASS" 改为 != "Pass",与实际返回值的大小写保持一致,修复结果误判问题。

likedislike
CANN-robotCANN-robot成员
14 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
14 天前 评论:

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


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
attention haijie_699874, wangzhe123456789 (2/2) wangzhe123456789, haijie_699874 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

zhengwenhui0817, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
14 天前 将hz36amy_00,coder_linx,juyangokok,monologue815,xuanyuandy,crystalhu,yu-xinjie62,huangwei791,jiang-lirui,yang-binrong,Allan_Yu,liudan12,shasha_an,wangzhe123456789,cc-z,shen_weiling,gaoxiang618,songjionghui,wenxin_fight,miaofangzheng,mabing1118,tang-hao-hw-gitcode,haijie_699874,zzy__,yuhao_,L_Euler设为评审人
此处折叠了46条消息 查看更多
wangzhe123456789成员
13 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
13 天前 添加了label:approved
张海杰
张海杰成员
13 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
13 天前 添加了label:lgtm
CANN-robotCANN-robot成员
13 天前 合入了pull request