You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or 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提交成功,感谢你对开源项目的贡献!
请关注后续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.
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses a bug in the caching of meta information by introducing deep copy operations to prevent shared mutable SymbolicVariables causing incorrect reuse of meta info in different TensorVariables.
Introduces a "copy" parameter in the Cache class to enable deep copying on cache hits.
Adds custom deepcopy implementations for DistInfo and MetaInfo to ensure fresh copies.
Updates InferMetaCache and LayerInferMetaCache to use deep-copied outputs from the cache.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File
Description
python/paddle/jit/sot/utils/utils.py
Adds a "copy" flag to the Cache class and deep-copy logic when a cache hit occurs.
python/paddle/jit/sot/infer_meta.py
Implements custom deepcopy methods for DistInfo and MetaInfo and applies deep copy in caches.
Comments suppressed due to low confidence (2)
python/paddle/jit/sot/utils/utils.py:271
[nitpick] The parameter and attribute 'copy' might be confused with the imported 'copy' module. Consider renaming it to 'do_deepcopy' for improved clarity.
def __init__(self, weak=False, copy=False):
python/paddle/jit/sot/infer_meta.py:281
Ensure that fields such as 'name', 'persistable', 'type', and 'place' in MetaInfo are immutable or intentionally shared; if they are mutable, they should be deep-copied to avoid unintended shared state.
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
#71932 在 MetaInfo 处确保不 copy 新的 shape 来保证同一个
TensorVariable
中 shape 里的SymbolicVariable
一定是 cache 住的,不会调两次 shape 创建的SymbolicVariable
不同但这暴露了另一个问题,因为我们 InferMeta 是有 cache 的,cache 后的 shape 一定是同一个对象,因此一旦两个 TensorVariable 因为 InferMetaCache 命中,那么就会共享同一个
meta.shape
了,这就导致这个 list 对应的 data proxy 是同一个,里面的SymbolicVariable
也是同一个,就出现了多个TensorVariable
的 shape 使用同一个SymbolicVariable
的问题比如
这里从 cache 里拿到的符号就错了,其实应该是互不相关的
[S6, S7]
因此在
InferMetaCache
里加了 copy 参数,在输出前deepcopy
一下,以免共享类似可变对象导致错误命中 cache 的问题