Pull Request已成功合入, 合并人@CANN-robot
(感谢 郑文惠 的贡献)变更摘要
此 PR 主要针对 smla(sparse flash mla)、qsmla(quant sparse flash mla)和 mqsmla(mixed quant sparse flash mla)三个模块的 pytest 测试框架进行 bug 修复,涉及 torch.load 兼容性适配、环境变量配置化、mask_mode 与 kv_topk_mode 的约束校验、元组解包修复以及安全的字典访问等多处修正。
主要改动
-
mask_mode非零时强制kv_topk_mode = "no":在mixed_quant_sparse_flash_mla_golden.py、quant_sparse_flash_mla_golden.py和sparse_flash_mla_golden.py三个文件的gen_sparse_indices_bsnd与gen_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.py、test_quant_sparse_flash_mla_batch.py和test_sparse_flash_mla_batch.py三个批测文件中,为torch.load调用统一添加weights_only=False,修复新版 PyTorch 默认安全加载策略导致的兼容性问题。 -
硬编码配置项改为环境变量读取:在
test_mixed_quant_sparse_flash_mla_single.py、test_quant_sparse_flash_mla_single.py和test_sparse_flash_mla_single.py三个单测文件中,将save_pt和result_path/pt_save_path从硬编码常量改为通过os.environ.get读取环境变量(SAVE_PT、MQSMLA_RESULT_SAVE_PATH、QSMLA_RESULT_SAVE_PATH、SMLA_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_kv和max_seqlen_cmp_kv的计算提前到metadata字典构造之前,使取值更安全。 -
结果比较字符串大小写修正:在
test_quant_sparse_flash_mla_single.py中,将main_res != "PASS"和lse_res != "PASS"改为!= "Pass",与实际返回值的大小写保持一致,修复结果误判问题。


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
/approveor/lgtm- Commenting
/approveimplies 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. 👍


/lgtm
/approve


/approve


描述
smla/qsmla/mqsmla pytest bugfix
关联的Issue
测试
文档更新
类型标签