Skip to content
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

Fix enable memory efficient attention on ROCm #10564

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tenpercent
Copy link

@tenpercent tenpercent commented Jan 13, 2025

What does this PR do?

Fix enable memory efficient attention on ROCm while calling CK implementation

https://github.com/facebookresearch/xformers/blob/main/xformers/ops/fmha/ck.py#L157

Bug cause: the only supported dtypes by the op are float16 and bfloat16, and by default the input tensor is initialized as float32, which prevents using memory efficient attention on ROCm
Bug fix: pick a supported dtype when a custom attention op is passed as an argument
Note: attention op is not a Callable but a pair of (forward, backward) op implementations
https://github.com/facebookresearch/xformers/blob/main/xformers/ops/fmha/__init__.py#L202
https://github.com/facebookresearch/xformers/blob/main/xformers/ops/fmha/common.py#L469

Fixes # (issue)

Before submitting

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.

while calling CK implementation
refactor of picking a set element
@tenpercent tenpercent marked this pull request as ready for review January 15, 2025 20:43
@a-r-r-o-w a-r-r-o-w requested a review from DN6 January 23, 2025 21:42
@HuggingFaceDocBuilderDev

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.

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.

2 participants