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.

Avoid torch compile graphbreak for older pytorch versions (#9344)

Xiangxi Guo (Ryan)f0d5d0111f1f
diff --git a/comfy/ops.py b/comfy/ops.py
index be312d714..2be35f76a 100644
--- a/comfy/ops.py
+++ b/comfy/ops.py
@@ -41,9 +41,11 @@ try:
SDPA_BACKEND_PRIORITY.insert(0, SDPBackend.CUDNN_ATTENTION)
- @sdpa_kernel(backends=SDPA_BACKEND_PRIORITY, set_priority=True)
def scaled_dot_product_attention(q, k, v, *args, **kwargs):
- return torch.nn.functional.scaled_dot_product_attention(q, k, v, *args, **kwargs)
+ # Use this (rather than the decorator syntax) to eliminate graph
+ # break for pytorch < 2.9
+ with sdpa_kernel(SDPA_BACKEND_PRIORITY, set_priority=True):
+ return torch.nn.functional.scaled_dot_product_attention(q, k, v, *args, **kwargs)
except (ModuleNotFoundError, TypeError):
logging.warning("Could not set sdpa backend priority.")