Skip to content

Commit

Permalink
fix enable memory efficient attention on ROCm
Browse files Browse the repository at this point in the history
while calling CK implementation
  • Loading branch information
tenpercent committed Jan 15, 2025
1 parent b0c8973 commit 36d34fd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/diffusers/models/attention_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,12 @@ def set_use_memory_efficient_attention_xformers(
else:
try:
# Make sure we can run the memory efficient attention
_ = xformers.ops.memory_efficient_attention(
torch.randn((1, 2, 40), device="cuda"),
torch.randn((1, 2, 40), device="cuda"),
torch.randn((1, 2, 40), device="cuda"),
)
dtype = None
if attention_op is not None:
op_fw, op_bw = attention_op
dtype = list(op_fw.SUPPORTED_DTYPES)[0]
q = torch.randn((1, 2, 40), device="cuda", dtype=dtype)
_ = xformers.ops.memory_efficient_attention(q, q, q)
except Exception as e:
raise e

Expand Down

0 comments on commit 36d34fd

Please sign in to comment.