Closed
SIMT expf/sqrtf/除法函数不支持 subnormal 模式导致特殊场景精度异常 #1487
xuyiyangAdd on  Aug 12Closed at  Aug 25
xuyiyang
xuyiyangCollaborators
Aug 12 Create

从 A5 架构开始,SIMT API 中部分基础数学运算/函数对 subnormal number支持不完整,包括但不限于:

  • expf
  • sqrtf
  • 浮点除法相关函数/表达式,例如 /、__fdividef、fdividef

在输入或中间结果落入 subnormal 范围时,结果可能被 flush-to-zero,导致与 IEEE-754 预期结果或 host/libm 参考结果存在明显偏差。在部分特殊数值场景下,会进一步放大为精度问题。

影响范围

  • 编程模型:Ascend C SIMT API
  • 目标架构:A5 及之后架构
  • 数据类型:float
  • 受影响函数/操作:
    • expf(float)
    • sqrtf(float)
    • float division:a / b
    • __fdividef(float, float)
    • fdividef(float, float)

期望结果

希望社区确认并补充以下内容:

  1. A5 及之后架构中,SIMT expf、sqrtf、浮点除法是否确实不支持 subnormal 模式。

  2. 如果是架构限制,是否可以在文档中明确说明:

    • 哪些函数/操作不支持 subnormal;
    • 是否默认 FTZ;
    • 是否存在关闭 FTZ 或启用精确模式的编译选项。
  3. 如果可以通过软件补偿修复,希望 SIMT API 层提供统一实现,例如:

    • expf 对 subnormal 输出进行补偿;
    • sqrtf 对 subnormal 输入进行缩放计算;
likedislike
xuyiyangxuyiyangCollaborators
Aug 12 Modify description of issue
xuyiyangxuyiyangCollaborators
Aug 12 Assign xuyiyang0324 as responsible person
xuyiyangxuyiyangCollaborators
Aug 12 Associated pull request
xuyiyangxuyiyangCollaborators
Aug 12 Associated pull request
xuyiyang
xuyiyangCollaborators
Aug 18 Comments:

@xuyiyang 我们会在impl/simt_api/math_functions_impl.h中,将expf和sqrtf接口实现修改,根据编译宏状态来控制代码逻辑走不同的分支,实现支持subnormal场景和sqrt高精度场景。

likedislike
xuyiyangxuyiyangCollaborators
Aug 25 changed custom state from 进行中 to 已完成
xuyiyangxuyiyangCollaborators
Aug 25 Close issue
xuyiyang
xuyiyangCollaborators
Aug 25 Comments:

@xuyiyang 代码已经合入,相关pr:https://gitcode.com/cann/asc-devkit/pull/4722

likedislike
CANN-robotCANN-robotCollaborators
Aug 25 Added label: resolved