[Serde][Dy2St] Use cached PartialProgramLayer in jit.load #72103 
   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 Category
Execute Infrastructure
PR Types
Bug fixes
Description
jit.load运行阶段,当PartialProgramLayer已经被构造后,不应该重新构造,应该直接复用,否则这会导致:PartialProgramLayer构造阶段需要每次都重新跑,这包含了前反向拆分等诸多编译期逻辑,不应该在热启动链路执行scope是在PartialProgramLayer上 cache 的,如果PartialProgramLayer每次重新构造,那么scope必然重新构造,这会导致执行器 cache 无法命中,每次都重新构造执行器,造成非常大的启动开销同样代码(ResNet50),动转静直接跑 timeline 如下:
jit.save再jit.load本 PR 修复前 timeline 如下(慢了十几倍):本 PR 修复后 timeline 如下(和动转静直接跑基本对齐了):
另外,因为有一个
TranslatedLayerload 多个 program 的情况,因此需要存多个PartialProgramLayer,根据method_name存在_partial_program_layers中