Fix: restore boolean attention mask handling in _naive_prompt_attention#1
Draft
Copilot wants to merge 1 commit into
Draft
Fix: restore boolean attention mask handling in _naive_prompt_attention#1Copilot wants to merge 1 commit into
Copilot wants to merge 1 commit into
Conversation
The boolean mask handling for attn_bias was accidentally removed in commit f337029 (Enable slicing for fp8 FusedSDPA vllm-project#1285). When attn_bias is a boolean tensor, the code should use masked_fill to set invalid positions to -inf, but instead it was using add_ which only adds 0/1 to the attention weights. This causes incorrect attention scores and accuracy degradation, especially for long prompts where proper masking of padded positions is critical. Signed-off-by: copilot <copilot@github.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: JyhWind <40982453+JyhWind@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
JyhWind
May 19, 2026 05:43
View session
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.
Summary
Restores boolean attention mask handling in
_naive_prompt_attentionthat was accidentally removed in commit f337029 (Enable slicing for fp8 FusedSDPA vllm-project#1285).Problem
When
attn_biasis a boolean tensor (e.g., from the Boolean attention mask introduced in vllm-project#1032),attn_weights.add_(attn_bias)only adds 0 or 1 to the attention weights instead of masking invalid positions with-inf. This causes incorrect attention scores and potential accuracy degradation, especially for long prompts where proper masking of padded positions is critical.Fix
Restore the original boolean mask check in
_naive_prompt_attention(vllm_gaudi/extension/ops.py):attn_bias.dtype == torch.bool: usemasked_fill(~attn_bias, float("-inf"))to properly mask invalid positionsadd_path for float-type attention biasesNote
This fix should also be cherry-picked to the
aicebranch asaice_patch. The same fix is available on the localaice_patchbranch (commit4b17717), based onorigin/aice.Signed-off-by: copilot copilot@github.com