已关闭
[Bug-Report|缺陷反馈]: SIMT修复bessel函数精度问题 #1637
shaonaite创建于  9月4日关闭于  9月8日
shaonaite
shaonaite成员
9月4日 创建

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

SIMT Bessel 函数族(j0f/j1f/jnf/y0f/y1f/ynf)在以下输入区间存在精度问题:

1. j0f/j1f/y0f/y1f 大 x(x ≳ 4e8)输出完全错误

原 >8 段用 __internal_trig_red_slowpath_f_fast_mode(uint64 两步 Cody-Waite 相位规约),x > ~4e8 后 a * (2/π) 的 float 舍入把相位低位吃掉,fmaf(q, -π/2_hi, a) 消差后相位全错,sin/cos 多项式喂入大残差 → 输出 1e22~1e28 量级垃圾值或 -inf。>1e13 直接 return 0 放弃精度。

典型数据(y0f,x ≈ 1e12):

输入 x kernel 输出 golden 说明
1.919762e+12 -2.51343204e+27 3.64626480e-08 相位丢失
8.253670e+12 -5.43107102e+25 -1.96991512e-09 相位丢失
7.021627e+12 -inf 1.78723198e-07 溢出

2. ynf 小 x / subnormal 段 ULP 超标

__internal_yn_case1 用 powf(2/x, n) 走 exp(n·log(2/x)) 链,subnormal x 下 log 精度有限 + n 次幂放大误差,且 (2/x)^n 易溢出 -inf。

典型数据(ynf):

n x kernel 输出 golden ulp_dist ulp_tol
2 9.55e-20 -inf -1.40e+38 溢出 7
3 3.57e-10 -1.12e+29 -1.12e+29 72 10
2 5.44e-16 -4.30e+30 -4.30e+30 50 7

3. 特殊值语义不完整

nan 返回 INF/INF(payload 不固定,非标准传播);+inf 走 larger8 的 isinf → 0,但与 golden(scipy 返回 nan)不一致;ynf 对 x<0 返回 NaN 正确但 ±0 语义未显式处理。

Environment / 环境信息 (Mandatory / 必填)

  • 测试环境:Ascend NPU,CANN 9.2.0,--npu-arch=dav-3510

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

同上典型数据

Describe the expected behavior / 预期结果 (Mandatory / 必填)

  • j0f/j1f/y0f/y1f:|x|<8 走 9 ULP,|x|≥8 走 atol 2.2e-6
  • ynf:|x|<n 走 ULP ceil(2+2.5n),否则走 atol 2.2e-6

见上方典型数据表。

Special notes for this issue/备注 (Optional / 选填)

修复方案见 PR #5661:

  • j0f/j1f/y0f/y1f:三段拆分(less8 / middle_range / huge_range)+ Payne-Hanek 大 x 相位规约
  • ynf:case1 改前向递推 + Newton 精化 2/x + 激进归一化,case3 调 case1
  • 共用 helper 改名(__internal_bessel_middle_* 等)
likedislike
shaonaiteshaonaite成员
9月4日 添加了label:bug-report
shaonaiteshaonaite成员
9月4日 关联了pull request:修复bessel函数精度问题
shaonaiteshaonaite成员
9月4日 修改了issue 的描述
shaonaiteshaonaite成员
9月4日 修改了issue 的描述
shaonaite
shaonaite成员
9月7日 评论:

预计9.10日前闭环

likedislike
shaonaiteshaonaite成员
9月8日 issue状态由 待办的 改变为 已完成
shaonaiteshaonaite成员
9月8日 关闭了 issue
CANN-robotCANN-robot成员
9月8日 添加了label:resolved
xuyiyangxuyiyang成员
12 天前 删除了关联的pull request:修复bessel函数精度问题