Skip to content

[Serde][Dy2St] Use cached PartialProgramLayer in jit.load #72103

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

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Apr 7, 2025

PR Category

Execute Infrastructure

PR Types

Bug fixes

Description

jit.load 运行阶段,当 PartialProgramLayer 已经被构造后,不应该重新构造,应该直接复用,否则这会导致:

  • PartialProgramLayer 构造阶段需要每次都重新跑,这包含了前反向拆分等诸多编译期逻辑,不应该在热启动链路执行
  • scope 是在 PartialProgramLayer 上 cache 的,如果 PartialProgramLayer 每次重新构造,那么 scope 必然重新构造,这会导致执行器 cache 无法命中,每次都重新构造执行器,造成非常大的启动开销

同样代码(ResNet50),动转静直接跑 timeline 如下:

image

jit.savejit.load 本 PR 修复前 timeline 如下(慢了十几倍):

image

本 PR 修复后 timeline 如下(和动转静直接跑基本对齐了):

image

另外,因为有一个 TranslatedLayer load 多个 program 的情况,因此需要存多个 PartialProgramLayer,根据 method_name 存在 _partial_program_layers

Copy link

paddle-bot bot commented Apr 7, 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 requested a review from Copilot April 7, 2025 11:04
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Comments suppressed due to low confidence (1)

python/paddle/jit/pir_translated_layer.py:324

  • [nitpick] The parameter name 'input' shadows Python's built-in function. Consider renaming it to 'input_data' to improve clarity.
def _run_dygraph(instance, input, program_holder, method_name):

@SigureMo SigureMo changed the title [Dy2St] Use cached PartialProgramLayer in jit.load [Serde][Dy2St] Use cached PartialProgramLayer in jit.load Apr 7, 2025
@SigureMo SigureMo merged commit fa29e23 into PaddlePaddle:develop Apr 8, 2025
38 checks passed
@SigureMo SigureMo deleted the serde/use-cached-partial-program-layer-in-jit-load branch April 8, 2025 02:44
YqGe585 pushed a commit to YqGe585/Paddle that referenced this pull request May 7, 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.

2 participants