Merged
fix(operation): Correct packed FP4 UB offsets [9.2.0] #6692
fix(operation): Correct packed FP4 UB offsets [9.2.0] #6692
Merged
bynshardAdd on Sep 23
bynshard
bynshardCollaborators
Sep 23

在 A5 上的 TileTensor::GetLinearAddr 中,将逻辑的 FP4 瓦片偏移量转换为打包的字节偏移量。

Related Issue:
https://gitcode.com/cann/pypto/issues/3443

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for bynshard's contribution.)
bynshardbynshardCollaborators
Sep 23 Created pull request, commit 84782efe
atomgit-bot
atomgit-bot
Sep 23 Comments:

变更摘要

本 PR 修正 A5 架构上打包 FP4 类型的 UB 地址偏移计算。由于 float4_e1m2x2_t 和 float4_e2m1x2_t 每字节存放两个 4-bit 元素,而布局 stride 以 4-bit 元素计数,因此在 TileTensor::GetLinearAddr 中需要将逻辑 FP4 tile 偏移转换为打包字节偏移,避免地址超出已分配的 tile。改动仅涉及 TileTensor::GetLinearAddr,其他数据类型与代码生成保持不变。

主要改动

  • FP4 偏移量右移转换为字节偏移: 在 TileTensor::GetLinearAddr 中新增条件分支,当 Type 为 float4_e1m2x2_t 或 float4_e2m1x2_t 时对计算出的 offset 执行 offset >>= 1,使逻辑 4-bit 元素偏移减半为打包字节偏移。
  • 限定 A5 架构生效: 上述 FP4 偏移修正被包裹在 #if defined PTO_NPU_ARCH_A5 条件编译中,仅在 A5 架构下启用,不影响其他架构。
  • 引入类型判断所需头文件: 新增 #include <type_traits>,以支持通过 std::is_same_v 在编译期判断 FP4 类型。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 23 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 23 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 23 Comments:

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robotCollaborators
Sep 23 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
9.2.0 ✅ gcw_kUomxQ2l, congqiannan (2/2) ✅ gcw_kUomxQ2l (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robotCANN-robotCollaborators
Sep 23 Set xinweiliu,cam_bxh,dai-zhentao,TianXL,lululu40888,shi-dingkun,gguuaanngg,codehjp423,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,gcw_kUomxQ2l,Andy-lb,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Sep 23 Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
bynshardbynshardCollaborators
Sep 23 Change title to "fix(operation): Correct packed FP4 UB offsets [9.2.0]", originally titled "fix(tileop): Correct packed FP4 UB offsets [9.2.0]".
bynshardbynshardCollaborators
Sep 23 Associated issue: [Bug-Report|缺陷反馈]: fp4cast精度错误
bynshard
bynshardCollaborators
Sep 23 Comments:

compile

likedislike
bynshardbynshardCollaborators
Sep 23 Pre merge succeeded (commit_id: 2d815620d8318bfaef129b0ffc3331580313dbe1)
CANN-robot
CANN-robotCollaborators
Sep 23 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 23 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 23 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 23 Added label: ci-pipeline-passed
bynshardbynshardCollaborators
Sep 24 Modify description of pull request
liulun0308
liulun0308Collaborators
Sep 24 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 24 Added label: approved
陈晨
陈晨Collaborators
Sep 24 Comments:

/lgtm

likedislike
congqiannan
congqiannanCollaborators
Sep 24 Comments:

/lgtm

likedislike
CANN-robot
CANN-robotCollaborators
Sep 24 Comments:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
/lgtm: chen_chenn

likedislike
CANN-robotCANN-robotCollaborators
Sep 24 Added label: lgtm
CANN-robotCANN-robotCollaborators
Sep 24 Merged pull request