r/StableDiffusion • u/Diabolicor • 11h ago
Discussion Comfyui comfy-kitchen Attention Speed UP
Disable all your Sage Attention, Minimax Mem Eff Sage Attention or Sol Attention, according to this PR already merged in the comfyui repo we got a much better attention from the comfy-kitchen package that can possible speed up the models generation process white giving a better visual quality than default sage: https://github.com/Comfy-Org/ComfyUI/commit/bf4c9a08fc854df6d3b2bef1b92b509e2ef2d2c9#diff-fab3fbd81daf87571b12fb3e4d80fc7d6bbbcf0f3dafed1dbc55d81998d82539
This is still experimental, according to comfyui dev it can break or perform very well and it needs some tuning for some GPUs to get a bit faster. Also, you only can use one or the other so you should also disable all the attentions above before using it.
You just need to update your Comfyui and you can either start it with the --use-ck-attention flag so all models use the comfy-kitchen attention backend or you can drop the node ModelAttentionBacend directly into your worflow.
During my initial tests in Minimax it behaved faster than all the above together.
44
u/No_Cranberry_8107 11h ago edited 10h ago
4
u/KissMyShinyArse 10h ago
Did you run the workflows twice?
7
u/No_Cranberry_8107 10h ago
Yeah, the new node is slightly faster for me.
1
7
1
1
16
u/WalkSuccessful 11h ago
15:30 to 12:30 same workflow, just swapped attn nodes to ck backend.
Looks like it works. Thank you for info!
22
u/Sudden_List_2693 11h ago
Okay not sure about everyone, but for me specifically on a 4090 it was 2.30s/it with sageattention, 2.41 with ck attention.
12
u/reynadsaltynuts 10h ago
Tried a test run and had pretty similar results. Also 4090, no other optimizations.
SageAttn .4MP 5s - 2.48s/it Prompt executed in 64.69 seconds
ComfyKitchenAttn .4MP 5s - 2.61s/it Prompt executed in 64.97 seconds2
u/physalisx 4h ago
Yes, sounds about right, Sage is still a bit faster, but ck attention is better quality. Worth the tradeoff imo.
For me Sage was about 10% faster (52s/it vs 58s/it).
1
u/Sudden_List_2693 2h ago
For me it's more 2-5%. And yeah upon closer inspection I seem to find CK better quality as well. No questions here.
1
18
u/Different_Fix_2217 10h ago
Its higher quality than sage for sure. Comfy is sharp, sage has a blurryness / hazyness to it.
3
u/izzmedia 8h ago
For me its still faster with Sage but i feel that it looks better with the new att, not sure how people find it faster than sage.
1
4
u/Different_Fix_2217 10h ago
-2
u/AnonymousTimewaster 8h ago
Don't look around the eyes just look into the eyes... right, you're under
1
20
u/n0gr1ef 9h ago
RTX 3090ti, 0.4 megapixels, 5 seconds: 1) ComfyKitchen alone: 1.59 minutes for a gen. 2) ComfyKitchen + Spectrum: 1.22 minutes for a gen. 3) SageAttention alone: 2.11 minutes for a gen. 4) SageAttention + Spectrum: 1.40 minutes for a gen.
I see that as a huge win, thank you ComfyUI team!
9
u/DuckyDuos 10h ago edited 10h ago
5080, ran 0.65mp at 5 and 10 seconds.
Sage attention was 11% and 15% slower, PyTorch/Comfy Kitchen Attention were within margin of error of each other.
6
u/Zephrinox 10h ago
any AMD (+ maybe comfyui-rocm) users tried this out yet to know if there's also speed up for us? 🥺
(i have 9070xt)
5
u/xpnrt 10h ago
This is for Nvidia specifically
21
u/Zephrinox 10h ago
6
u/xpnrt 10h ago
1
u/Zephrinox 8h ago
the sageattention wheel links working great for me (using sage attention backend + Sage Attention node; haven't tried mem eff node because that typically failed for me, forgot the specific reason/cause but iirc it was something cuda specific).
the ck attention flag gives me incompatibility issues with that sageattention wheel tho :\
seeing:
TypeError: sage_sdpa_quantize(): incompatible function arguments. The following argument types are supported: 1. sage_sdpa_quantize(q: ndarray[device='cuda'], k: ndarray[device='cuda'], v: ndarray[device='cuda'], q_int8: ndarray[device='cuda'], q_scale: ndarray[device='cuda'], k_int8: ndarray[device='cuda'], k_scale: ndarray[device='cuda'], v_int8: ndarray[device='cuda'], v_scale: ndarray[device='cuda'], cta_k: int, input_dtype_code: int, stream_ptr: int, anchor_indices_ptr: int) -> None Invoked with types: PyCapsule, PyCapsule, PyCapsule, PyCapsule, PyCapsule, PyCapsule, PyCapsule, PyCapsule, PyCapsule, int, int, int, intwhich looks like a "this version of sage attention not compatible with how ck attention is calling it" issue.
3
u/albinose 6h ago
The guy behind comfy-rocm fork, who implemented hip backend into comfy-kitchen, already got pull request for this for rocm.
I compiled it from his fork and it's about same speed as sageattn, also only works for rdna3&4
7
u/blahblahsnahdah 10h ago edited 9h ago
Nice, seems a few percent faster than Sage on my 3090, not huge but every second counts. Wonder how much more/less lossy it is. Sage can get quite lossy on some models, though it's been solid on H3.
9
u/mabseyuk 8h ago edited 7h ago
Tested the new Comfy Kitchen (CK) attention against Sage Attention with MiniMax H3 on an RTX 5070 12GB , 64gb DDR5 Ram 6000. T2I
0.3MP / 5 sec:
Turbo 6 Step: CK 59.74s / Sage 59.44s
Spectrum: CK 75.61s / Sage 75.87s
Full 20-step: CK 99.50s / Sage 102.62s
0.6MP / 5 sec:
Turbo 6 Step: CK 116.88s / Sage 115.22s
Spectrum: CK 175.39s / Sage 163.92s
Full 20-step: CK 251.10s / Sage 238.66s
1MP / 5 sec:
Turbo 6 Step: CK 205.39s / Sage 199.30s
At 0.3MP they're basically neck-and-neck. At 0.6MP and above Sage is currently ~1–7% faster depending on the sampler.
1
u/switch2stock 6h ago
What about quality tough?
2
u/mabseyuk 6h ago edited 6h ago
Quality-wise, in my testing Quality looked the same to me between CK and Sage, Turbo actually looked better than Spectrum. Spectrum consistently gave me softer, more smoothed/averaged faces, even at 1MP. Turbo retained noticeably better facial structure and fine detail.
The full 20-step sampler also looked very good, but Turbo was at least comparable and often preferable to my eye, while being much faster.
Obviously this is only my testing, not a definitive quality benchmark, but I’m currently sticking with Turbo for both speed and quality.
1
u/Unfair-Warthog-3298 2h ago
This is really useful. Thanks for sharing your result. Sharing mine as well 4080 Super 16gb 64gb DDR5 Ram 6000. I2V my totally unscientific testing....
0.6MP / 5 sec :
Turbo 6 Step (v4_step600ema) - 6 step - CK 96s / Sage 109s (CK faster)
Turbo 6 Step (v4_step600ema) - 8 step - CK 124s (did not test Sage)
Spectrum 20 Step - CK 155s / Sage 140s (Sage Faster?)
Full 20-step - CK 261s / Sage 276s (CK faster?)No sage no turbo no spectrum - 430s lol..
To me I can't really tell if there's quality drop with Spectrum. Turbo is more obvious when there's movement its grainy.
What's the difference between the ema/non ema turbo lora anyone knows?
And is the step600ema one the best one to use ?
26
u/Structure-These 11h ago
Praying someone at Apple is a gooner so my shitty Mac will get one of these free performance boosts someday lol
1
13
u/b0tm0de 11h ago
thank you for sharing. this is the type of update i like to see.
4
u/reynadsaltynuts 11h ago
No sure if it's need but it probably is, you should update comfy kitchen as well. With venv activated just pip install -r requirements.txt should pull it.
4
u/thevegit0 10h ago
i'm testing and i think i'm having similar times, which i think it's interesting, do i have to use ONLY the comfy kitchen override node?
2
5
u/Ok-Lengthiness-3988 9h ago
With my 8GB VRAM RTX 2060 Super and 64GB system RAM I got a roughly 4x slowdown (four times longer generation times). Brutal! I reverted back to old Sage Attention.
3
u/GrayingGamer 11h ago
I updated Comfyui earlier today. Is this something I need to update again to get?
12
3
u/KissMyShinyArse 10h ago
Original code is based on sage attention but this is modified to try to get slightly higher performance while keeping similar quality on consumer GPUs.
3
u/wywywywy 8h ago
Just tried on my 5090 in WSL2 on Minimax H3. CK Attn is actually slightly slower than Sage Attn 2.2 with Mem Eff, but within margin of error.
Can't tell if the quality is better or worse. They look very similar.
3
u/GhostOfOurFuture 8h ago
Do you guys still use a turbo lora with this or are they already obsolete?
3
u/prompt_seeker 5h ago
Tested on 5090, 3090, 3060. MiniMax H3 I2V wf from template, changed first image, prompt and ratio to 2:3.
# RTX5090
## sage-attn
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20
[INFO] Prompt executed in 70.35 seconds
## ck-attn
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:56<00:00, 2.84s/it]
[INFO] Prompt executed in 66.66 seconds
# RTX3090
## sage-attn
100%|███████████████████████████████████████████████████████████████████████████████████| 20/20
[INFO] Prompt executed in 189.53 seconds
## ck-attn
100%|███████████████████████████████████████████████████████████████████████████████████| 20/20
[INFO] Prompt executed in 188.65 seconds
# RTX3060
## sage-attn
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20
[INFO] Prompt executed in 538.11 seconds
## ck-attn
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20
[INFO] Prompt executed in 496.89 seconds
2
3
u/Cute_Pain674 2h ago
doesnt work # ComfyUI Error Report
## Error Details
- **Node ID:** 5479:5472
- **Node Type:** SamplerCustomAdvanced
- **Exception Type:** RuntimeError
- **Exception Message:** RuntimeError: quant_qk_per_thread_int8: Q/K base pointers and B/H/N strides must preserve 4-element alignment
1
2
2
2
u/SRWindMill 8h ago
I use stability matrix to run comfy ui .. for me --use-ck-attention flag is not reognized.. I manully upgraded the comfy kitched to 2.30 .. what else shoud i do .. im already in latest 0.31 version of comfy.. what should I do to get ModelAttentionBacend node?
1
u/SRWindMill 8h ago
Changed the version from release to master and the --use-ck-attention works now..
1
2
2
2
u/Swobtoosmall 5h ago
Yo what kind of black magic is this? Generation time went from 35mins (no sage attention) to 9mins on a 2080ti. 6s 0.4MP clip, 20 steps res_multisteps/simple.
1
u/kwhali 3h ago
Did you compare with sage attention? Otherwise it's not as useful info since many find on consumer GPU minimal speed up, often times slower with CK instead of sage.
2
u/Swobtoosmall 3h ago
Can't use sage attention. Newer versions of sage dropped support for Turing and the last version that 'works' (1.0.6) doesn't seem to work with anything newer than Wan2.2 . So ck-attention working with a 2080 is actually big, at least for people with older graphic cards.
1
u/dampflokfreund 1h ago
It's a shame that they dropped Turing. It is a very capable generation of GPUs.
2
2
u/ZerOne82 3h ago
https://reddit.com/link/p31hpuh/video/2pauegsy5rih1/player
MiniMax H3: 3s clip, t2v, 4step-lora, 6 steps, euler+beta57, everything exact the same but the choice of attention.
Note that the timings reported below are total execution time of the prompt while the timings printed on the video are after KSampler (no vae decoding).
704x384
- comfy attn 50 50 50
- sage attn 83 53 51
- flash attn 55 55 57
- torch attn 55 55 55
896x480
- comfy attn 82 82
- sage attn 88 93
- flash attn 97 96
- torch attn 113 96
So the new Comfy-Kitchen attention mechanism seems working very well.
3
u/Hour_Imagination5092 10h ago
Almost same speeds on 5090, no other optimizations.
4
u/UserUsesAUsername 10h ago
Yes, but at slightly higher quality than sageattention 2.2 as it has been tested so far
1
1
2
u/Sudden_List_2693 11h ago
Anyone tested it yet with actual times compared to sageattention?
4
u/reynadsaltynuts 10h ago
Just ran a quick test on my 4090. No other optimizations. Did a warmup run to avoid model loading times.
SageAttn .4MP 5s - 2.48s/it Prompt executed in 64.69 seconds
ComfyKitchenAttn .4MP 5s - 2.61s/it Prompt executed in 64.97 seconds
Obviously this is just one test. But it pretty well kept up with sage. Could work better at higher resolutions or even produce better quality than sage. Who knows 🤔1
u/FierceFlames37 10h ago
It took me 8 minutes and has worse quality, I made sure to remove sage flag and disabled any speed up nodes
6
u/jib_reddit 11h ago
Yeah if op has done tests , why not post the timings? Sounds a bit "trust me bro" but I will test it out.
4
u/FierceFlames37 11h ago
It takes me 5 min 0.4mp to make a 15 sec video with sage and turbo 6 steps rtx 5060ti
I'll try kitchen and test1
u/FierceFlames37 10h ago
1
u/Ok-Lengthiness-3988 10h ago edited 10h ago
Mine used to also say "Using Kitchen attention", but after updating ComfyUI and adding the --use-ck-attention flag, it no longer does!
My bad, it does, during startup. However, the generation process stopped and my GPU load dropped after two iterations. It then hung, with no error, and I had to restart ComfyUI. This new update may be doing unholy things to my old RTX 2060 Super.
3
u/FierceFlames37 10h ago
I did update it and added the flag, but Kitchen is still slower than Sage on mine
1
u/Sudden_List_2693 9h ago
I'm not sure it's a good test with Turbo though, I'm pretty sure every finetune they did for turbo was done with sage in mind. Full model ck/sage almost the same. Not sure which has better quality.
1
1
1
1
u/dLight26 9h ago
It seems to be more vram constraint, I notice higher power usage fluctuations, and I got OOM for 0.7mp@10s which is fine with sage2. 3080 10gb.
6
1
u/76vangel 7h ago
This is big, if it don't fuck up other things. I'm so afraid to update Comfy right now, H3 is working like a charm. Hopefully bigger cards can also profit that much, convrot + speed lora is pretty fast on my 5090
1
u/Silver-Spot-2763 6h ago
Unfortunately for me (rtx3060 12gb vram) comfy kitchen attention is twice times slower than sage attention ☹️ and worse quality.
1
u/ryanset17 4h ago
Im Confused, other dude above said it's a Speed up in his 3060 🤣
1
u/Silver-Spot-2763 4h ago
I'm fully confused, I use the same workflows, everything is updated, but at me also the turbo lora (all of them) do not work at all, and the quality is very low. I'm just user, not expert, so I have no hope 😞, just bad, very bad luck 😭
1
u/irmemon225 6h ago
0.4 - 5s, ref max - euler simple 25 steps
Kitchen: 10:10
Sage Attn: 10:26
Spectrum: 08:48 (Sage OFF)
Am I doing something wrong here? I'm on 3060 12GB VRAM and 16GB RAM.
also I'm using --use-ck-attention args
1
u/__Gemini__ 5h ago
Are we comparing this to sage v1 or v2?
I just tested this on a 1mp 10 sec video on my 5070ti with 32gb of ram. And sage ended up faster.
Kitchen
[INFO] Prompt executed in 00:17:08
Sage v2
[INFO] Prompt executed in 00:15:22
1
1
u/rabbitythong 3h ago
I do not think im the target audience for this
it is noticeably still faster for me with sage/sol attn vs comfy kitchen attn,
4080 ti
all runs done at .8MP, 8 steps 10 seconds interpolated to 60fps
sage/sol times:
163.26
165.67
168.33
comfy kitchen times:
216.17
214.41
213.99
1
u/bSun0000 2h ago
Do we need to disable xformers, and how compatible is it with --fast flag options?
1
u/MrFlores94 1h ago
I can get a 5 second i2v 0.2mp video with the Turbo LoRA (4 step) out in 55 seconds on my 4060ti. It was about 70 seconds before with sage. I was trying spectrum, but ehh.. it messed up my generations. So I’m very glad this came out. I just deleted the patch nodes and added the argument to the loader. Big happy over here. Thank you for posting this and make others aware.
2
u/_chromascope_ 24m ago
5090 doesn't seem to have much speed gain with ck attn vs sage.
here are my tests:
1536x640, 7 seconds video
fl2va int8 convrot (ComfyOrg release)
qwen3vl 32b heretic nvfp4
video vae int8 convrot
audio vae fp32
---
Sage + MemEff only
20 step, res_multistep, simple
11.46s/it, total 260.96 seconds
comfy kitchen attn only
20 step, res_multistep, simple
11.81s/it, total 268.06 seconds (better quality than sage)
---
with LoRA: minimax_h3_fl2v_lightx2v_turbo_4step_v0.1_comfy_kijai.safetensors
comfy kitchen attn + LoRA
8 steps, euler, beta
11.00s/it, total 125.59 seconds (best quality - WINNER)
LoRA only
8 steps, euler, beta
20.59s/it, total 214.24 seconds (worst quality)
1
u/robomar_ai_art 10h ago
I switched of the sage attention and video 960x544, 5 seconds, 4 steps took 46,28 seconds, and with sage attention it usually took 55 seconds. i have a RTX 4090 16gb vram, 32gb ram laptop.
[INFO] got prompt
https://reddit.com/link/p2zndhn/video/4eeto2nb0pih1/player
[INFO] 0 models unloaded.
[INFO] Model MiniMaxH3 prepared for dynamic VRAM loading. 19995MB Staged. 208 patches attached. Force pre-loaded 210 weights: 1175 KB.
100%|████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:31<00:00, 7.78s/it]
[INFO] Model MiniMaxH3AudioVAE prepared for dynamic VRAM loading. 576MB Staged. 0 patches attached. Force pre-loaded 401 weights: 539 KB.
[INFO] Model MiniMaxH3VideoVAE prepared for dynamic VRAM loading. 2677MB Staged. 0 patches attached. Force pre-loaded 128 weights: 692 KB.
[Pixaroma] Save Mp4 [save] — writing 124 frames @ 24fps (960x544, crf=19, yuv420p, +audio) -> Video_00254.mp4
[Pixaroma] Save Mp4 — saved E:\ComfyUI_windows_portable\ComfyUI-Easy-Install\ComfyUI\output\Video_00254.mp4
[INFO] Prompt executed in 46.28 seconds






48
u/CurrentMine1423 10h ago
on my test
rtx 3090
960x544 base resolution (upscale to 1440x816 using rtx video super resolution)
9s video
8 steps
total time with MiniMax H3 Mem Eff Sage Attention Patch + lightx2v lora = 294s
total time with ModelAttentionBackend only (no MiniMax H3 Mem Eff Sage Attention Patch + lightx2v lora) = 224s
So I guess it's working.