KEMBAR78
Fix enable memory efficient attention on ROCm by tenpercent · Pull Request #10564 · huggingface/diffusers · GitHub
Skip to content

Conversation

@tenpercent
Copy link
Contributor

@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.

@DN6
Copy link
Collaborator

DN6 commented Jan 31, 2025

Failing Flax Test is unrelated. Merging.

@DN6 DN6 merged commit 1ae9b05 into huggingface:main Jan 31, 2025
11 of 12 checks passed
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.

3 participants