Skip to content

[Operator Mechanism] fix BroadcastConfig do not support big_tensor#79439

Open
feixi139 wants to merge 17 commits into
PaddlePaddle:developfrom
feixi139:fix_broadcast
Open

[Operator Mechanism] fix BroadcastConfig do not support big_tensor#79439
feixi139 wants to merge 17 commits into
PaddlePaddle:developfrom
feixi139:fix_broadcast

Conversation

@feixi139

@feixi139 feixi139 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

PR Category

Operator Mechanism

PR Types

Bug fixes

Description

BroadcastConfig 使用 FastDivMod<int> 对输出线性索引做维度坐标拆解,当 tensor 某一维度大小超过 INT_MAX(2^31 - 1) 时,int 发生溢出,导致索引计算错误,广播结果产生静默错误。

此次改动把从 BroadcastConfig 的GPU/non-XPU 路径支持 64 位,XPU 仍保持 32 位上限

  • paddle/phi/kernels/primitive/datamover_primitives.h

    • BroadcastConfig::divmodersFastDivMod<int>FastDivMod<int64_t>
    • BroadcastConfig::strides:改为 uint64_t
    • ReadDataBc 三个重载的 block_offsettotal_num_output 参数:uint32_t/intuint64_t
    • 移除原有的 PADDLE_ENFORCE_LE_INT_MAX(out_dims[i], "out_dim") 限制,因为 divmoder 本身已升级为 64 位,不再需要该保护
  • paddle/phi/kernels/funcs/broadcast_function.h

    • BroadcastDataLoader::Applyblock_offsetnumel 参数从 int/uint32_t 改为 uint64_t
    • BroadcastDataSetter::Applyindex_bcuint32_tuint64_t
    • VectorizedBroadcastKernelImplnumelblock_offset、内部的 index_bc/thread_offset/idx 全部改为 uint64_t
    • VectorizedBroadcastKernelnumelmain_offsettail_tidblock_offsetstride 改为 uint64_t
    • LaunchBroadcastKernel:去掉此前 numel_64 → static_cast<uint32_t>(numel_64) 的收窄转换,numel/main_offset/tail_tid 直接以 int64_t 参与计算并传递

是否引起精度变化

fix bugs

fix bugs

fix bugs
@feixi139 feixi139 changed the title [Operator Mechanism] fix Broadcast do not support big_tensor [Operator Mechanism] fix BroadcastConfig do not support big_tensor Jul 8, 2026

@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.

已完成首轮代码审查,未发现需要阻塞合入的问题。改动范围集中在 BroadcastConfig 的大维度索引计算,当前 diff 看起来合理;CI 仍有部分任务在运行,合入前请以最终 CI 结果为准。

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

PaddlePaddle-bot

This comment was marked as outdated.

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

@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.

已复查新提交,当前改动主要是将广播索引临时变量从有符号 64 位调整为无符号 64 位;结合 BroadcastKernelSplit 的大 tensor 分片路径检查后,未发现新的阻塞问题。CI 仍有任务在运行,合入前请以最终 CI 结果为准。

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

PaddlePaddle-bot

This comment was marked as outdated.

@PaddlePaddle-bot

PaddlePaddle-bot commented Jul 9, 2026

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-07-16 08:31:12 UTC+08:00

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


1 Required任务 : 47/48 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
123(41) 82 81 1 0 0 0
任务 错误类型 置信度 日志
Windows-GPU / Build and test 🔄×1 不稳定问题:cuda_managed_memory_test 间歇性超时 Job

2 失败详情

🔴 Windows-GPU / Build and test — 不稳定问题(置信度: 高)

失败用例:

用例 错误摘要
cuda_managed_memory_test CTest 记录 Timeout;同一日志后续批次该测试 22.02s 通过

关键日志:

2026-07-15T16:04:18.2431151Z       Start  320: cuda_managed_memory_test
2026-07-15T16:05:47.5852572Z 97% tests passed, 1 tests failed out of 29
2026-07-15T16:05:47.5855283Z The following tests FAILED:
2026-07-15T16:05:47.5862191Z     320 - cuda_managed_memory_test (Timeout)
2026-07-15T17:21:55.9542883Z       Start  320: cuda_managed_memory_test
2026-07-15T17:22:17.9798385Z  1/13 Test  #320: cuda_managed_memory_test ...............   Passed   22.02 sec
  • 根因摘要: cuda_managed_memory_test 间歇性超时

失败发生在 Windows-GPU 的 Test paddle 步骤,CTest 只给出 cuda_managed_memory_test (Timeout),没有断言或编译错误。该测试位于 test/cpp/fluid/memory/cuda_managed_memory_test.cu,覆盖 CUDA managed memory 的 H2D/D2H、oversubscribe 和 OOM 行为;本 PR 仅修改 paddle/phi/kernels/funcs/broadcast_function.hpaddle/phi/kernels/primitive/datamover_primitives.h 的广播索引实现,未触及 managed memory 分配路径或测试注册。结合同一日志后续该测试通过,判断为偶发超时/资源抖动,和本 PR 代码关联度低。

修复建议:

  1. 已知不稳定,请 rerun Windows-GPU / Build and test
  2. 若 rerun 后仍复现,再检查 test/cpp/fluid/memory/CMakeLists.txt 中该测试 TIMEOUT 50cuda_managed_memory_test.cu 的 oversubscribe 用例在当前 Windows GPU runner 上的耗时波动。

关联变更: paddle/phi/kernels/funcs/broadcast_function.hpaddle/phi/kernels/primitive/datamover_primitives.h;未发现与 cuda_managed_memory_test 的直接调用关系。

@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.

已复查新提交,之前关于 total_num_output 仍为 int 的边界判断问题已经在三个 ReadDataBc overload 中改为 uint64_t,与当前 uint64_t index_output 保持一致;未发现新的阻塞问题。CI 仍有任务在运行,合入前请以最终 CI 结果为准。

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

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

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.

已复查新提交,XPU 尾块路径已改为先判断再相减,XPU 分支也补回了 INT_MAX 保护,避免继续把超出 xpu2 32 位索引能力的输入放行;GPU 侧大 tensor broadcast 的 offset/index 链路看起来已经贯通。未发现需要阻塞合入的问题。CI 仍有任务在运行,合入前请以最终 CI 结果为准。

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

@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.

代码 head 未变化,仍沿用上次复查结论;这次只看了更新后的 PR 描述。

  • P3 优先级:P3 非行级:PR 描述更新后写成“从 BroadcastConfig 到最终读写数据的整条链路都同步扩宽到 64 位”,但当前代码在 XPU 分支仍保留 PADDLE_ENFORCE_LE_INT_MAX(numel, "BroadcastKernel numel (XPU)"),并没有实现 XPU large tensor 支持。建议把描述补充为 GPU/non-XPU 路径支持大 tensor,XPU 路径仍保持 INT_MAX 保护,避免读者误以为所有设备后端都已支持。
    处理要求:请针对该评论进行回复(同意并已修改请回复 Done,不同意请说明理由)。
Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@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.

已复查新提交,代码侧主要是把 XPU 的 INT_MAX 检查前移到 BroadcastConfig 构造之前,并补了几处 64 位 offset 计算的显式转换;这部分未发现需要阻塞合入的问题。

  • P3 优先级:P3 非行级:PR 描述仍写成“从 BroadcastConfig 到最终读写数据的整条链路都同步扩宽到 64 位”,但当前实现对 XPU 仍是提前 INT_MAX 保护,而不是支持 XPU large tensor。建议把描述补充为 GPU/non-XPU 路径支持大 tensor,XPU 路径仍保持 INT_MAX 保护。
    处理要求:请针对该评论进行回复(同意并已修改请回复 Done,不同意请说明理由)。
Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

PaddlePaddle-bot

This comment was marked as outdated.

@liuhao2638 liuhao2638 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.

已复查这次提交,上一轮的 non-XPU grid-stride 覆盖问题已经补上,代码侧未再看到新的阻塞点;这次没有新增行级评论。

  • P3 优先级:P3 非行级:PR 描述仍写成“从 BroadcastConfig 到最终读写数据的整条链路都同步扩宽到 64 位”,但当前 XPU 分支仍保留 INT_MAX 保护,和实现不一致。建议把描述改成“GPU/non-XPU 路径支持 64 位,XPU 仍保持 32 位上限”。
    处理要求:请针对该评论进行回复(同意并已修改请回复 Done,不同意请说明理由)。
Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@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.

已复查最新提交:grid_strideuint32_t 溢出选择问题看起来已经补上,但尾块路径仍有需要修复后再合入的问题,详情见行级评论。

  • P3 优先级:P3 非行级:PR 描述仍写成“从 BroadcastConfig 到最终读写数据的整条链路都同步扩宽到 64 位”,但当前 XPU 分支仍保留 INT_MAX 保护,和实现不一致。建议把描述改为“GPU/non-XPU 路径支持 64 位,XPU 仍保持 32 位上限”。
    处理要求:请针对该评论进行回复(同意并已修改请回复 Done,不同意请说明理由)。
Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

Comment thread paddle/phi/kernels/funcs/broadcast_function.h Outdated
PaddlePaddle-bot

This comment was marked as outdated.

@liuhao2638 liuhao2638 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.

已复查最新提交,上一轮行级 P1 的 tail 下溢/越界写问题已经通过 uint64_t loop 变量和有符号剩余量判断修复;这轮没有新增行级评论。

  • P3 优先级:P3 非行级:PR 描述仍写成“从 BroadcastConfig 到最终读写数据的整条链路都同步扩宽到 64 位”,但当前 XPU 分支仍保留 INT_MAX 保护,和实现不一致。建议把描述改为“GPU/non-XPU 路径支持 64 位,XPU 仍保持 32 位上限”。
    处理要求:请针对该评论进行回复(同意并已修改请回复 Done,不同意请说明理由)。
Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

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.

已复查更新后的 PR 描述和当前 head。上一轮行级 P1 已由新提交修复;PR 描述也已补充 GPU/non-XPU 与 XPU 支持范围的差异,之前的非行级说明问题已解决。当前未发现需要阻塞合入的问题,CI 仍在运行,合入前请以最终 CI 结果为准。

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

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.

已复查最新提交,改动主要是补充 tail/索引选择相关注释,并将 XPU 路径固定到已受 INT_MAX 保护的 uint32 索引分支;GPU/non-XPU 路径仍按 numelgrid_strideuint32/uint64 间选择。此前的行级 P1 和 PR 描述问题保持已解决状态,未发现新的阻塞问题。CI 仍在运行,合入前请以最终 CI 结果为准。

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

@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.

@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.

已复查最新提交。此次主要将 GPU/non-XPU 的 BroadcastConfigIndexT 模板化,并在 launch 选择 uint32/uint64 后再构造对应配置,同时把 uint32 快路径上限收紧到 INT_MAX 以匹配 32 位 FastDivMod 的约束。此前的行级 P1 和 PR 描述问题仍保持已解决状态,未发现新的阻塞问题。CI 仍在运行或等待审批相关检查,合入前请以最终 CI 结果为准。

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

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.

已复查最新提交。本轮主要把 kernel 内部的 block_offset/stride 与实际 IndexT 保持一致,并保留 block_offset < numel 后再计算 tail num 的保护;结合 uint32 快路径的 INT_MAX/grid_stride 限制和 XPU 的 INT_MAX 上限检查,之前的行级 P1 仍保持已解决状态。未发现新的阻塞问题。CI 仍在运行或等待审批相关检查,合入前请以最终 CI 结果为准。

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

@wanghuancoder wanghuancoder 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.

LGTM

@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-15 19:16:30

📋 Review 摘要

PR 概述:将 GPU/non-XPU BroadcastConfig 和 broadcast kernel 的线性索引、stride、numel 计算改为按 uint32/uint64 分派,以支持大 tensor 广播;XPU 保持 32 位上限。
变更范围paddle/phi/kernels/funcs/broadcast_function.hpaddle/phi/kernels/primitive/datamover_primitives.h
影响面 TagOperator Mechanism

问题

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

📝 PR 规范检查

符合规范。

总体评价

本轮按风险优先审查了大 tensor 索引类型、FastDivMod 32/64 位分派、GPU grid-stride/tail 分支和 XPU 32 位保护。未发现需要阻塞合入的新问题。

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.

5 participants