[SOT][3.14] Update the internal function to use PyObject_GC_Track replace _PyObject_GC_TRACK#78558
Conversation
… `PyObject_GC_Track`
|
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Pull request overview
This PR fixes CPython 3.14 internal-API integration issues in Paddle’s SOT pybind layer, addressing compilation problems in debug builds by adjusting which CPython headers/APIs are used.
Changes:
- Include
internal/pycore_genobject.hto ensure_PyGen_GetGeneratorFromFrameand related generator internals are available for compilation. - Replace
_PyObject_GC_TRACKusage with the publicPyObject_GC_TrackAPI when tracking frame objects for GC.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| if (!_PyObject_GC_IS_TRACKED((PyObject *)f)) { | ||
| _PyObject_GC_TRACK((PyObject *)f); | ||
| PyObject_GC_Track((PyObject *)f); | ||
| } |
There was a problem hiding this comment.
The PR title says to replace PyObject_GC_Track with _PyObject_GC_TRACK, but the actual change does the opposite (switches _PyObject_GC_TRACK to PyObject_GC_Track). Please update the title (and/or description) to match the implemented fix to avoid confusion for reviewers and release notes.
There was a problem hiding this comment.
The PR title says to replace
PyObject_GC_Trackwith_PyObject_GC_TRACK, but the actual change does the opposite (switches_PyObject_GC_TRACKtoPyObject_GC_Track). Please update the title (and/or description) to match the implemented fix to avoid confusion for reviewers and release notes.
已修正。PR 标题和描述里现在都已经改成实际代码方向:将 _PyObject_GC_TRACK 替换为公开 API PyObject_GC_Track。
|
@ShigureNyako 喵子来 review 下,是 #78484 遇到的 SOT CI 问题的修复 PR |
_PyObject_GC_TRACK replace PyObject_GC_Track_PyObject_GC_TRACK replace PyObject_GC_Track
_PyObject_GC_TRACK replace PyObject_GC_Track_PyObject_GC_TRACK replace PyObject_GC_Track
ShigureNyako
left a comment
There was a problem hiding this comment.
这次改动的主线我确认了:它是在修正 Python 3.14 下 SOT cpython_internals 的兼容性问题,实际方向是补齐 _PyGen_GetGeneratorFromFrame 所需的内部头,并把 _PyObject_GC_TRACK 改回公开 API PyObject_GC_Track,不是把修复方向做反了。
我本地按 Python 3.14 头文件做了最小验证:
- 当前
develop版本的paddle/fluid/pybind/sot/cpython_internals/internals_3_14.c会因为缺少<internal/pycore_genobject.h>而直接报_PyGen_GetGeneratorFromFrame未声明; - 只补这个头之后,如果继续保留
_PyObject_GC_TRACK,目标文件会额外依赖私有符号_Py_TriggerGC(在 macOS 下表现为__Py_TriggerGC),链接 Python 3.14 framework 时会 unresolved;改成公开的PyObject_GC_Track后可以正常链接。
所以这次改动修的是根因,不只是表面绕过;并且和 upstream/CPython 3.14 的预期是一致的:Include/objimpl.h 公开导出的是 PyObject_GC_Track,Include/internal/pycore_gc.h 里的 _PyObject_GC_TRACK 仍然是 private/internal 路径。对 ABI / 私有符号风险来说,这个方向也是更安全的。
唯一的小问题是 PR 标题/描述里关于 _PyObject_GC_TRACK 与 PyObject_GC_Track 的替换方向仍然写反了,不过这是表述问题,不影响这次代码本身的正确性。整体代码改动我这边 approve。
_PyObject_GC_TRACK replace PyObject_GC_TrackPyObject_GC_Track replace _PyObject_GC_TRACK
ShigureNyako
left a comment
There was a problem hiding this comment.
已复查最新 head(439ae1119622933f3413186bea1afeaf6f5f1680)。新增提交只是在 .github/workflows/_SOT.yml 中把 SOT 任务的 runner group 从 GZ_BD-CPU 调整为 SOT-314-debug,没有改动前面已经 review 过的 CPython 3.14 兼容性修复逻辑;PR 标题和描述里关于 PyObject_GC_Track / _PyObject_GC_TRACK 的方向也已经修正。
我同步看了当前失败的 CI:
PR-CI-SOT现在报的是numpy在 Python 3.14 环境下module 'numpy' has no attribute 'dtype',属于导入阶段的环境 / 基线问题,不是这次_PyGen_GetGeneratorFromFrame/PyObject_GC_Track改动触发的逻辑回归;Linux-IXUCA失败点是外部Paddle-iluvatarpatch apply 失败,也和这次 SOT 代码改动无直接关系。
基于最新提交内容和当前日志,我这边对这次 PR 的代码结论不变,继续 approve。
|
@ShigureNyako 排查一下 PR-CI-SOT 的日志看看是什么原因导致的 |
我把 关键信息链如下:
我本地单独拿干净的 Python 3.14 环境验证过,正常安装的 NumPy 2.4.2 是有 所以这次 python3.14 -m pip uninstall -y numpy
python3.14 -m pip install --force-reinstall --no-cache-dir 'numpy>=2.3.5'否则现在这种“卸了 2.3.5,但又直接命中残留的 2.4.2”状态,后面 rerun 很可能还会是同样的导入错误。 |
ShigureNyako
left a comment
There was a problem hiding this comment.
最新这笔提交我复查过了:ci/run_sot_test.sh 在 Python 3.14 分支里把
python3.14 -m pip install "numpy>=2.3.5"改成了
python3.14 -m pip install --force-reinstall --no-cache-dir "numpy>=2.3.5"这和上一轮日志分析里定位到的问题是对齐的:之前 PR-CI-SOT 失败的关键不是当前 PR 的 SOT/CPython 3.14 兼容性修复本身,而是 runner 上 Python 3.14 的 NumPy 处在脏环境状态;这次补丁正是在 3.14 特判路径里把 NumPy 重装做实,方向正确。
结合前面已经确认过的两处核心代码修复(补 pycore_genobject.h、改用公开 API PyObject_GC_Track),我这边对最新 head 继续给 approve。当前 PR-CI-SOT 已经基于新提交重新跑起,后续看 rerun 结果即可。
This reverts commit 439ae11.
PR Category
Execute Infrastructure
PR Types
Bug fixes
Description
_PyGen_GetGeneratorFromFrame内部函数编译错误_PyObject_GC_TRACK内部函数因为宏展开导致的更多内部函数使用,报错:undefined symbol: _Py_TriggerGC。 改用公开的 apiPyObject_GC_Track相关链接
是否引起精度变化
否