-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SOT][3.13] eval_frame
support python 3.13
#69126
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
if sys.version_info >= (3, 13): | ||
# in 3.13, the frame_obj.f_code is f_executable | ||
if frame_obj.f_executable.co_name == "add": | ||
return code | ||
return CustomCode( | ||
code=frame_obj.f_executable, disable_eval_frame=True | ||
) # do nothing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv run -p 3.13 --no-project test.py
> /Users/nyakku/Projects/Paddle/test.py(6)fn()
-> breakpoint()
(Pdb) f = inspect.currentframe()
(Pdb) f.f_code
<code object <module> at 0x10431ca80, file "<stdin>", line 1>
(Pdb) f.f_executable
*** AttributeError: 'frame' object has no attribute 'f_executable'
(Pdb)
python 端界面上好像没改?好像还有 f_code
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2024-11-02 01:49:05 File "/usr/local/lib/python3.12/dist-packages/paddle/jit/sot/opcode_translator/executor/opcode_executor.py", line 1663, in _prepare_virtual_env
2024-11-02 01:49:05 for name, value in self._frame.f_locals.items():
2024-11-02 01:49:05 ^^^^^^^^^^^^^^^^^^^^
2024-11-02 01:49:05 SystemError: error return without exception set
没太看出来,为啥会影响到 3.12
#define PY_3_10_PLUS (PY_VERSION_HEX >= PY_3_10_0_HEX) | ||
#define PY_3_11_PLUS (PY_VERSION_HEX >= PY_3_11_0_HEX) | ||
#define PY_3_12_PLUS (PY_VERSION_HEX >= PY_3_12_0_HEX) | ||
#define PY_3_13_PLUS (PY_VERSION_HEX >= PY_3_13_0_HEX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没太看出来,为啥会影响到 3.12
得加括号,不然 !PY_3_13_PLUS
会有问题
PyObject *locals = Internal_PyFrame_GetLocals(frame, 0); | ||
if (locals == NULL) { | ||
return -1; | ||
} | ||
Py_DECREF(locals); | ||
#endif | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注意 3.13 是将 PyFrame_FastToLocalsWithError
变为无操作,因为这个接口会被弃用并删除,而我们这里在 3.11+ 以来对齐的是 _PyFrame_FastToLocalsWithError
,这个接口在 python/cpython#115153 被直接删除,但并不是不需要了,而是使用了替代方案,主要是 _PyFrame_GetLocals
可以参考 python/cpython#115153 中的替换 _PyFrame_FastToLocalsWithError
的使用方式,我们可以也直接替换下,3.13 我们就不用编 Internal_PyFrame_FastToLocalsWithError
这个接口了
debug 版本的报错可能是因为这个原因,可以试下
改动动机可以看看 PEP 667
非 debug 版本 Linux 下验证通过,这个问题解决后感觉就可以合入了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在没有使用 GetLocals
基本 case 能过,但后续需要注意下是否有问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在使用 debug 版 python
问题确认升级 pybind11 到 2.13.6 可解 |
eval_frame
support python 3.13
PR Category
Execute Infrastructure
PR Types
New features
Description
改名
Internal_PyInterpreterFrame_GetLine
->Internal_PyUnstable_InterpreterFrame_GetLine
Internal_PyEvalFrameClearAndPop
->Internal_PyEval_FrameClearAndPop
TODO
由于f_code
的修改, 大概有 8 个文件需要相关适配debug 模式还没测f_locals
会出现问题, 见: [SOT][3.13]eval_frame
support python 3.13 #69126 (comment)