Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Try to fix ace text encoder slowness on some configs. (#12290)

comfyanonymousc8fcbd66eef0
diff --git a/comfy/ops.py b/comfy/ops.py
index 53c5e4dc3..0f4eca7c7 100644
--- a/comfy/ops.py
+++ b/comfy/ops.py
@@ -54,6 +54,8 @@ try:
SDPA_BACKEND_PRIORITY.insert(0, SDPBackend.CUDNN_ATTENTION)
def scaled_dot_product_attention(q, k, v, *args, **kwargs):
+ if q.nelement() < 1024 * 128: # arbitrary number, for small inputs cudnn attention seems slower
+ return torch.nn.functional.scaled_dot_product_attention(q, k, v, *args, **kwargs)
with sdpa_kernel(SDPA_BACKEND_PRIORITY, set_priority=True):
return torch.nn.functional.scaled_dot_product_attention(q, k, v, *args, **kwargs)
else: