SyncAI.news, a Varaisys broadcasting
Using Stable Diffusion with Core ML on Apple Silicon
HF

Hugging Face Blog

· 2 min read

AI LabsHugging Face Blog

Using Stable Diffusion with Core ML on Apple Silicon

Thanks to Apple engineers, you can now run Stable Diffusion on Apple Silicon using Core ML!

This Apple repo provides conversion scripts and inference code based on 🧨 Diffusers, and we love it! To make it as easy as possible for you, we converted the weights ourselves and put the Core ML versions of the models in the Hugging Face Hub.

Update: some weeks after this post was written we created a native Swift app that you can use to run Stable Diffusion effortlessly on your own hardware. We released an app in the Mac App Store as well as the source code to allow other projects to use it.

The rest of this post guides you on how to use the converted weights in your own code or convert additional weights yourself.

Available Checkpoints

The official Stable Diffusion checkpoints are already converted and ready for use:

  • Stable Diffusion v1.4: converted original
  • Stable Diffusion v1.5: converted original
  • Stable Diffusion v2 base: converted original
  • Stable Diffusion v2.1 base: converted original

Core ML supports all the compute units available in your device: CPU, GPU and Apple's Neural Engine (NE). It's also possible for Core ML to run different portions of the model in different devices to maximize performance.

There are several variants of each model that may yield different performance depending on the hardware you use. We recommend you try them out and stick with the one that works best in your system. Read on for details.

Notes on Performance

There are several variants per model:

At the time of this writing, we got best results on my MacBook Pro (M1 Max, 32 GPU cores, 64 GB) using the following combination:

  • original attention.
  • all compute units (see next section for details).
  • macOS Ventura 13.1 Beta 4 (22C5059b).

With these, it took 18s to generate one image with the Core ML version of Stable Diffusion v1.4 🤯.

Each model repo is organized in a tree structure that provides these different variants:

You can download and use the variant you need as shown below.

Original source

This story was published by Hugging Face Blog. SyncAI.news shows a preview; the complete article is on the publisher's site.

Read the full story on huggingface.co

Similar News