-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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.11] fix eval frame for python 3.11 #57490
Merged
SigureMo
merged 8 commits into
PaddlePaddle:develop
from
cattidea:sot/fix-eval-frame-311
Sep 21, 2023
Merged
[SOT][3.11] fix eval frame for python 3.11 #57490
SigureMo
merged 8 commits into
PaddlePaddle:develop
from
cattidea:sot/fix-eval-frame-311
Sep 21, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
你的PR提交成功,感谢你对开源项目的贡献! |
This was referenced Sep 21, 2023
SigureMo
changed the title
[SOT] fix eval frame for python 3.11
[SOT][3.11] fix eval frame for python 3.11
Sep 21, 2023
2742195759
approved these changes
Sep 21, 2023
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.
LGTM
Frida-a
pushed a commit
to Frida-a/Paddle
that referenced
this pull request
Oct 14, 2023
* [SOT] fix eval frame for python 3.11 * fix missing `()` * fix no Paddle_PyInterpreterFrameProxyType in < 3.11 * `Paddle_PyInterpreterFrameProxy` -> `PyInterpreterFrameProxy` * compat for eval_custom_code * clean callback result is None logic * refine internal API name * refine comments
jiahy0825
pushed a commit
to jiahy0825/Paddle
that referenced
this pull request
Oct 16, 2023
* [SOT] fix eval frame for python 3.11 * fix missing `()` * fix no Paddle_PyInterpreterFrameProxyType in < 3.11 * `Paddle_PyInterpreterFrameProxy` -> `PyInterpreterFrameProxy` * compat for eval_custom_code * clean callback result is None logic * refine internal API name * refine comments
danleifeng
pushed a commit
to danleifeng/Paddle
that referenced
this pull request
Nov 14, 2023
* [SOT] fix eval frame for python 3.11 * fix missing `()` * fix no Paddle_PyInterpreterFrameProxyType in < 3.11 * `Paddle_PyInterpreterFrameProxy` -> `PyInterpreterFrameProxy` * compat for eval_custom_code * clean callback result is None logic * refine internal API name * refine comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
Bug fixes
PR changes
Others
Description
PyInterpreterFrame
创建PyFrameObject
,但是这样是有可能影响原来的PyInterpreterFrame
的,这就导致在发生 Fallback 时,需要跑原来的PyInterpreterFrame
,而这个影响可能就会导致段错误,目前的test_tensor_dtype_in_guard
单测就是因为这个原因,修改后已正常通过PyFrameObject
,是一个PyObject
,因此可以直接传递给 Python 端,但 Python 3.11 不是这样的,而如果通过上面说的的方式从PyInterpreterFrame
创建PyFrameObject
则会产生影响,因此我们需要使用其他方式来创建一个PyObject
传递给 Python 端 eval frame callback,这里创建了一个数据 Proxy 类PyInterpreterFrameProxy
,就是代理了其内部的PyInterpreterFrame
,用来间接访问f_code
、f_globals
、f_locals
、f_builtins
属性,我们目前只访问了这四个属性,因此不会有问题,相关参考如下:eval_custom_code
中,我们会创建一个 shadow frame,在 3.8-3.10 我们会利用PyFrame_New
创建PyFrameObject
,但这也是有问题的,这样创建的PyFrameObject
会强行 complete,见 https://github.com/python/cpython/blob/17a335dd0291d09e1510157a4ebe02932ec632dd/Objects/frameobject.c#L1070 ,这会导致RESUME
之前的,包括RESUME
都不会跑到,其中包括了MAKE_CELL
,为了避免这一问题,我们需要寻找其他的创建新 Frame 的方法eval_custom_code
中,3.11 fastlocals 布局与之前版本是不一样的,通过co_localsplusnames
可以获得 index -> name 的映射关系,因此利用 old 初始化 new 时候需要new[new_idx] = old[old_idx]
,即new[new_name_to_idx[old_idx_to_name[old_idx]]] = old[old_idx]
_custom_eval_frame
中 callback 返回None
的情况,我们现在永远只会返回CustomCode
PCard-66972