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

Add fused_attention_op: add impl wrappers. #35903

Merged
merged 1 commit into from
Sep 23, 2021

Conversation

limin2021
Copy link
Contributor

PR types

Function optimization

PR changes

OPs

Describe

The first PR of "add fused_attention_op":
1.Add impl wrappers for gemm and fmha parts in fused_attention_op.
2.Fix bugs in layer_norm and attn_bias_add.cu.h.
3.Fix bugs in elementwise_op_impl.cu.h for ternary elementwise_add impl.

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@@ -0,0 +1,324 @@
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

fmha_ref.h 是使用 paddle 堆起来的 attn 吗?感觉名字有点歧义,后续可以改下名字。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是使用 paddle 堆起来的 attn。下一个PR修改名字。

@AnnaTrainingG AnnaTrainingG merged commit 88ea8e6 into PaddlePaddle:develop Sep 23, 2021
AnnaTrainingG pushed a commit to AnnaTrainingG/Paddle that referenced this pull request Sep 29, 2021
limin2021 added a commit to limin2021/Paddle that referenced this pull request Oct 24, 2021
lanxianghit pushed a commit that referenced this pull request Oct 25, 2021
功能:本PR的目标是提高attention模块的计算性能。
为了减少框架层对op的调度开销,本PR通过在C++层手动实现attention模块,对外提供attention 大op;
为了减少防存开销,本PR采取了两种优化方法:
(1)在q,k,v计算时通过共享输入X,将该处的gemm,transpose和bias add从三次调用减少为一次;
(2)使用kernel融合优化技术,在不同cuda kernel之间通过寄存器传输数据;
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