Fix for Unet NaNs

This commit is contained in:
brkirch 2023-04-14 02:22:48 -04:00
parent 5ab7f213be
commit 7aab389d6f
1 changed files with 3 additions and 0 deletions

View File

@ -256,6 +256,9 @@ def sub_quad_attention_forward(self, x, context=None, mask=None):
k = k.unflatten(-1, (h, -1)).transpose(1,2).flatten(end_dim=1)
v = v.unflatten(-1, (h, -1)).transpose(1,2).flatten(end_dim=1)
if q.device.type == 'mps':
q, k, v = q.contiguous(), k.contiguous(), v.contiguous()
dtype = q.dtype
if shared.opts.upcast_attn:
q, k = q.float(), k.float()