Pull Request has been successfully merged by CANN-robot.
(Thank you for tianjun's contribution.)变更摘要
本 PR 修复 examples/flat_quant/scripts/verify_result.py 中校验器把非有限 float32 参考数据判为通过的问题:在读取并 reshape golden_ref.bin 后新增有限性检查,发现 NaN/Inf 时抛出明确的 ValueError,避免 NaN 比较被忽略而输出错误的 PASS 指标。有限参考仍沿用原有 scale、FP4 容差与输出尺寸规则。同时新增 Host CLI 回归测试文件,并纠正被修改文件的许可证声明拼写。
主要改动
- 非有限参考数据校验: 在
verify函数中对 reshape 后的golden数组执行np.all(np.isfinite(golden))检查,非有限时抛出ValueError("Golden reference contains non-finite values"),阻止非有限数据被写入通过指标。 - 校验脚本文档补充: 在
verify_result.py的 docstringChecks列表中新增说明,明确golden的全部 float32 参考值在比较前必须有限。 - 许可证声明修正: 将
verify_result.py的 License 头调整为与仓库OAT.xml一致的原文(redistribute it and/or modify it under the terms and conditions of、the "License").及MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.)。 - 新增 Host CLI 回归测试: 新增
examples/flat_quant/tests/test_result_verifier.py,通过subprocess调用校验器并合成golden_ref.bin、npu_y.bin、npu_scale.bin夹具,覆盖单一 NaN、后续 batch NaN、全 NaN、正负 Inf 等非有限场景被拒绝,以及零参考、多 batch、正负 0.5 精确参考通过、有限值不匹配失败、输出长度不足报错等用例。 - 失败断言约定: 测试辅助方法
_assert_nonfinite_rejected断言非零返回码、stderr包含指定错误信息、stdout不含[PASS],并确认未生成verify_metrics.json。


/compile


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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ops-tensor | ✅ 唐玮玮, 林鹏翔 (2/2) | ✅ 唐玮玮 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Ethan_Zou, thanks for your pull request. All authors of the commits have signed the CLA. 👍


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm


/compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


自动评审完成:纯 Python 样例修复,正确拒绝非有限参考数据,许可证文本与 OAT.xml 一致,测试充分覆盖正反例;无实质问题(BLAZE 规则因 PR 无 C++ 差异不启用)。
未发现需要修改的问题。
CANNBot 自动评审 · head 3690dc63 · cannbot/deepseek-v4-pro


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


@liubo75 @tangweiwei2 您好,这个 PR 当前没有未解决的行内评审意见。重新触发的 CI 已完成,当前状态通过。烦请您方便时检视;若无其他问题,请按模块权限给予 /approve 和 /lgtm。若仍需调整,我会继续跟进。谢谢!


/lgtm
/approve


描述
修复 FlatQuant 样例校验器把非有限 float32 参考数据判为 PASS 的问题。读取并 reshape
golden_ref.bin后检查全部值有限,异常时抛出明确的 ValueError;避免 NaN 比较被忽略而写出错误的通过指标。有限参考继续使用现有 scale、FP4 容差与输出尺寸规则。新增 Host CLI 回归测试,现有 UT 不作修改。同步将被修改文件的许可证声明拼写纠正为仓库 OAT.xml 中的 Huawei 2026 / CANN 2.0 原文,许可证与审计策略保持一致。
关联的Issue
问题链接附于文末。
测试
python3 examples/flat_quant/tests/test_result_verifier.py -v:8 个测试方法、11 次真实校验 CLI 调用通过,无跳过。使用同一测试文件在未修复基线上验证,5 个非有限参考场景原先均误报 PASS:首个 NaN、后续 batch NaN、全 NaN、正 Inf 组和负 Inf 组。以 master
dcc896ebb1d6eec780a1803708a8be115dc273b9为基线,仅一个源提交。文档更新
补充校验脚本 docstring 中的参考数据有限性检查说明。
类型标签
Closes https://gitcode.com/cann/ops-tensor/issues/296