Skip to content

Commit 3258eb3

Browse files
Disable ck attention when fp32 + low_precision_attention False. (#16029)
1 parent 02aa707 commit 3258eb3

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

comfy/ldm/modules/attention.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ def _comfy_kitchen_int8_inputs(q, k, v, heads, mask, skip_reshape, enable_gqa):
603603

604604
@wrap_attn
605605
def attention_comfy_kitchen_int8(q, k, v, heads, mask=None, attn_precision=None, skip_reshape=False, skip_output_reshape=False, **kwargs):
606+
if kwargs.get("low_precision_attention", True) is False and q.dtype == torch.float32:
607+
return attention_pytorch(q, k, v, heads, mask=mask, attn_precision=attn_precision, skip_reshape=skip_reshape, skip_output_reshape=skip_output_reshape, **kwargs)
606608
q, k, v, mask, b, dim_head = _comfy_kitchen_int8_inputs(
607609
q, k, v, heads, mask, skip_reshape, kwargs.get("enable_gqa", False)
608610
)
@@ -622,6 +624,8 @@ def _attention_comfy_kitchen_int8_containers(q, k, v, heads, mask=None, attn_pre
622624
q = q.take()
623625
k = k.take()
624626
v = v.take()
627+
if kwargs.get("low_precision_attention", True) is False and q.dtype == torch.float32:
628+
return attention_pytorch(q, k, v, heads, mask=mask, attn_precision=attn_precision, skip_reshape=skip_reshape, skip_output_reshape=skip_output_reshape, **kwargs)
625629
q, k, v, mask, b, dim_head = _comfy_kitchen_int8_inputs(
626630
q, k, v, heads, mask, skip_reshape, kwargs.get("enable_gqa", False)
627631
)

0 commit comments

Comments
 (0)