Skip to content
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] Refactor sot simulation to avoid hold real frame in graph and codegen #71275

Conversation

SigureMo
Copy link
Member

PR Category

Execute Infrastructure

PR Types

Devs

Description

重构 SOT pycodegen 和 graph 对 frame 的引用,这些地方都不应该 hold 真实 frame

后续 OpCodeExecutor 同样不会 hold 真实 frame,作为替代,会 hold 一个 VirtualFrame,这个 vframe 会在 OpCodeExecutor 外构造并传入,OpCodeExecutor 本身是无状态的,只用来执行(或弱状态,只持有 stack)

后续会进一步改造,https://github.com/PaddleJitLab/deepdive-python-internals/blob/main/examples/generator.py 这种引用关系才是良好的结构,Frame 后续会作为轻量级的可 dump 和 load 的结构,确保实现生成器时能够实现正确的回退

PCard-66972

Copy link

paddle-bot bot commented Feb 25, 2025

你的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.

@SigureMo SigureMo changed the title [SOT] Refactor sot simulation to avoid hold real frame in graph and codegen [SOT][3.13] Refactor sot simulation to avoid hold real frame in graph and codegen Feb 25, 2025
@SigureMo SigureMo requested a review from Copilot February 25, 2025 11:30

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comments suppressed due to low confidence (1)

python/paddle/jit/sot/opcode_translator/executor/opcode_executor.py:1885

  • The 'frame' parameter is passed but not used in the method body. It should be used to access 'frame.f_code'.
def transform(self, frame: types.FrameType):
@SigureMo SigureMo changed the title [SOT][3.13] Refactor sot simulation to avoid hold real frame in graph and codegen [SOT] Refactor sot simulation to avoid hold real frame in graph and codegen Feb 26, 2025
@SigureMo SigureMo merged commit 34343f5 into PaddlePaddle:develop Feb 26, 2025
33 checks passed
@SigureMo SigureMo deleted the sot/dont-hold-frame-in-graph-and-codegen branch February 26, 2025 02:15
Enigmatisms pushed a commit to Enigmatisms/Paddle that referenced this pull request Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants