Skip to content

Conversation

contentis
Copy link
Contributor

Enable cuDNN attention and set it as the highest priority backend. cuDNN SDPA backend performs on-par or sometimes faster than flash-attention backend. More importantly, is the flash-attention backend disabled on windows, falling back to the much slower mem-efficient backend.
On Windows I've seen ~2x speed-up for SDPA kernel on multiple models (FLUX, SDXL, SD3.5 Medium & Large, Qwen).

@comfyanonymous comfyanonymous merged commit 3da5a07 into comfyanonymous:master Aug 13, 2025
6 checks passed
@jurgenprins
Copy link

comfyui does not start anymore; this is what I get now on startup

pytorch version: 2.5.1+cu124
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 3060 : cudaMallocAsync
Traceback (most recent call last):
File "E:\ComfyUI\main.py", line 147, in
import execution
File "E:\ComfyUI\execution.py", line 16, in
import nodes
File "E:\ComfyUI\nodes.py", line 24, in
import comfy.diffusers_load
File "E:\ComfyUI\comfy\diffusers_load.py", line 3, in
import comfy.sd
File "E:\ComfyUI\comfy\sd.py", line 9, in
from .ldm.models.autoencoder import AutoencoderKL, AutoencodingEngine
File "E:\ComfyUI\comfy\ldm\models\autoencoder.py", line 11, in
import comfy.ops
File "E:\ComfyUI\comfy\ops.py", line 82, in
class disable_weight_init:
File "E:\ComfyUI\comfy\ops.py", line 262, in disable_weight_init
@sdpa_kernel(backends=SDPA_BACKEND_PRIORITY, set_priority=True)
File "C:\Program Files\Python310\lib\contextlib.py", line 281, in helper
return _GeneratorContextManager(func, args, kwds)
File "C:\Program Files\Python310\lib\contextlib.py", line 103, in init
self.gen = func(*args, **kwds)
TypeError: sdpa_kernel() got an unexpected keyword argument 'set_priority'

@contentis
Copy link
Contributor Author

@jurgenprins this API was introduced with PyTorch 2.6, can you please try upgrading Torch?

@contentis contentis deleted the sdpa_kernel_selection branch August 14, 2025 08:42
zhangp365 pushed a commit to zhangp365/ComfyUI that referenced this pull request Aug 14, 2025
@jurgenprins
Copy link

@jurgenprins this API was introduced with PyTorch 2.6, can you please try upgrading Torch?

I noted it was due to Torch 2.5.1 thanks!

I am happy fow now to accept that its now in try/catch with a 'cannot set' message, instead of crashing at startup.

I am not sure exactly what would be the benefit of immediate upgrading to make this work perhaps something for the release notes.

In time will try the upgrade, thank you!

@NielsGx
Copy link

NielsGx commented Aug 17, 2025

This won't force replace SageAttention 2++/3, right ?

@contentis
Copy link
Contributor Author

This won't force replace SageAttention 2++/3, right ?

It shouldn't - if you encounter any issues, please let me know and I'll look into it. Feel free to tag me in a related issue.

Vander-Bilt pushed a commit to Vander-Bilt/ComfyUI that referenced this pull request Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants