[Dy2St] Record patched name to avoid rollback failures #69940
Merged
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
SOT layer infermeta 需要走 AST 动转静,并在结束后 rollback 回原来的函数,rollback 时候用的是
dygraph_function.__name__
但是在 PaddleNLP 中,部分函数是被 patch 的,
dygraph_function.__name__
和实际 patch 的名字不一样,比如paddle.nn.TransformerEncoderLayer.forward = _transformer_encoder_layer_fwd
,dygraph_function.__name__
为_transformer_encoder_layer_fwd
,因此最后恢复没有恢复到forward
,导致后续 forward 仍然是转静后的函数因此在 patch 时记录到底 patch 到哪个 name 上,以确保最终能正确恢复
https://github.com/PaddlePaddle/PaddleNLP/blob/a5ec6bf623ce8e68ce84e0620d1e195072b25643/paddlenlp/transformers/model_outputs.py#L362-L365
同 #69936,但只是临时解决方案,因为 #69936 有一些坑还不太好解决
PCard-66972