Swift Diffusion is an open-source re-implementation of Stable Diffusion written in Swift, hosted on GitHub with about 470 stars under the BSD-3-Clause license and updates in 2026. Remarkably, the entire model lives in a single file, written to match the original implementation layer by layer.
The project includes the CLIP text tokenizer, the CLIP text encoder, the UNet diffusion model, and the decoder, together with a PLMS sampler. Because it mirrors the original Stable Diffusion computation step for step, the same starting noise produces the same image as the reference implementation. The author built it both to understand diffusion models deeply and as groundwork for running Stable Diffusion natively on iPhone and iPad, where a native Swift implementation allows mobile-specific optimizations that ONNX-style exports cannot. Working example targets cover text-to-image, image-to-image, and inpainting.
Running diffusion on a phone is a serious memory problem: the original models total roughly 8 GiB in memory at full precision. A native Swift implementation gives the developer direct control over memory layout and execution, which is exactly what mobile optimization requires, and the repository’s structure, with separate example targets for the UNet, CLIP components, encoder, and decoder, makes it a study-friendly map of the architecture.
Swift Diffusion is free and open source under the BSD-3-Clause license. There are no fees or services attached; you compile it into your own Swift projects.
It is aimed at Swift and iOS developers who want to run diffusion models natively on Apple devices, and at engineers who learn best from a faithful, readable re-implementation of how Stable Diffusion actually works.