Skip to content

[V0.9.1] Replace FA interface with FA_V2 to optimize perf in SelfAttention #1701

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

Open
wants to merge 1 commit into
base: v0.9.1-dev
Choose a base branch
from

Conversation

rjg-lyh
Copy link
Contributor

@rjg-lyh rjg-lyh commented Jul 9, 2025

What this PR does / why we need it?

Due to the lack of support for passing compressed masks in the FA interface, performance significantly degraded in long-sequence scenarios, even leading to functional issues such as OOM errors. Therefore, I switched to using the FA_V2 interface for the selfattention computation, ensuring functionality while greatly improving performance.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

CI passed with existing test.

Signed-off-by: rjg-lyh <1318825571@qq.com>
num_heads=self.num_heads,
num_kv_heads=self.num_kv_heads,
out=output)
torch_npu.atb._npu_flash_attention_v2(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you have the performance data for this PR?

@weijinqian0
Copy link
Contributor

Operating during the prefill phase can save on HBM activation and improve FA computation efficiency, especially in long sequence scenarios.

@rjg-lyh rjg-lyh closed this Jul 22, 2025
@rjg-lyh rjg-lyh deleted the pr-fa branch July 22, 2025 12:14
@rjg-lyh rjg-lyh restored the pr-fa branch July 22, 2025 12:15
@rjg-lyh rjg-lyh reopened this Jul 22, 2025
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