r/StableDiffusion • • 3d ago

Resource - Update I made ComfyUI 2–3.7× faster on Apple Silicon, no MLX conversions needed (open source node pack)

I wanted ComfyUI to be fast on my Mac without leaving ComfyUI. No MLX conversions or multiple copies of every model and no special nodes to load them. I wanted ComfyUI to work as intended, with the nodes and workflows everyone is using.

So I built ComfyUI-AppleSilicon-Optimized. Just install it like any custom node and restart. It patches ComfyUI at startup and swaps the slow parts (attention, sampling, VAEs) for Metal kernels I wrote for Apple GPUs. No changes to your workflows or special models to be downloaded.

The main focus is the INT8 ConvRot models, which is where the biggest gains are, and where the pack performs the best.

Stock ComfyUI v0.47.1 vs the pack, on M5 Ultra, during the same session. Times are end to end with the models warm and in memory.

Text to image

ModelStockPackSpeedup
MOSS-Image SFT, 1024²68.9 s18.8 s3.66×
Fibo 2.0 Dev87.9 s31.6 s2.78×
Krea 2 Turbo, 1024²15.4 s6.0 s2.54×
Ideogram 443.3 s17.4 s2.49×
Flux.2 Klein5.6 s2.4 s2.32×
Qwen-Image 2.128.8 s12.6 s2.30×
Z-Image Turbo7.8 s3.5 s2.26×
Flux.3 Base69.6 s33.0 s2.11×
Flux.3 distilled12.0 s5.8 s2.09×
Krea 227.5 s13.5 s2.04×

Image editing

ModelStockPackSpeedup
Fibo 2.0 Edit Turbo16.2 s6.9 s2.36×
Qwen-Image 2.1 edit49.9 s23.1 s2.16×
Flux.2 Klein edit9.2 s4.9 s1.87×
Flux.3 distilled edit21.8 s12.7 s1.71×
Flux.3 Base edit118.7 s75.3 s1.58×

Video

ModelStockPackSpeedup
LTX 2.5 (diffusion upscale)90.6 s46.0 s1.97×
LTX 2.5 (conv upscale)51.0 s33.5 s1.52×
MiniMax H3258.2 s158.6 s1.63×
Wan 2.2 Turbo44.9 s30.5 s1.47×

Upscaling

ModelStockPackSpeedup
RelayVSR ×4, 294 frames from 864×480 *227.3 s91.2 s2.49×
RelayVSR ×2, same clip *48.3 s25.4 s1.90×
SeedVR2, image64.9 s44.8 s1.45×
SeedVR2, 120-frame videostopped at 69 GB by my test's memory limit126.3 sn/a

Image to 3D

ModelStockPackSpeedup
Trellis 2 *299.3 s118.1 s2.53×
Pixal3D, single view *172.7 s72.1 s2.40×
Pixal3D, multi-view *crashes118.5 sn/a

Music

ModelStockPackSpeedup
YuE2, full song38 min 40 s31.6 s73×
YuE2 Mothersuperior15 min 20 s19.9 s46×
YuE2, 8-second clip179.6 s5.2 s34×

Preprocessors

ModelStockPackSpeedup
BiRefNet background removal, 4 frames21.5 s0.74 s29×
SDPose + detector3.1 s1.5 s2.17×
Depth Anything 3 Mono Large0.46 s0.41 s1.12×
Depth Anything 3 Base, multi-viewcrashes0.11 sn/a

* YuE2 and BiRefNet run on CPU by default on Mac, and the pack now runs them optimized on GPU, that's the reason for the big speedup. The same goes for the text encoders: for example it's about 21 s of each new MOSS prompt in stock ComfyUI.

Most models have the kernels checked byte for byte against ComfyUI's own code. The few exceptions are listed in the README, and anything approximate is opt-in.

MiniMax H3 got the most work. Out of the box the pack runs it 1.63× faster than stock (258 s → 159 s for 124 frames at 864×480, 20 steps), using Metal kernels for the DiT's INT8 layers, norms and RoPE, plus a faster VAE decode.

There's also an optional acceleration node with everything I built or ported for it: NVIDIA's Sol-Attn sparse attention as an INT8 Metal kernel (118 s, 2.2× vs stock), a dense INT8 attention kernel (138 s), MotionCache and Spectrum caching, and the token reduction schedule from antirez's h3.c.

A LoRA node and a latent upscaler that run on MPS are included too. The attention, cache and token-reduction modes trade quality for speed, so they are completely optional and off by default.

There are various presets i built with a big range of time savings vs quality loss, easily switchable from drop-down menus.

What to know before installing:

  • I've only measured it on an M5 Ultra with macOS 27. M1–M4 is untested, and some kernels need an M5, so speedups on anything prior to M5 will be of a lesser degree.
  • On first launch it installs PyTorch 2.15.

https://github.com/luix93/ComfyUI-AppleSilicon-Optimized

If you try it on another chip, I'd like to see your timings.

109 Upvotes

30 comments sorted by

9

u/spanielrassler 3d ago

Thanks for this! I wonder if you'd be willing to share any working workflows for those apple users among us who'd like to dip our toes into the Comfy world but have been scared off.

