The current Pull Request has been closed by raoliang_sac.
变更摘要
本 PR 修复 CrossCheckComparison 在特殊值分支中的比较误判:当 Promote 保留的高精度 golden(如 FP64)与低精度输出(如 FP32)比较、且竞品独立溢出为 Inf/NaN 时,原规则要求 NPU 输出直接等于高精度 golden 值,会误拒绝已正确舍入的输出。改动集中在 ttk/core_modules/common/comparison/cross_check.py 的 _special_fail 及其调用处:在特殊值路径下按实际输出 dtype 对有限 golden 舍入后再比较;普通有限值分支与 NaN/Inf 之间的匹配语义保持不变。测试文件 tests/core_modules/common/comparison/test_cross_check.py 新增参数化测试覆盖该场景。
主要改动
- 特殊值比较引入输出 dtype 舍入:
_special_fail新增可选参数output_dtype,仅对「输出与golden均有限、third_party非有限」的位,将golden先转为output_dtype再转回后与输出比较,命中则视为tg_match,从而接受正确舍入的有限输出。 - 调用处传入输出类型: 在单块扫描逻辑中,调用
_special_fail时新增传入self.output.dtype,使特殊值分支能按实际输出精度进行舍入比较。 - 规则语义保持与文档更新:
_special_fail的 docstring 更新规则2 为「有限golden舍入到输出类型后相等」,普通有限值分支仍使用原始高精度golden与原有比值阈值,NaN/Inf 之间的匹配语义不变。 - 新增参数化回归测试: 新增
test_promoted_finite_reference_with_nonfinite_competitor,参数化覆盖np.float16/np.float32、正负号、舍入中点(fraction1.0/1.5)及竞品±Inf/NaN,并额外断言相邻错误输出仍不通过。


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
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ops-test-kit | ❌ (0/2)(You can also ask: 徐鲁威, 冯彤, liujun2025, 傅涛, 沈敏) | ❌ (0/1)(You can also ask: wangmingli, 徐鲁威, 周奇龙, 傅涛, 王瑞) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
raoliang_sac, thanks for your pull request. All authors of the commits have signed the CLA. 👍


AI Declaration Check Failed
@raoliang_sac, AI declaration is not compliant. AI tool: OpenAI Codex
Please check:
- The AI tool and model declared in the PR description must be real.
- Commit messages must include the AI model, and it must be consistent with the PR description. ⚠️


当前PR是否有AI参与:
[ ] 否
[x] 是
PR功能描述 / 为什么需要这个合入:
当Promote golden为FP64、NPU输出为FP32且竞品独立溢出为Inf/NaN时,特殊值分支要求NPU直接等于FP64值,会误拒绝正确舍入的输出。例如golden=1+2^-24,NPU=1,GPU=Inf。
在此分支按实际输出dtype舍入有限golden后比较。普通有限值分支继续使用原始高精度golden和原有比值阈值;NaN/Inf之间的匹配语义不变。相邻错误浮点值仍拒绝。
该PR关联的issue
fixes #390
https://gitcode.com/cann/ops-test-kit/issues/390
希望检视人员了解:
仅修改比较器及其测试,不修改算子golden或容差。此修复不会放过BN3DTrainingReduce的中间溢出:重放旧三方产物时,其3条真实失败仍失败。
测试
文档更新
无。
类型标签