Merged
fix(cosh): 提升 arch35 大值精度并补齐 golden 注册与 E2E 兼容 #7643
yefeicodingAdd on 3 days ago
fix(cosh): 提升 arch35 大值精度并补齐 golden 注册与 E2E 兼容 #7643
Merged
yefeicodingAdd on 3 days ago
yefeicoding
yefeicodingCollaborators
3 days ago

描述

本 PR 修复 cosh 算子在 arch35(dav_3510)kernel 的大值精度问题,并补齐 diag_flat / cosh 测试资产的注册与兼容性。

cosh arch35 kernel(math/cosh/op_kernel/arch35/cosh.h)

  • 范围缩减由 n = trunc(ax·log2e) 改为 n = round(ax·log2e),使缩减后 |r| ≤ ln2/2,收窄 exp(r) 的拟合区间。
  • n 钳位上限 126 → 130:ax<90 时 n≤130 不会触发钳位;n=130 时 2^(n−2) 的位构造结果为 +inf,与 e^x/4 已溢出的语义一致。
  • 以 FMA 单次舍入的 7 阶 Taylor Horner(Σ r^k/k!, k≤7)替代单条向量 Exp 求 exp(r);复用 nBuf 做 ping-pong 暂存,复用后恢复 cwHiBuf 的 Cody-Waite 常量,不新增 UB 占用。

diag_flat golden(conversion/diag_flat/tests/assets/golden.py)

  • __spec__ 增加 DiagFlat 双注册,GEIR op_name 为 DiagFlat(REG_OP(DiagFlat))时同样命中 DiagFlatKernelSpec。
  • 新增 _TorchDiagFlatReference 三方对照,将 diagonal 映射为 torch 的 offset,供 Kernel 与 ACLNN 两个 spec 使用。

cosh golden(math/cosh/tests/assets/golden.py)

  • import torch 改为可选导入;CoshGraph、torch_graph 与 third_party 按 torch 是否可用条件注册,使仅安装 TF 的 ttk geir 环境也能加载 TestSpec。

关联的Issue

测试

  • 上板验证(arch35):aclnnCosh_L1_008 单次 PASS(rmse 1.086);默认 1e6 复检 64 轮全 PASS(rmse 1.021)。
  • diag_flat 与 cosh 的 golden/spec 改动未附带单独测试执行记录。

文档更新

  • 无。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for yefeicoding's contribution.)
yefeicodingyefeicodingCollaborators
3 days ago Created pull request, commit fc1f9f8f
yefeicodingyefeicodingCollaborators
3 days ago Pre merge succeeded (commit_id: 5c5b1645c9ec7136a68f0a5d5c26871eb0c8e043)
yefeicodingyefeicodingCollaborators
3 days ago Force-pushed 2140 commits:fc1f9f8f-2139 commits from branch master,eedeed12-fix(cosh,diag_flat,diag_v2,batch_to_space): 补齐 golden 注册、bf16 与 E2E 兼容
yefeicodingyefeicodingCollaborators
3 days ago Pre merge succeeded (commit_id: 85346180d3a0627eb67ebb5aa8efdd81bb8eda31)
CANN-robotCANN-robotCollaborators
3 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
3 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

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

Module Approval Details

module lgtm status approve status
conversion/diag_flat ✅ 王瑞, 汤平川 (2/2) ✅ 王瑞, 汤平川 (2/1)
math/cosh ✅ 汤平川, 王瑞 (2/2) ✅ 汤平川, 王瑞 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
3 days ago Set FelixTang7,yue-ma,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,onanfield,zhanw_coding,jiangjiawei,clinglai0517 as approver
8 event messages are collapsed here。 See more
yefeicodingyefeicodingCollaborators
3 days ago Modify description of pull request
yefeicoding
yefeicodingCollaborators
3 days ago Comments:

compile

likedislike
yefeicodingyefeicodingCollaborators
3 days ago Pre merge succeeded (commit_id: 314134f58a3691122df9bbe547aebdbbe3dec4cb)
CANN-robot
CANN-robotCollaborators
3 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
3 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
3 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
3 days ago Added label: ci-pipeline-failed
CANN-robot
CANN-robotCollaborators
3 days ago Comments:

流水线分析报告 — ops-math run#8349

流水线: https://gitcode.com/cann/ops-math/actions/runs/1df5f45f10e6429db489adff58946d0a | PR#7643 | 2026-11-18 16:45:52 ~ 16:53:39 | 失败 Job 1 个

