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

use tensor.shape bug not paddle.shape(tensor) #8260

Merged
merged 3 commits into from
Apr 16, 2024

Conversation

wanghuancoder
Copy link
Contributor

PR types

Others

PR changes

Others

Description

paddle.shape(tensor)在最新的动转静(SOT)中,会造成子图打断,进而影响模型性能。统一改成tensor.shape。

Copy link

paddle-bot bot commented Apr 11, 2024

Thanks for your contribution!

Copy link

codecov bot commented Apr 15, 2024

Codecov Report

Attention: Patch coverage is 68.63636% with 69 lines in your changes are missing coverage. Please review.

Project coverage is 55.32%. Comparing base (2273ee7) to head (4b044ef).
Report is 20 commits behind head on develop.

Files Patch % Lines
paddlenlp/transformers/transformer/modeling.py 0.00% 12 Missing ⚠️
...lenlp/ops/fast_transformer/transformer/decoding.py 0.00% 7 Missing ⚠️
paddlenlp/transformers/bloom/modeling.py 0.00% 5 Missing ⚠️
paddlenlp/transformers/xlm/modeling.py 50.00% 5 Missing ⚠️
paddlenlp/transformers/xlnet/modeling.py 77.27% 5 Missing ⚠️
paddlenlp/generation/utils.py 20.00% 4 Missing ⚠️
paddlenlp/transformers/gpt/modeling_auto.py 0.00% 4 Missing ⚠️
paddlenlp/transformers/layoutxlm/modeling.py 42.85% 4 Missing ⚠️
...s/fast_transformer/transformer/fast_transformer.py 0.00% 3 Missing ⚠️
paddlenlp/trainer/trainer_compress.py 0.00% 2 Missing ⚠️
... and 16 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8260      +/-   ##
===========================================
+ Coverage    55.15%   55.32%   +0.17%     
===========================================
  Files          601      614      +13     
  Lines        91764    95333    +3569     
===========================================
+ Hits         50611    52747    +2136     
- Misses       41153    42586    +1433     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ZHUI
Copy link
Collaborator

ZHUI commented Apr 16, 2024

为什么会出现这个性能问题呢?之前是推荐使用 paddle.shape的,有段时间 tensor.shape 并不能动转静。
后续新增模型是否要监测 padde.shape 的使用。

Copy link
Collaborator

@ZHUI ZHUI left a comment

Choose a reason for hiding this comment

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

LGTM

@wawltor wawltor merged commit ee88c12 into PaddlePaddle:develop Apr 16, 2024
7 of 10 checks passed
@wanghuancoder
Copy link
Contributor Author

为什么会出现这个性能问题呢?之前是推荐使用 paddle.shape的,有段时间 tensor.shape 并不能动转静。 后续新增模型是否要监测 padde.shape 的使用。

在很早期的基于AST的动转静时,推荐使用paddle.shape,否则无法动转静。但后来AST修复了这个问题。AST也能支持Tensor.shape。
而现在动转静已经默认改用了基于SOT的技术,这种技术对paddle.shape的支持还不够好,会造成动态图转成多个子静态图。paddle.shape在一些场景下会造成子图打断。而静态图子图越多,就会执行效率就会越差。
这个我认为暂时不用监控,因为有些地方是必须使用paddle.shape的。SOT后续也会逐步完善~
但短期,子图打断严重既影响动转静性能,有影响动转静+CINN性能。因此推全修复主要repo~

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