From 3f8da51eac6b1ffb543615ed5edbfe93647a09e0 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Sun, 11 Feb 2024 13:44:39 +0300 Subject: [PATCH] Set default atten for ROCm to SDP --- CHANGELOG.md | 5 +++-- modules/sd_hijack_dynamic_atten.py | 8 ++++++-- modules/shared.py | 4 +--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1486b7e3e..b98347037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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* diff --git a/modules/sd_hijack_dynamic_atten.py b/modules/sd_hijack_dynamic_atten.py index d9881beb7..2ccc81e77 100644 --- a/modules/sd_hijack_dynamic_atten.py +++ b/modules/sd_hijack_dynamic_atten.py @@ -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 """ diff --git a/modules/shared.py b/modules/shared.py index 86818f290..7082be669 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -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"