Set default atten for ROCm to SDP

This commit is contained in:
Disty0
2024-02-11 13:44:39 +03:00
parent c61a92d05c
commit 3f8da51eac
3 changed files with 10 additions and 7 deletions
+3 -2
View File
@@ -23,9 +23,10 @@
- **Cross-attention** refactored cross-attention methods, thanks @Disty0
- for backend:original, its unchanged: SDP, xFormers, Doggettxs, InvokeAI, Sub-quadratic, Split attention
- for backend:diffuers, list is now: SDP, xFormers, Batch matrix-matrix, Split attention, Dynamic Attention BMM, Dynamic Attention SDP
note: you may need to update your settings! if you were previously using split-attention, closest match is batch-matrix-matrix
note: you may need to update your settings! Attention Slicing is renamed to Split attention
- for ROCm, updated default cross-attention to Scaled Dot Product
- **Dynamic Attention Slicing**, thanks @Disty0
- dynamically slices attention queries in order to save vram based on query size and slice rate in GB
- dynamically slices attention queries in order to keep them under the slice rate
slicing gets only triggered if the query size is larger than the slice rate to gain performance
*Dynamic Attention Slicing BMM* uses *Batch matrix-matrix*
*Dynamic Attention Slicing SDP* uses *Scaled Dot Product*
+6 -2
View File
@@ -99,8 +99,10 @@ def sliced_scaled_dot_product_attention(query, key, value, attn_mask=None, dropo
class DynamicAttnProcessorSDP:
r"""
dynamically slices attention queries based on query size and slice rate in GB
dynamically slices attention queries in order to keep them under the slice rate
slicing will not get triggered if the query size is smaller than the slice rate to gain performance
slice rate is in GB
based on AttnProcessor V2
"""
@@ -181,8 +183,10 @@ class DynamicAttnProcessorSDP:
class DynamicAttnProcessorBMM:
r"""
dynamically slices attention queries based on query size and slice rate in GB
dynamically slices attention queries in order to keep them under the slice rate
slicing will not get triggered if the query size is smaller than the slice rate to gain performance
slice rate is in GB
based on AttnProcessor V1
"""
+1 -3
View File
@@ -318,9 +318,7 @@ elif devices.backend == "mps":
cross_attention_optimization_default = "Scaled-Dot-Product" if backend == Backend.DIFFUSERS else "Doggettx's"
elif devices.backend == "directml":
cross_attention_optimization_default = "Dynamic Attention BMM" if backend == Backend.DIFFUSERS else "Sub-quadratic"
elif devices.backend == "rocm":
cross_attention_optimization_default = "Dynamic Attention BMM" if backend == Backend.DIFFUSERS else "Sub-quadratic"
else: # cuda and ipex
else: # cuda, rocm, ipex
cross_attention_optimization_default ="Scaled-Dot-Product"