Fix additive attention mask handling in the native NPU attention backend. - #14396
Open
mengchengTang wants to merge 1 commit into
Open
Fix additive attention mask handling in the native NPU attention backend.#14396mengchengTang wants to merge 1 commit into
mengchengTang wants to merge 1 commit into
Conversation
mengchengTang
force-pushed
the
fix/native_npu_additive_mask
branch
from
August 5, 2026 15:30
e4a82e0 to
e1962a8
Compare
mengchengTang
force-pushed
the
fix/native_npu_additive_mask
branch
from
August 5, 2026 16:34
e1962a8 to
c9ba560
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes attention mask handling in the native NPU attention backend.
PyTorch SDPA defines two mask formats:
Truemeans attend.Previously,
_native_npu_attentionpassed every mask to_maybe_modify_attn_mask_npu, which casts the mask to boolean and inverts it fornpu_fusion_attention. This works for boolean masks but loses the values and semantics of floating-point additive masks.This PR makes the mask handling explicit:
npu_fusion_attention.No new dependencies are introduced.
Fixes #14397
Before submitting
self-reviewskill on the diff?documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.