Closed
fix: 正确比较Promote有限参考值与低精度输出 #483
raoliang_sacAdd on 20 days agoClosed at 20 days ago
fix: 正确比较Promote有限参考值与低精度输出 #483
Closed
raoliang_sacAdd on 20 days agoClosed at 20 days ago
raoliang_sac
20 days ago

当前PR是否有AI参与:

[ ] 否
[x] 是

  1. AI Agent 平台:OpenAI Codex
  2. AI 模型:GPT-6
  3. Prompt上下文:核实RaggedBinCount三方失败,修复可重现的比较器误判,保持既有容差。

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条真实失败仍失败。

测试

  • 基于主线a2058078e7d650cb8511da74a1795b72410b7563,comparison单元测试258项通过。
  • 新增24组参数化测试,覆盖FP16/FP32、正负值、舍入中点及中点以上、竞品±Inf/NaN;每组另检查相邻错误输出仍失败。修复前24组均失败。
  • 冻结RaggedBinCount输入在Ascend950PR_9579与A100上重新执行:19/19真实三方通过,release binary全部匹配,越界检查通过,TTK单进程。
  • 未执行全量CI。

文档更新

无。

类型标签

likedislike
The current Pull Request has been closed by raoliang_sac.
Rraoliang_sac
20 days ago Created pull request, commit b67866cc
atomgit-bot
atomgit-bot
20 days ago Comments:

变更摘要

本 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、正负号、舍入中点(fraction 1.0/1.5)及竞品 ±Inf/NaN,并额外断言相邻错误输出仍不通过。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
20 days ago Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
Rraoliang_sac
20 days ago Modify description of pull request
CANN-robotCANN-robotCollaborators
20 days ago Added label: ai-co-authored
CANN-robotCANN-robotCollaborators
20 days ago Added label: cann-cla/yes
CANN-robotCANN-robotCollaborators
20 days ago Added label: ai-includes-code
CANN-robot
CANN-robotCollaborators
20 days ago Comments:

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 /approve or /lgtm
  • Commenting /approve implies 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. 👍

likedislike
CANN-robotCANN-robotCollaborators
20 days ago Set wangmingli,dengguojie,zhou-qilong,wangrui_,rxtfeng,loov1,chenqi317,fullt,llimwang,gubaocheng,liujun2025,OpSphere as approver
CANN-robotCANN-robotCollaborators
20 days ago Set wangmingli,dengguojie,zhou-qilong,wangrui_,rxtfeng,loov1,chenqi317,fullt,llimwang,gubaocheng,liujun2025,OpSphere as approver
CANN-robotCANN-robotCollaborators
20 days ago Added label: ai-compliance-failed
CANN-robot
CANN-robotCollaborators
20 days ago Comments:

AI Declaration Check Failed

@raoliang_sac, AI declaration is not compliant. AI tool: OpenAI Codex

Please check:

  1. The AI tool and model declared in the PR description must be real.
  2. Commit messages must include the AI model, and it must be consistent with the PR description. ⚠️
likedislike
Rraoliang_sac
20 days ago Close pull request