Merged
feat: support float8 e8m0 scale nn transdata #4577
feat: support float8 e8m0 scale nn transdata #4577
Merged
jayshuAdd on Aug 11
jayshu
jayshu
Aug 11

描述

  • 在 aclnnNpuFormatCast 中支持 FLOAT8_E8M0 从 ND 转换到 scale NZ 昇腾亲和格式。
  • 新增目标 storage shape 推导与校验,scale NZ storage shape 为 (..., ceil(N/16), KScale, 16, 2)。
  • aclnn 路径中复用现有 TransData 流程完成数据搬运与格式转换,保持 origin format 为 ND。
  • 非 FLOAT8_E8M0、非目标格式转换等存量路径保持不变。

关联的Issue

测试

二级冒烟+泛化验证

文档更新

  • 更新 aclnnNpuFormatCast.md,补充 FLOAT8_E8M0 scale NZ 昇腾亲和格式转换说明。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for jayshu's contribution.)
jayshujayshu
Aug 11 Created pull request, commit 91bdfa74
atomgit-bot
atomgit-bot
Aug 11 Comments:

变更摘要

本次变更在 aclnnNpuFormatCast 接口中新增了对 FLOAT8_E8M0 数据类型从 ND 格式到 FRACTAL_NZ(Nn)存储格式的转换支持。该场景主要用于 MX scale 数据的 Nn 布局转换:逻辑 shape 为 (..., KScale, N, 2),Nn 存储 shape 为 (..., ceil(N/16), KScale, 16, 2)。实现上通过新增的 TransFloat8E8m0NdToNn 函数,采用 Reshape + Transpose 组合操作完成转换,并配套增加了 shape 校验、目标 shape 计算以及 Ascend950 L2 单元测试用例。

主要改动

  • 新增 FLOAT8_E8M0 类型支持与路由逻辑:在 ASCEND950_WEIGHT_DTYPE_SUPPORT_LIST 和 WEIGHT_DTYPE_SUPPORT_LIST 中加入 DT_FLOAT8_E8M0;新增 IsFloat8E8m0NdToNn 判断函数,并在 aclnnNpuFormatCastCalculateSizeAndFormat 和 aclnnNpuFormatCastGetWorkspaceSize 中优先路由到 E8M0 ND→Nn 专用处理分支。
  • 新增 E8M0 Nn shape 校验与计算:新增 CheckFloat8E8m0NnShape 校验输入必须为 3D 或 4D、最后一维为 2、N 维对齐 16;新增 ValidFloat8E8m0NnDstShape 校验输出存储 shape 符合 (..., ceil(N/16), KScale, 16, 2);新增 CalcFloat8E8m0NdToNn 计算目标 shape 并设置 actualFormat 为 FORMAT_FRACTAL_NZ。
  • 新增基于 Reshape + Transpose 的转置实现:新增 TransFloat8E8m0NdToNn,将输入先 Reshape 为 (..., KScale, N/16, 16, 2),再通过 Transpose 交换 KScale 轴与 N/16 轴,得到 Nn 存储布局,并正确设置输出 tensor 的 view/ storage/ original 的 format 与 shape。
  • API 文档更新:在 aclnn_npu_format_cast.h 中为 aclnnNpuFormatCast 和 aclnnNpuFormatCastCalculateSizeAndFormat 的注释补充了 FLOAT8_E8M0 数据类型及 MX scale Nn 转换场景说明,additionalDtype 参数增加 ACL_FLOAT8_E8M0。
  • 新增 Ascend950 L2 单元测试:在 test_aclnn_npu_format_cast_l2.cpp 中新增三个测试用例,覆盖合法 4D/3D 形状转换以及 N 维未对齐 16 时返回 ACLNN_ERR_PARAM_INVALID 的错误路径。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 11 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 11 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 11 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
*/*/docs/acl*.md ✅ 陈娇, 周奇龙, zhangzijie (3/2) ✅ 陈娇 (1/1)
*/*/op_host/op_api/*.h ✅ zhangzijie, 周奇龙, 王永光 (3/2) ✅ 王永光 (1/1)
conversion/npu_format_cast ✅ zhangzijie, 周奇龙 (2/2) ✅ 周奇龙, zhangzijie (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
62 messages are collapsed here。 See more
zhangzijieCollaborators
Aug 27 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 27 Added label: approved
sundayCollaborators
Aug 28 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 28 Added label: lgtm
CANN-robotCANN-robotCollaborators
Aug 28 Merged pull request