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

[Inference]add blha_get_max_len op & modify block_multihead_attention op #64246

Merged
merged 10 commits into from
May 21, 2024

Conversation

ming1753
Copy link
Contributor

@ming1753 ming1753 commented May 13, 2024

PR Category

Inference

PR Types

New features

Description

Pcard-71500

新增算子:blha_get_max_len,输入为seq_lens_encoder、seq_lens_decoder、bsz,输出为max_enc_len_this_time、max_dec_len_this_time

使用示例:

import paddle
paddle.device.set_device('gpu')
seq_lens_encoder = paddle.cast(paddle.randn(shape=[10]), dtype=paddle.int32)
seq_lens_decoder = paddle.cast(paddle.randn(shape=[10]), dtype=paddle.int32)
bsz = 10
batch_size = paddle.ones(shape=[bsz])
max_enc_len_this_time, max_dec_len_this_time = paddle.incubate.nn.functional.blha_get_max_len(seq_lens_encoder, seq_lens_decoder, batch_size)

修改block_multihead_attention,新增两个可选参数max_enc_len_this_time和max_dec_len_this_time,在传入时不在kernel内部计算

Copy link

paddle-bot bot commented May 13, 2024

你的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.

carryyu
carryyu previously approved these changes May 16, 2024
>>> batch_size = paddle.ones(shape=[bsz])
>>> max_enc_len_this_time, max_dec_len_this_time = paddle.incubate.nn.functional.blha_get_max_len(seq_lens_encoder, seq_lens_decoder, batch_size)
"""
if in_dynamic_mode():
Copy link
Contributor

Choose a reason for hiding this comment

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

应该in_dynamic_or_pir_mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@carryyu
Copy link
Contributor

carryyu commented May 16, 2024 via email

@jzhang533
Copy link
Contributor

hi, running sample code in paddle.incubate.nn.functional.block_multihead_attention raised NotImplementedError in PR-CI-Static-Check.

btw: change to api no longer requires my approval since #64212 , but please feel free to assign me if you think my review helps.

@ming1753
Copy link
Contributor Author

Thanks for review. PR-CI-Static-Check raised NotImplementedError in because there is no implementation of FlashAttention on it, not PR's fault.

@jzhang533
Copy link
Contributor

I think we have two options:

  • surrounding the sample codes with doctest: +SKIP("reason"), doctest: -SKIP directives to instruct doctest skip running the sample codes.

  • upgrade the env of PR-CI-Static-Check.

@ming1753 ming1753 merged commit 669a261 into PaddlePaddle:develop May 21, 2024
31 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.

None yet

6 participants