Skip to content

[Operator Mechanism] Fix baddbmm_grad input_grad overflow for large tensors#79455

Open
feixi139 wants to merge 2 commits into
PaddlePaddle:developfrom
feixi139:fix_baddbmm_big_tensor
Open

[Operator Mechanism] Fix baddbmm_grad input_grad overflow for large tensors#79455
feixi139 wants to merge 2 commits into
PaddlePaddle:developfrom
feixi139:fix_baddbmm_big_tensor

Conversation

@feixi139

Copy link
Copy Markdown
Contributor

PR Category

Operator Mechanism

PR Types

Bug fixes

Description

input_grad = beta * out_grad

但这两个 BLAS 接口的长度参数是 int n。当 input_grad.numel() 超过 INT_MAX 时,长度参数会发生溢出,导致 input_grad 没有被正确写入,最终出现梯度为 0 或保留旧内存内容的问题。

本次修改改为使用 ForRange elementwise kernel 直接计算:

input_grad[i] = beta * out_grad[i]

从而避开 BLAS int n 的限制,使 baddbmm backward 在超大 tensor 场景下能够正确计算 input_grad。

是否引起精度变化

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

发现一个会影响广播输入梯度正确性的阻塞问题,具体位置和建议修复已放在 inline review comment 里。CI 仍有部分任务运行中,当前已完成的非审批检查没有暴露额外问题。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

Comment thread paddle/phi/kernels/impl/baddbmm_grad_kernel_impl.h
PaddlePaddle-bot

This comment was marked as outdated.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复查,新提交恢复了 input_grad 在广播和非广播路径上的统一 beta 缩放,上一轮阻塞问题已解决。当前未发现新的需要阻塞合入的问题,CI 以最终运行结果为准。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Copy link
Copy Markdown

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-07-10 17:11:34

📋 Review 摘要

PR 概述:修复 baddbmm_gradinput_grad 大 tensor 场景下使用 BLAS VCOPY/SCALint 长度溢出问题。
变更范围paddle/phi/kernels/impl/baddbmm_grad_kernel_impl.h
影响面 Tag[Operator Mechanism]

问题

未发现阻塞性问题。PR 规范问题在下面章节报,不要在这里重复

📝 PR 规范检查

符合规范。

总体评价

本轮按 PR diff 和 Paddle Phi kernel checklist 审查了 input_grad 计算路径、BCopyOrScaleFunctor / ForRange 被调用方、baddbmm_grad YAML 与 CPU/GPU kernel 注册。新增实现用 ForRange 承接 int64_t total_elems 并避开 BLAS int n 限制,未发现需要阻塞合入的新问题。

@PaddlePaddle-bot

PaddlePaddle-bot commented Jul 10, 2026

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-07-15 17:59:47 UTC+08:00

CI报告基于以下代码生成(30分钟更新一次):
PR commit: 757e4fe | Merge base: 406c7af (branch: develop)


1 Required任务 : 41/48 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
81(0) 81 73 3 0 0 5
任务 错误类型 置信度 日志
Mac-CPU / Build and test 未知:Mac 测试失败日志不可用 Job
Coverage build 环境问题:Docker 镜像仓库 TLS 握手超时 Job
Check approval 需要 Approval Job

2 失败详情

🔴 Mac-CPU / Build and test — 未知(置信度: 低)

分析器: 通用分析(fallback)
失败用例: 日志不可用,未定位到具体失败用例

用例 错误摘要
Test with mac python3.10 该 step 失败,但深度日志接口未能提取错误正文

关键日志:

failed_steps: Test with mac python3.10
error_snippet: (日志获取失败,无法提取错误信息)
  • 根因摘要: Mac 测试失败但日志不可用
    fetch_ci_logs 仅返回失败 step 为 Test with mac python3.10,没有 log_file_pathstep_log 或单测详情,无法确认具体测试用例和根因。

修复建议:

  1. 当前日志不可用,建议先 rerun 或等待下一轮日志可提取后再分析;低置信度下不提供代码修改建议。

关联变更: 未分析(缺少失败用例和 traceback)

🔴 Coverage build — 环境问题(置信度: 高)

分析器: 通用分析(fallback)
失败用例: 无(Docker 容器启动阶段失败)

用例 错误摘要
Check docker image and run container Docker 访问镜像仓库时 TLS handshake timeout,容器未启动

关键日志:

docker: Error response from daemon: Get "https://ccr-2vdh3abv-pub.cnc.bj.baidubce.com/v2/": net/http: TLS handshake timeout.
See 'docker run --help'.
##[error]Process completed with exit code 125.
Error response from daemon: No such container: paddle-CI-79455-coverage-build-20260710-172042
##[error]Process completed with exit code 1.
  • 根因摘要: Docker 镜像仓库 TLS 握手超时
    Coverage 容器启动阶段访问 ccr-2vdh3abv-pub.cnc.bj.baidubce.com 超时,导致 docker run 退出 125。后续清理步骤因容器未创建而报 No such container,属于前置启动失败的连带错误。

修复建议:

  1. 环境问题,请 rerun。

关联变更: 未分析(失败发生在容器启动/镜像仓库访问阶段,与 PR 代码执行无关)

🔴 Check approval — 需要 Approval(置信度: 高)

该 Job 需要人工 Approval,完成审批后 CI 才会继续执行。

  • 根因摘要: 需要 Approval
  • 修复建议: 请通过人工审批

@paddle-bot paddle-bot Bot added the contributor External developers label Jul 10, 2026
@paddle-bot

paddle-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

你的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.

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

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants