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

[NPU]Custom fusion operator unification #8431

Merged
merged 34 commits into from
May 14, 2024
Merged

[NPU]Custom fusion operator unification #8431

merged 34 commits into from
May 14, 2024

Conversation

Galaxy1458
Copy link
Contributor

@Galaxy1458 Galaxy1458 commented May 13, 2024

PR types

Others

PR changes

Models

Description

Custom fusion operator unification

Copy link

paddle-bot bot commented May 13, 2024

Thanks for your contribution!

Copy link

codecov bot commented May 13, 2024

Codecov Report

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

Project coverage is 55.42%. Comparing base (17fb497) to head (0a6d6b8).
Report is 1 commits behind head on develop.

Files Patch % Lines
paddlenlp/transformers/llama/fusion_ops.py 22.50% 62 Missing ⚠️
paddlenlp/transformers/llama/modeling.py 40.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8431      +/-   ##
===========================================
- Coverage    55.43%   55.42%   -0.01%     
===========================================
  Files          616      617       +1     
  Lines        96243    96281      +38     
===========================================
+ Hits         53348    53366      +18     
- Misses       42895    42915      +20     

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

@Galaxy1458 Galaxy1458 changed the title fix [NPU]Custom fusion operator unification May 13, 2024
Copy link
Contributor

@SylarTiaNII SylarTiaNII 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 previously approved these changes May 14, 2024
Copy link
Collaborator

@wawltor wawltor left a comment

Choose a reason for hiding this comment

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

LGTM

flash_attention = None


def fusion_rope(query_states, key_states, value_states, hidden_states, position_ids, past_key_value, rotary_emb):
Copy link
Collaborator

Choose a reason for hiding this comment

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

fusion_rope、fusion_flash_attention这种太长了就不建议去抽取了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已经将paddlenlp/transformers/fusion_ops.py 移动到paddlenlp/transformers/llama/fusion_ops.py

@@ -81,14 +80,16 @@ def swiglu(x, y=None):

try:
if get_env_device() == "npu":
from paddle.base import core

for lib in os.listdir(os.getenv("CUSTOM_DEVICE_ROOT")):
if lib.endswith(".so"):
paddle.utils.cpp_extension.extension_utils.load_op_meta_info_and_register_op(lib)
Copy link
Collaborator

Choose a reason for hiding this comment

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

注意看是不是有不需要的代码,注意删除掉。

@wawltor wawltor merged commit 05acad5 into PaddlePaddle:develop May 14, 2024
8 of 11 checks passed
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.

4 participants