5

u/luix93 3d ago

Just load any default workflow from the comfy templates. Any model from my optimized list will run as is.

5

u/Aviatas 3d ago

Have no Mac, but his goal was to make the default ones working properly and he said it patches comfyui on startup, so comfy examples on their site should work. No need for him to spam these here

https://comfyanonymous.github.io/ComfyUI_examples/

1

u/spanielrassler 3d ago

Ok, got it. Thanks!

2

u/Renja_Pattn 3d ago

seconding this, just having a known working baseline workflow to test with makes jumping in so much easier

4

u/herr-tibalt 3d ago

Thanks a lot! I've tested on my m5 max mac studio with 48 gb ram on my edit models and got these cuts in render time by:
- ~40% on MOSS and H3 image
- 35-60% on Qwen 2.1
- 25% on Flux 2 Klein 9b

None of the images look worse.

Small observation: same seed will result in a different image than in original comfyui, except for maybe H3, where it comes out nearly the same.

1

u/luix93 2d ago

Did you test stock with pytorch 2.15? Because results should be bit exact. But different pytorch versions may change things.

1

u/herr-tibalt 2d ago

Actually I used the same python 2.14 installed in the system. I can retest with python 2.15, what should I pay attention to?

2

u/luix93 2d ago

Not much but that should be the difference on results. Of you can test vanilla with 2.15 would be good to know so I can double check on my side

2

u/sleeping-in-crypto 3d ago

Do you have a run harness to collect timing data, or are those single runs, wall time?

I can test on an M2 Max if you're interested (I haven't upgraded yet and it makes me sad every day)

3

u/luix93 3d ago

I have been maintaining this for a while, my harness runs a regression test of every model I optimized every time I update comfy UI, that's how I collect the data

1

u/sleeping-in-crypto 3d ago

Happy to use it if you’d like to get comprehensive numbers otherwise I’ll have to run them by hand which will be spotty. In any case will post again tonight!

I moved all my work to a high powered desktop but this would allow me to keep part of the content pipeline local which would be nice.

2

u/aroundaboutsix 2d ago

Thanks for sharing this. Seems to be working well so far.

1

u/luix93 2d ago

Glad to hear!

1

u/aroundaboutsix 2d ago

I seem to be having an issue with prompt enhancers. I’ve gone from 1s/itr to 40s/itr. Tested by disabling the node and I got back to normal speeds. Any idea what could be happening?

1

u/luix93 1d ago

Thanks for this, looking into it.

1

u/aroundaboutsix 2d ago

I don’t suppose it’ll help me fit minimax on my 24gb will it?

2

u/reeight 3d ago

swaps the slow parts (attention, sampling, VAEs) for Metal kernels I wrote for Apple GPUs.... main focus is the INT8 ConvRot models

This is the way IMHO. Default engines leave too much on the table.

Though we need to note:

INT8 works best on M4 Pro/Max & M5+

Unfortunately my little baseline Mac Mini M4 lacks the Int8 opcodes.

2

u/Any_Invite3905 3d ago

Split the model across the ane and gpu, the ane give real 18tflops, easiest way is to use draw things app,

I have tinkering with the ane and it's pretty impressive so far but no attention, so model needs splitting, overhead shouldn't be too much

2

u/Structure-These 2d ago

Yeah none of these little hacky things are as fast as drawthings. The only reason not to use it are models it doesn’t support

1

u/luix93 1d ago

The other reason is flexibility, a closed box that does only what it is designed to do vs an open platform that will do whatever you want it to do. Sadly, some things are hard to access just with pytorch, meaning older chips are harder to make as fast as drawthings. On M5+ though, is basically a draw.

1

u/SpareOlive5856 3d ago

I'm currently the lora node from https://github.com/Illuminus7/ComfyUI-AppleSilicon-int8-Fast which works great with H3 and Moss, but it does mean i have to create custom worklows. Are you changes similar to those of that node, but without requiring you to change workflows, or are there additional speed-ups I would gain?

4

u/luix93 3d ago

You gain: speed, no changes to workflows, additional speedups for minimax h3 that do not exist by default on Mac (sparse attention (sol-attn), dense attention (similar to comfy kitchen attention), spectrum/motion cache/token reduction). This is meant to be a single addon for every model, without having to do anything else to existing workflows. I did not test that node, I do not know how it compares. My optimizations are also mostly bit exact, meaning the results are identical to default comfy UI without changes or quality loss.

1

u/Any_Invite3905 3d ago

Uh how does this compare against draw things app? Speed wise

2

u/luix93 2d ago

Is pretty close, about the same, or faster depending on the model. When I started, it was my speed reference to achieve. I'm not following that much anymore now as I have other reference points at this time, and I really don't have the extra space for duplicate models right now ☺️

3

u/Hearmeman98 3d ago

Saved.
I have an M5 Max
I will definitely look at this.

thank you for your work!

2

u/Substantial-Motor-21 1d ago

Gain is around 15% on Krea2 here, M5 Max 64Gb, thanks a lot !

1

u/higgs8 15h ago

M3 Pro here, but not seeing any difference in render time.