Skip to content

[XPU] Fix paddle.tile fp16 gradient error#79103

Open
YqGe585 wants to merge 2 commits into
PaddlePaddle:developfrom
YqGe585:xpu-api-fixer/PAD-335-xpu-crash
Open

[XPU] Fix paddle.tile fp16 gradient error#79103
YqGe585 wants to merge 2 commits into
PaddlePaddle:developfrom
YqGe585:xpu-api-fixer/PAD-335-xpu-crash

Conversation

@YqGe585
Copy link
Copy Markdown
Member

@YqGe585 YqGe585 commented May 21, 2026

PR Category

Operator Mechanism

PR Types

Bug fixes

Description

This PR fixes an XPU paddle.tile error for fp16 gradient execution. The XPU tile_grad kernel previously omitted fp16 registration, while the forward tile kernel supports fp16 and GPU tile gradient supports fp16 by accumulating in fp32.

paddle.tile

  • Registers fp16 support for the XPU tile_grad kernel.
  • Adds an fp16-specific XPU gradient path that casts out_grad to fp32, reduces in fp32, and casts the result back to fp16 to align with GPU behavior.
  • Updates XPU2/XPU3 operator capability lists to include fp16 tile_grad.

Validation: all 805 paddle.tile cases from /workspace/PaddleAPITest/all_config.txt passed XPU vs GPU verification.

是否引起精度变化

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented May 21, 2026

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Paddle-CI-Agent | pr_review | 2026-05-22 10:00:00

📋 Review 摘要

PR 概述:为 XPU tile_grad kernel 补齐 fp16 dtype 注册,采用 cast-to-fp32 → reduce_sum → cast-back-to-fp16 路径,与 GPU 行为对齐,修复 XPU fp16 梯度执行报错。

变更范围paddle/phi/backends/xpu/xpu2_op_list.ccxpu3_op_list.ccpaddle/phi/kernels/xpu/tile_grad_kernel.cc

影响面 Tag[Operator Mechanism] [Custom Device]

问题

级别 文件 概述
🟡 建议 paddle/phi/kernels/xpu/tile_grad_kernel.cc 新增 fp16 支持但未在 test/xpu/ 中添加对应回归单测
📝 PR 规范 标题 tag [XPU] 不在官方 PR Category 枚举中

📝 PR 规范检查

标题使用了 [XPU],但根据 checklist §D1,标题 Tag 应来自 PR Category 或 PR Types 枚举。该 PR 的 PR Category 为 Operator Mechanism,更合规的标题如下。

标题建议(可直接复制):

  • [Operator Mechanism] Fix paddle.tile fp16 gradient error on XPU

四个必填描述 section(PR Category / PR Types / Description / 是否引起精度变化)均已填写且内容完整,无需修改描述。

总体评价

fp16 梯度路径的实现方式(if constexpr + cast-compute-cast)逻辑正确,与 GPU 行为一致,XPU2/XPU3 op list 也已同步更新。建议补充 test/xpu/ 回归单测以防止后续回退。

@YqGe585
Copy link
Copy Markdown
Member Author

YqGe585 commented May 25, 2026

/re-run all-failed

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Paddle-CI-Agent | pr_review | 2026-05-26T18:07:25+08:00

📋 Review 摘要

PR 概述:为 XPU tile_grad kernel 新增 fp16 支持,通过 fp32 中间计算对齐 GPU 行为。
变更范围paddle/phi/kernels/xpu/tile_grad_kernel.ccpaddle/phi/backends/xpu/xpu2_op_list.ccpaddle/phi/backends/xpu/xpu3_op_list.cc
影响面 Tag[Operator Mechanism] [XPU]

问题

级别 文件 概述
🟡 建议 paddle/phi/backends/xpu/xpu3_op_list.cc:887 XPU3 tile 前向不支持 fp16,但反向 tile_grad 新增了 fp16,前向/反向 dtype 支持存在不一致
🟡 建议 paddle/phi/kernels/xpu/tile_grad_kernel.cc 缺少 test/xpu/ 下的回归测试

📝 PR 规范检查

PR 标题 [XPU] Tag 不在 checklist §D1 标准枚举中(应来自 PR Category 或 PR Types)。建议使用如下标准格式:

标题建议(可直接复制):

  • [Operator Mechanism] Fix paddle.tile fp16 gradient error on XPU

PR 描述四个必填 section 均存在且内容完整,结构合规,无需修改。

总体评价

整体方案合理,与 GPU tile_grad fp16 行为对齐(cast to fp32 → reduce → cast back)。XPU3 的前向/反向 fp16 支持不一致点需要作者确认是否符合预期;建议在 test/xpu/ 添加 fp16 tile 梯度回归用例以防后续回归。

XPUKernelSet({FLOAT32, INT32, INT64, FLOAT16, BFLOAT16, BOOL})},
{"tile", XPUKernelSet({INT32, INT64, BOOL, FLOAT64, FLOAT32, BFLOAT16})},
{"tile_grad", XPUKernelSet({FLOAT32, BFLOAT16})},
{"tile_grad", XPUKernelSet({FLOAT32, FLOAT16, BFLOAT16})},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 XPU3 的 tile 前向算子不支持 FLOAT16(tile XPU3 支持列表为 {INT32, INT64, BOOL, FLOAT64, FLOAT32, BFLOAT16},无 FLOAT16),但此处为 tile_grad 在 XPU3 上新增了 FLOAT16 支持。

若 XPU3 上 tile 前向不支持 fp16,反向理论上不会以 fp16 被调用。建议同步确认:

  1. XPU3 是否计划支持 fp16 的 tile 前向(若是,应同步补充 xpu3_op_list.cc 中 tile 的 FLOAT16)。
  2. 若 XPU3 暂不支持 fp16 tile 前向,此处注册 tile_grad fp16 是否有必要(或留作预留注册)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants