Skip to content

[Windows] export operator kernel registry#79419

Merged
swgu98 merged 4 commits into
PaddlePaddle:developfrom
gouzil:codex/export-all-op-kernels
Jul 7, 2026
Merged

[Windows] export operator kernel registry#79419
swgu98 merged 4 commits into
PaddlePaddle:developfrom
gouzil:codex/export-all-op-kernels

Conversation

@gouzil

@gouzil gouzil commented Jul 5, 2026

Copy link
Copy Markdown
Member

PR Category

Operator Mechanism

PR Types

Bug fixes

Description

从 Windows VS2022 CI 修复中拆出 OperatorWithKernel::AllOpKernels() 的单独修复。

Windows 下 header inline 函数里的局部静态 registry 可能在测试 exe 和 libpaddle.dll 中各有一份,导致 REGISTER_OP_CPU_KERNEL 写入的 Fluid op kernel 在 OperatorWithKernel::ChooseKernel() 查询时不可见,进而触发 operator_testkernels_iter == all_op_kernels.end() 的错误。

本 PR 将 AllOpKernels() 从 header inline 实现改为 operator.cc 中的 TEST_API 导出函数,保证 Windows 测试构建跨 DLL 边界使用同一份 op kernel registry;普通非测试构建中 TEST_API 为空,不新增 PADDLE_API runtime 导出符号。

同时从 Windows-Inference skip list 中放出 operator_test,让该 CI 直接验证上述 registry 修复。

关联拆分来源:#79381

验证:

  • git diff --check
  • prek --files paddle/fluid/framework/operator.h paddle/fluid/framework/operator.cc tools/windows/run_unittests.sh
  • bash -n tools/windows/run_unittests.sh

是否引起精度变化

Copilot AI review requested due to automatic review settings July 5, 2026 16:34

Copilot AI 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.

Pull request overview

This PR fixes a Windows-specific kernel registry visibility issue across DLL boundaries by moving OperatorWithKernel::AllOpKernels() from a header inline implementation to an exported out-of-line definition in operator.cc, ensuring the registry is shared between libpaddle.dll and test executables.

Changes:

  • Replaces the header-inline local static op kernel registry with an exported (PADDLE_API) OperatorWithKernel::AllOpKernels() declaration.
  • Adds the out-of-line OperatorWithKernel::AllOpKernels() definition in operator.cc so Windows uses a single registry instance across module boundaries.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
paddle/fluid/framework/operator.h Changes AllOpKernels() from header-inline to PADDLE_API declaration to avoid per-module static registry duplication on Windows.
paddle/fluid/framework/operator.cc Adds the out-of-line AllOpKernels() definition hosting the single function-local static registry instance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

代码层面未发现需要阻塞合入的问题。这个改动把 OperatorWithKernel::AllOpKernels() 从 header inline 挪到 operator.cc 并加上导出声明,和 PR 描述里的 Windows DLL registry 共享问题一致;我没有看到需要行级修改的缺陷。

CI 方面仍需等待:Windows 相关 build/test 还在运行,另外当前有 clone/构建链路失败。其中两个 clone 失败是 third_party/pocketfft submodule 403,Inference build 失败停在下载/更新测试分支阶段,暂未看到和本次代码改动直接相关的编译错误。

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 5, 2026
@SigureMo

SigureMo commented Jul 5, 2026

Copy link
Copy Markdown
Member

@ShigureNyako 看看 CI 里又是什么奇奇怪怪的报错?sleef?最近没动过吧?

PaddlePaddle-bot

This comment was marked as outdated.

@ShigureNyako

Copy link
Copy Markdown
Contributor

看了当前 head 704e95db63e6f9d8701a8408ad7138fc93e11e7e 的失败日志,结论倾向于 CI clone/submodule artifact 问题,不是这个 PR 的 operator.cc/operator.h 改动导致

证据:

  • 当前 PR diff 只有 paddle/fluid/framework/operator.ccpaddle/fluid/framework/operator.h
  • 失败发生在 Paddle 编译主体之前的 third_party patch 阶段:Mac-CPU/Linux-XPU/Linux-CPU/Distribute-stable-build 都在 extern_sleefextern_threadpoolextern_warprnnt 等外部依赖上执行 git checkout -- . 时失败,典型日志是 error: pathspec '.' did not match any file(s) known to git.;所以日志里提到 sleef 更像是坏 submodule/worktree 的一个症状,不是 SLEEF 本身最近被改坏。
  • 上游 Clone-linux / Clone Paddle 生成 Paddle.tar.gz 的日志里,在打包前已经出现 submodule fetch 异常:Errors during submodule fetchthird_party/warprnnt/third_party/warpctc/third_party/eigen3)以及 ci/third_party_tag.sh: line 41: cd: third_party/rocksdb: No such file or directory。这说明下游 build job 下载到的源码包很可能已经包含不完整/异常的 submodule 状态。

建议:这个 PR 暂时不需要改代码。优先重新触发一次会重新生成 Paddle.tar.gz 的完整 CI/clone 流程;如果复现,重点查刚合入的 clone/submodule 相关改动 PaddlePaddle/Paddle#79420。仅重跑失败 build job 可能会复用同一份异常源码包,未必能修复。

@SigureMo

SigureMo commented Jul 5, 2026

Copy link
Copy Markdown
Member

@ShigureNyako 可是 #79422 也挂了,就很奇怪

@ShigureNyako

Copy link
Copy Markdown
Contributor

更新:#79422 这边看起来不是反例,反而更支持“clone/submodule/source artifact 链路异常”。

我核了 PaddlePaddle/Paddle#79422 当前失败:

另外 #79422Clone-linux / Clone Paddle 虽然是 success,但在打包上传 Paddle.tar.gz 前也有异常日志:ci/third_party_tag.sh: line 37: cd: third_party/brpc: No such file or directoryline 41: cd: third_party/rocksdb: No such file or directoryfatal: couldn't find remote ref 6.19.fb,之后仍继续 tar -I 'zstd -T0' -cf Paddle.tar.gz Paddle

所以我会把结论收敛成:#79419 的 SLEEF 不是 PR 代码问题;#79422 说明更像是 #79420 这组“延迟到 merge PR 后再递归 submodule update/打包”的 clone workflow 改动引入/暴露了脏 worktree 或不完整 submodule 被打包的问题。建议优先修 clone job:submodule/tag 处理失败不要继续打包;merge 后对 submodule 做强制 deinit/clean + git submodule sync --recursive && git submodule update --init --recursive --force,并在上传前校验关键 submodule 是有效 git worktree。

@SigureMo

SigureMo commented Jul 5, 2026

Copy link
Copy Markdown
Member

@ShigureNyako 这个 PR rerun clone 后过了,但 #79422 并没有,我怀疑是某个 runner / 机器出了问题,你看看呢?

@ShigureNyako

Copy link
Copy Markdown
Contributor

按 runner / 机器再看了一轮,基本同意“某个 runner/workspace 状态有问题”的方向,但更具体地说像是 clone runner slot 的脏 workspace + workflow 没有强制重建 submodule,不是某个下游 build runner 单机坏了。

关键对比:

  • [Windows] export operator kernel registry #79419 rerun 后通过的 Clone-linux / Clone Paddle:runner 是 instance-occt1ls7-4-4,group hk-clone,machine instance-occt1ls7-4,workspace 路径里是 /home/paddle-4/...。开头 Check submodules status 直接是 fatal: not a git repository,等于从干净状态开始;随后 git submodule update --init --recursive 重新 checkout 了 81 个 submodule,包括 third_party/rocksdbsleefthreadpoolwarpctcwarprnntpocketfft。这个 artifact 下游 PR-CI-SOT 已经过了。
  • [release/3.4][Build][CI] Switch pocketfft submodule URL to GitHub mirror #79422Clone-linux / Clone Paddle:runner 是 instance-occt1ls7-4,同属 hk-clone,machine 也是 instance-occt1ls7-4,但 workspace 是 /home/paddle/...。这个 job 开头已经有旧的 submodule worktree;merge 后虽然执行了 git submodule sync --recursive && git submodule update --init --recursive,日志里实际只重新 checkout 了 4 个 submodule,没有重新 checkout/force 恢复 sleefthreadpoolwarprnntwarpctcrocksdb 这些后面会被 build patch 的目录。
  • [release/3.4][Build][CI] Switch pocketfft submodule URL to GitHub mirror #79422 后续失败不是集中在一个下游 runner:同一份 artifact 在 mac-m4-1paddle-cpu-6271-2-*paddle-cpu-10-1paddle-cpu-14-1yq01-bfs-cs57-1 等不同 runner/group 上都出现 git checkout -- . 后的 error: pathspec '.' did not match any file(s) known to git,例如 PR-CI-SOTLinux-CPUMac-CPU。这更像 artifact 里 submodule 目录已经不对,而不是这些 build runner 同时坏掉。

所以建议先处理 hk-clone 里的 instance-occt1ls7-4 这个 runner slot(/home/paddle/actions-runner/_work/Paddle/Paddle):清掉 workspace / .git/modules 后重新跑 #79422 clone。长期要在 clone workflow 里对 submodule 做强制清理/恢复,比如 merge PR 后 git submodule deinit -f --all + 清理旧 .git/modules + git submodule sync --recursive && git submodule update --init --recursive --force,并在上传 Paddle.tar.gz 前验证关键 submodule 是有效 git worktree;否则 clone job success 但 artifact 仍可能是坏的。

@SigureMo

SigureMo commented Jul 5, 2026

Copy link
Copy Markdown
Member

@ShigureNyako 你不用看下游的 runner,就看 clone 流水线,整理一个表格,对应这两个 PR 的几次 rerun,哪次跑的是哪个 runner,是否成功

@ShigureNyako

Copy link
Copy Markdown
Contributor

只看 CI / Clone-linux / Clone Paddle 这条 clone 流水线,我按 run attempt / runner 整理如下(状态来自 job metadata,runner/路径来自 job log):

PR attempt / job clone job 状态 runner / host workspace artifact 线索 下游结果
PaddlePaddle/Paddle#79419 attempt 1: 85246831334 success instance-occt1ls7-4 / host instance-occt1ls7-4 /home/paddle/actions-runner/_work/Paddle/Paddle git submodule update 实际 checkout 了 54 个 submodule;后续 artifact 出现外部依赖 patch 问题 坏 artifact,后面 rerun
PaddlePaddle/Paddle#79419 attempt 2: 85251486669 success instance-occt1ls7-4-4 / host instance-occt1ls7-4 /home/paddle-4/actions-runner/_work/Paddle/Paddle precheck 是 fatal: not a git repository,随后 checkout 了 81 个 submodule(含 rocksdb/sleef/threadpool/warpctc/warprnnt/pocketfft artifact 可用;该 attempt 后 SOT/Mac/XPU 已过
PaddlePaddle/Paddle#79422 attempt 1: 85246826268 success instance-occtls7-4-3 / host instance-occt1ls7-4 /home/paddle-3/actions-runner/_work/Paddle/Paddle 只看到 4 个 Submodule path ... checked out artifact 可疑
PaddlePaddle/Paddle#79422 attempt 2: 85251693489 success instance-occt1ls7-4 / host instance-occt1ls7-4 /home/paddle/actions-runner/_work/Paddle/Paddle 只 checkout 4 个 submodule,且 third_party_tag.shbrpc/rocksdb 目录不存在 artifact 可疑;下游复现 patch 失败
PaddlePaddle/Paddle#79422 attempt 3: 85253710792 success instance-occtls7-4-3 / host instance-occt1ls7-4 /home/paddle-3/actions-runner/_work/Paddle/Paddle 没看到新的 Submodule path ... checked out,仍有 third_party_tag.sh 的缺目录/remote ref 日志 artifact 仍可疑;该 attempt 后已有下游失败/部分仍在跑

结论只针对 clone:这几次 clone job 本身都是 success,差异在于 #79419 成功的 rerun 跑到了 /home/paddle-4 这个较干净的 runner slot 并完整 checkout submodule;#79422 的 rerun 主要落在 /home/paddle / /home/paddle-3,没有强制刷新关键 submodule,clone job 虽绿但 artifact 不可信。建议先清理 instance-occt1ls7-4 上这些 hk-clone workspace 后再 rerun #79422 clone,或者在 workflow 里强制 deinit/clean submodule 后再打包。

@SigureMo

SigureMo commented Jul 5, 2026

Copy link
Copy Markdown
Member

@ShigureNyako 好,instance-occt1ls7-4instance-occtls7-4-3 先下掉了,明天让 @swgu98 清理下 /home/paddle/home/paddle-3 后再重新上线,你继续观察下吧

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@2235ce4). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             develop    #79419   +/-   ##
===========================================
  Coverage           ?   100.00%           
===========================================
  Files              ?         1           
  Lines              ?         3           
  Branches           ?         0           
===========================================
  Hits               ?         3           
  Misses             ?         0           
  Partials           ?         0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PaddlePaddle-bot

PaddlePaddle-bot commented Jul 5, 2026

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-07-07 00:27:55 UTC+08:00

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


1 Required任务 : 44/49 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
82(0) 82 77 2 1 0 2
任务 错误类型 置信度 日志
Build Fleet whl 环境问题 Job
Mac-CPU / Build and test 未知 Job

2 失败详情

🔴 Build Fleet whl — 环境问题(置信度: 高)

错误类型: 环境问题 | 置信度: 高
分析器: 通用分析(fallback)
失败用例: 无(构建/打包阶段失败)

用例 错误摘要
uv build whl 克隆 Fleet 第三方 submodule 时代理返回 502,导致 whl 构建退出

关键日志:

fatal: unable to access 'https://github.com/PFCCLab/DeepEP.git/': CONNECT tunnel failed, response 502
fatal: clone of 'https://github.com/PFCCLab/DeepEP.git' into submodule path '/paddle/packages/paddlefleet_ops/third_party/HybridEP' failed
fatal: unable to access 'https://github.com/PFCCLab/fast-hadamard-transform.git/': CONNECT tunnel failed, response 502
fatal: clone of 'https://github.com/PFCCLab/fast-hadamard-transform.git' into submodule path '/paddle/packages/paddlefleet_ops/third_party/fast-hadamard-transform' failed
fatal: unable to access 'https://github.com/PaddlePaddle/flash-attention.git/': CONNECT tunnel failed, response 502
##[error]Process completed with exit code 1.
  • 根因摘要: 代理 502 导致第三方子模块克隆失败

uv build whl 阶段在拉取 packages/paddlefleet_ops/third_party 下的 DeepEP、fast-hadamard-transform、flash-attention 等 submodule 时失败,错误均为 CONNECT tunnel failed, response 502。PR 仅修改 paddle/fluid/framework/operator.{h,cc} 和 Windows 单测 skip list,与 Fleet 第三方依赖拉取路径无直接关联,因此判定为 CI 网络/代理环境问题。

修复建议:

  1. 环境问题,请 rerun;若重复出现,检查 CI 代理到 GitHub/PFCCLab 仓库的网络连通性或为这些 submodule 配置稳定镜像。

关联变更: 未发现与本 PR 修改文件直接关联。

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

错误类型: 未知 | 置信度: 低
分析器: 通用分析(fallback)
失败用例: 未能提取具体失败用例

用例 错误摘要
Test with mac python3.10 深度日志正文不可用,仅确认测试步骤以 exit code 8 失败

关键日志:

(日志获取失败,无法提取错误信息)
Process completed with exit code 8.
  • 根因摘要: Mac 测试日志不可用,无法定位

单 Job 深度日志只返回失败步骤 Test with mac python3.10,未返回 step_loglog_file_pathunittest_details,因此无法定位具体测试、断言或环境错误。结合 PR 内容看,本次变更主要面向 Windows DLL 边界下的 operator kernel registry 导出,未发现与 Mac 测试路径的直接关联;当前只能低置信度标记为未知。

修复建议:

  1. 重新触发该 Job 或补齐可读的 Mac 测试日志后再分析;若重跑仍失败,优先查看 Test with mac python3.10 的完整测试输出。

关联变更: 未发现与本 PR 修改文件直接关联。

@ShigureNyako

Copy link
Copy Markdown
Contributor

观察更新(还是只聚焦 clone / source artifact):

  • PaddlePaddle/Paddle#79422 后面又跑了一次 CI / Clone-linux / Clone Paddlejob 85256304662,状态 success,runner 是 instance-occt1ls7-4-4,host instance-occt1ls7-4,workspace /home/paddle-4/actions-runner/_work/Paddle/Paddle,时间 20:11–20:14 UTC
  • 这次没有落到前面下线等待清理的 instance-occt1ls7-4 /home/paddleinstance-occtls7-4-3 /home/paddle-3,所以还不能验证这两个 workspace 清理后的效果。
  • 但用这次 /home/paddle-4 clone artifact 跑起来后,前面受 source artifact 影响的几条主线已经过了:SOT、Linux-CPU、Distribute、Linux-XPU、Linux-DCU、Mac-CPU 都是 success;之前那类 git checkout -- . / pathspec 的外部依赖 patch 失败没有再出现。
  • 当前剩余失败看起来不是 clone artifact 问题:[release/3.4][Build][CI] Switch pocketfft submodule URL to GitHub mirror #79422 的 IXUCA 是 rebase/revert 冲突,Api-Benchmark 也是另一条;[Windows] export operator kernel registry #79419 现在剩的 Fleet single-card 是 60min timeout,和这次 clone/submodule 问题无关。

结论:目前 clone 问题看起来已经通过避开 /home/paddle/home/paddle-3 的坏 slot 得到规避;待这两个 workspace 清理并重新上线后,再看它们第一次接到 clone job 时是否还会产出坏 artifact。现在不需要对 #79419 代码做动作。

PaddlePaddle-bot

This comment was marked as outdated.

@ShigureNyako

Copy link
Copy Markdown
Contributor

新 head 9942af8031545d900bfe47472a3301cc9d7cca70 的 clone / artifact 再看了一轮:

job 状态 runner / workspace 备注
Clone-linux 85284842983 success instance-occt1ls7-4-4 / /home/paddle-4/actions-runner/_work/Paddle/Paddle 上传 PR/Paddle/.../Paddle.tar.gz
Clone-linux 85284849244 success instance-occt1ls7-4-4 / /home/paddle-4/actions-runner/_work/Paddle/Paddle 上传 PR/Paddle-build/.../Paddle.tar.gz
Coverage clone 85284841107 success instance-occt1ls7-4-4 / /home/paddle-4/actions-runner/_work/Paddle/Paddle 上传 PR/Paddle-coverage/.../Paddle.tar.gz
Coverage clone 85284897605 success instance-occt1ls7-4-2 / /home/paddle-2/actions-runner/_work/Paddle/Paddle 上传 PR/h-ci/.../Paddle.tar.gz

这次还是没有跑到前面下线等待清理的 /home/paddle/home/paddle-3,所以还不能验证那两个 workspace 清理后的效果。

当前几个新失败和之前 pathspec / extern_sleef 的 source artifact 问题不是同一个现象:

  • Linux-CPU 85285808559PR-CI-SOT 85285808561PR-CI-Inference 85286027896 都是在 Download paddle.tar.gz ... 步骤里 wget -q --tries=5 --no-proxy .../Paddle.tar.gz 之后直接 exit code 4,发生在解压/merge/submodule 之前;日志里没有之前那种 git checkout -- . / error: pathspec
  • 我本机对对应 BOS URL 做 curl -I 现在是 200,能看到对象已经存在(例如 PR/Paddle/...PR/Paddle-build/...PR/Paddle-coverage/...PR/h-ci/...)。所以这轮更像下载链路/对象可见性时序问题,优先重跑这些下载失败的 job 即可,不像是 PR 代码或 source artifact 内容损坏。

结论:新 head 的 Linux clone job 都是绿的;之前的 submodule/pathspec 问题没有复现。当前需要继续观察下游 rerun,以及等 /home/paddle/home/paddle-3 清理后重新上线时的第一次 clone。

@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-06 21:08:12 Asia/Shanghai

📋 Review 摘要

PR 概述:将 OperatorWithKernel::AllOpKernels() 的 legacy Fluid kernel registry 从 header inline 局部静态移动到 operator.cc,并放开 Windows-Inference 的 operator_test

变更范围paddle/fluid/framework/operator.*tools/windows/run_unittests.sh

影响面 TagOperator Mechanism Execute Infrastructure

问题

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

📝 PR 规范检查

标题当前使用 [Windows],该 Tag 不在 Paddle PR 模板枚举中;描述结构和“是否引起精度变化”字段符合规范。

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

  • [Operator Mechanism] export operator kernel registry
PR 描述建议(点击展开,可直接复制)
### PR Category
<!-- One of [ User Experience | Execute Infrastructure | Operator Mechanism | CINN | Custom Device | Performance Optimization | Distributed Strategy | Parameter Server | Communication Library | Auto Parallel | Inference | Environment Adaptation ] -->
Operator Mechanism

### PR Types
<!-- One of [ New features | Bug fixes | Improvements | Performance | BC Breaking | Deprecations | Docs | Devs | Not User Facing | Security | Others ] -->
Bug fixes

### Description
<!-- Describe what you’ve done -->`OperatorWithKernel::AllOpKernels()``operator.h` 的 header inline 实现移动到 `operator.cc`,并在声明处使用 `PADDLE_API` 导出,避免 Windows DLL 边界下测试 exe 与 `libpaddle.dll` 各自持有一份 Fluid op kernel registry。

影响范围:legacy Fluid `OperatorWithKernel` kernel registry。

验证方式:`prek --files paddle/fluid/framework/operator.h paddle/fluid/framework/operator.cc`

### 是否引起精度变化
<!-- one of the following [ 是 | 否 ]-->

总体评价

本轮按 diff 回溯了 legacy kernel registry 的注册/查询路径、TEST_API 条件展开和 Windows skip list 使用点,未发现需要阻塞合入的代码问题。建议按 Paddle PR 标题 Tag 规范调整标题。

@gouzil

gouzil commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

@ShigureNyako 来 review 一下这个 pr

@swgu98
swgu98 merged commit 9717bfc into PaddlePaddle:develop Jul 7, 2026
129 of 132 checks passed
@SigureMo
SigureMo deleted the codex/export-all-op-kernels branch July 7, 2026 09:04
@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.

8 participants