Skip to content

Commit

Permalink
fix: MacOS MPS background can't handle large slices
Browse files Browse the repository at this point in the history
  • Loading branch information
brycedrennan committed Jan 23, 2023
1 parent bbe3f84 commit 0cdacaa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions imaginairy/modules/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ def forward_splitmem(self, x, context=None, mask=None): # noqa
)

slice_size = q.shape[1] // steps if (q.shape[1] % steps) == 0 else q.shape[1]
if get_device() == "mps":
# https://github.com/brycedrennan/imaginAIry/issues/175
# https://github.com/invoke-ai/InvokeAI/issues/1244
slice_size = min(slice_size, 2**30)

for i in range(0, q.shape[1], slice_size):
end = i + slice_size

Expand Down

0 comments on commit 0cdacaa

Please sign in to comment.