-
Notifications
You must be signed in to change notification settings - Fork 30.9k
NPU support SDPA #35165
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
NPU support SDPA #35165
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR ! Is there a link that shows that npu is compatible with sdpa from torch 2.1.0 ? Also let us know when this is ready to be reviewed !
@SunMarc Thanks for your reply, this PR ready to be reviewed. Some explanations and tests are as follows. NPU supports SDPA in torch>=2.1.0To use SDPA in NPU, simply import torch_npu.
For NPU
NPU is OK with non-contiguous inputs in torch>=2.1.0According to the issue 112577, transformers requires torch>=2.1.1 to avoid a numerical issue in SDPA with non-contiguous. Test this issue in the same code. NPU can avoid this issue in torch>=2.1.0.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice thanks for the explanation !
@SunMarc @ArthurZucker |
Okay to be merged for me ! cc @ArthurZucker |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
Co-authored-by: root <[email protected]>
What does this PR do?
add features: Ascend NPU supports SDPA.
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
notes
Ascend NPU requires torch>=2.1.0 to use SDPA in Transformers.