Skip to content

Minor test addition for sdpa producing NaNs for pad tokens#40971

Closed
DuyguA wants to merge 3 commits intohuggingface:mainfrom
DuyguA:minor/sdpa-nan-check
Closed

Minor test addition for sdpa producing NaNs for pad tokens#40971
DuyguA wants to merge 3 commits intohuggingface:mainfrom
DuyguA:minor/sdpa-nan-check

Conversation

@DuyguA
Copy link
Copy Markdown
Contributor

@DuyguA DuyguA commented Sep 18, 2025

The issue was fixed from PyTorch side, still I added a quick test to confirm the issue is indeed resolved.

Fixes #31035

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [ x] Did you read the contributor guideline,
    Pull Request section?
  • [ x] Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • [ x] Did you write any new necessary tests?

@github-actions
Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: bert

@Rocketknight1
Copy link
Copy Markdown
Member

cc @Cyrilvallez for attention

@Cyrilvallez
Copy link
Copy Markdown
Member

Hey! Thanks for opening the PR. However, the issue you are referring to is very old and well-known, and we've been working around it for quite some time already. Moreover, our tests run on latest pytorch, so it does not actually test anything.
Closing the PR for now, feel free to reopen if you think we missed something! 🤗

@DuyguA
Copy link
Copy Markdown
Contributor Author

DuyguA commented Sep 19, 2025

Hey! Thanks for opening the PR. However, the issue you are referring to is very old and well-known, and we've been working around it for quite some time already. Moreover, our tests run on latest pytorch, so it does not actually test anything. Closing the PR for now, feel free to reopen if you think we missed something! 🤗

Sure, no worries @Cyrilvallez 🙂 One tiny question, for some reason flash attention is not supported for BERT and T5, I wonder PRs per model would be of interest?

@Cyrilvallez
Copy link
Copy Markdown
Member

Hey! Bert got refactored a few days ago in #38301 to support it. Still not the case for T5 though if you want to try it out!

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.

sdpa for bert casues nan when using bfloat16 with padding.

3 participants