定界结论: 代码问题 / 代码检查错误 — pre-commit 格式检查未通过(clang-format + ruff format)
  • 失败类型: 代码问题(PR 自身变更的格式问题, 非 CI/环境故障)
  • 根因: CodeCheck_precommit 的 pre-commit 检查项 clang-format 与 ruff format 未通过 —— 两个 hook 均因"文件被 hook 修改"而判失败, 属提交者提交前未本地执行 pre-commit 格式化
  • 影响 Job: 仅 CodeCheck_precommit(其余 hook: trim trailing / fix end of files / ruff check / codespell / OAT 全部 Passed)
  • 处置建议: 通知 PR 提交者本地执行 pre-commit 修复并重新推送
    • 参考链接: 本地执行 pre-commit 指导
    • 修复动作(在 PR 分支上):
      pre-commit install          # 首次
      pre-commit run --files conversion/diag_flat/tests/assets/golden.py math/cosh/tests/assets/golden.py math/cosh/op_kernel/arch35/cosh.h
      git add -u && git commit --amend --no-edit && git push -f
      
  • 排除项: 非环境/工程问题(无网络、镜像、平台内部错误); 无平台错误码; 本 run 无其他失败 Job

失败根因分析

根因 #1: 代码问题 / 代码检查错误 — pre-commit 格式 hook(clang-format、ruff format)自动改写文件
  • 判据: pre-commit 检查项不通过 —— clang-format ... Failed(files were modified by this hook) 与 ruff format ... Failed(files were modified by this hook)
  • 定位步骤: Job CodeCheck_precommit → 步骤 3_precommit.log(第 3 步 "pre-commit 检测 changes files" → 第 4 步 "pre-commit 检测结果")
  • 影响 Job: CodeCheck_precommit
  • 根因证据(日志原文):
clang-format.............................................................Failed
- hook id: clang-format
- files were modified by this hook

Formatting [1/1] math/cosh/op_kernel/arch35/cosh.h

ruff check...............................................................Passed
ruff format..............................................................Failed
- hook id: ruff-format
- files were modified by this hook

1 file reformatted, 1 file left unchanged
  • 说明: 失败由 PR#7643 的 3 个变更文件触发 —— math/cosh/op_kernel/arch35/cosh.h(clang-format 需重排)、math/cosh/tests/assets/golden.py 与 conversion/diag_flat/tests/assets/golden.py 中 1 个(ruff format 需重排, 另 1 个已符合格式)。日志末尾的 precommit.py 异常退出: exit code=1 与 ❌ 存在部分文件格式错误 是该 hook 失败的汇总结果, 非独立根因。
  • 修复提示: 该类问题为确定性失败, 重新触发流水线不会消失; 必须本地跑 pre-commit 让 hook 自动格式化后再推送。
结构化定界摘要
[{"repo": "ops-math", "run_number": 8349, "Failed_Type": "代码问题", "Failed_Sub_Type": "代码检查错误", "Failed_Reason": "CodeCheck_precommit 的 clang-format 与 ruff format hook 判失败: math/cosh/op_kernel/arch35/cosh.h 被 clang-format 改写, 1 个 golden.py 被 ruff format 重排, 提交前未本地执行 pre-commit 格式化", "evidence": "clang-format....Failed / - files were modified by this hook / Formatting [1/1] math/cosh/op_kernel/arch35/cosh.h / ruff format....Failed / 1 file reformatted, 1 file left unchanged", "suggestion": "通知 PR 提交者本地执行 pre-commit(或 clang-format -i / ruff format)修复格式后重新推送", "jobs": "CodeCheck_precommit"}]

由门禁失败定界分析自动生成 | repo: ops-math | run: 1df5f45f10e6429db489adff58946d0a | PR#7643

likedislike
yefeicodingyefeicodingCollaborators
3 days ago Pre merge succeeded (commit_id: 0c6f75774f258ed43af0e80a11de314d91a2e137)
yefeicodingyefeicodingCollaborators
3 days ago Force-pushed 2 commits:4ccc384c-fix(cosh,diag_flat,diag_v2,batch_to_space): 补齐 golden 注册、bf16 与 E2E 兼容,eadbfe38-fix(cosh): 提升 arch35 kernel 大值精度,Exp 改 FMA 7 阶 Taylor
yefeicodingyefeicodingCollaborators
3 days ago Pre merge succeeded (commit_id: 6861db325fbb6903a33fb8a06d06ba05d8c9d59c)
CANN-robotCANN-robotCollaborators
3 days ago Removed label: cann-cla/yes
CANN-robotCANN-robotCollaborators
3 days ago Added label: cann-cla/yes
yefeicoding
yefeicodingCollaborators
3 days ago Comments:

/compile

likedislike
yefeicodingyefeicodingCollaborators
3 days ago Pre merge succeeded (commit_id: ecad1bd35146534e97bf36a0d9bd4ed60615ff3a)
CANN-robot
CANN-robotCollaborators
3 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
3 days ago Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
3 days ago Added label: ci-pipeline-running
RuiWang_
RuiWang_Collaborators
3 days ago Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
3 days ago Added label: approved
CANN-robotCANN-robotCollaborators
3 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
3 days ago Added label: ci-pipeline-passed
yefeicoding
yefeicodingCollaborators
3 days ago Comments:
likedislike
TangPC
TangPCCollaborators
3 days ago Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
3 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
3 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
3 days ago Merged pull request