Skip to content

Fix attention mask to use float_lowest instead of -inf and add NaN-safe softmax handling#2654

Merged
justinchuby merged 4 commits intomicrosoft:mainfrom
Aniketsy:fix/2561
Feb 3, 2026
Merged

Fix attention mask to use float_lowest instead of -inf and add NaN-safe softmax handling#2654
justinchuby merged 4 commits intomicrosoft:mainfrom
Aniketsy:fix/2561

Conversation

@Aniketsy
Copy link
Contributor

#2561

  • Use lowest representable float value instead of -inf for attention masks.
  • Add NaN-safe handling and a unit test for softmax with all masked positions.

Please let me know if my approach or fix needs any improvements . I’m open to feedback and happy to make changes based on suggestions.
Thankyou !

@Aniketsy
Copy link
Contributor Author

@microsoft-github-policy-service agree

@justinchuby
Copy link
Collaborator

If this PR is facilitated by an AI, please disclose its usage.

@codecov
Copy link

codecov bot commented Oct 26, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.45%. Comparing base (a9cb429) to head (72b2c2c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
onnxscript/function_libs/torch_lib/ops/nn.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2654   +/-   ##
=======================================
  Coverage   70.45%   70.45%           
=======================================
  Files         228      228           
  Lines       27177    27177           
  Branches     2734     2734           
=======================================
  Hits        19148    19148           
  Misses       7092     7092           
  Partials      937      937           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Aniketsy
Copy link
Contributor Author

Aniketsy commented Oct 26, 2025

I went through the questions you mentioned and yes, i used AI assistance to help add the unit test.

@justinchuby justinchuby added the module: torchlib Related to the torch/aten function lib in development label Jan 6, 2026
@justinchuby justinchuby self-assigned this Jan 6, 2026
Copy link
Collaborator

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

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

I think this is reasonable. @xadupre @titaiwangms what do you think?

@titaiwangms
Copy link
Contributor

Yeah, that's also what ort folk would suggest: microsoft/onnxruntime#27129 (comment)

@justinchuby justinchuby added this to the 0.6.0 milestone Jan 27, 2026
@justinchuby
Copy link
Collaborator

@Aniketsy could you fix the lint issues? Thanks

@Aniketsy
Copy link
Contributor Author

Aniketsy commented Feb 3, 2026

@justinchuby fixed lint error.

@github-project-automation github-project-automation bot moved this from Todo to Done in ONNX Script Review Board Feb 3, 2026
@justinchuby justinchuby merged commit 68e0458 into microsoft:main Feb 3, 2026
30 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: torchlib Related to the torch/aten function lib in development

Projects

Development

Successfully merging this pull request may close these issues.

3 participants