Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 7 min read How-to mediumAdept

Diffusers welcomes Stable Diffusion 3

Stable Diffusion 3 Medium (2B parameters) is now usable through Diffusers. Its architecture pairs three text encoders (two CLIP models and T5-XXL) with a Multimodal Diffusion Transformer that runs joint attention over text and image-patch sequences, and it is trained with rectified flow matching, served by a new FlowMatchEulerDiscreteScheduler (shift=3.0 recommended). Benchmarks on an A100 show the memory tradeoffs: CPU offloading cuts VRAM from 18.8GB to 12GB at roughly 6.8x latency, dropping T5 brings it to 4.3GB, and 8-bit T5 reaches 10.6GB with almost no slowdown. torch.compile delivers about a 4x speedup (0.585s), and a DreamBooth LoRA fine-tuning script is included.

Assumes: PyTorch basicsdiffusion modelsLoRA fine-tuning

Related posts

  • Diffusers welcomes Stable Diffusion 3.5 Large

    Hugging Face mediumAdept

    Stable Diffusion 3.5 Large (8B) and a timestep-distilled Turbo variant are now usable in Diffusers. The architecture matches SD3 Medium except for QK normalization and dual attention layers in the MMDiT blocks. Code covers bf16 inference, few-step (4-8 step) Turbo generation without classifier-free guidance, NF4 quantization via bitsandbytes with CPU offload for consumer GPUs, and single-file checkpoint loading. LoRA fine-tuning on 24GB GPUs works with the existing SD3 DreamBooth script, combined with peft's k-bit training preparation.

  • Stable Diffusion with 🧨 Diffusers

    Hugging Face mediumAdept

    Stable Diffusion is a latent diffusion model that denoises compressed 64×64 latents rather than pixels, combining a VAE, a text-conditioned U-Net with cross-attention, and a frozen CLIP text encoder. The Diffusers walkthrough covers running it in a few lines with StableDiffusionPipeline, including fp16 loading for GPUs under 10GB, seeded generators for determinism, and tuning num_inference_steps (50 recommended) and guidance_scale (7–8.5). It explains why the 8× VAE compression (3×512×512 to 4×64×64) makes generation feasible on 16GB GPUs. It then shows how to build a custom inference pipeline by loading components individually and swapping in schedulers such as K-LMS.

  • Using LoRA for Efficient Stable Diffusion Fine-Tuning

    Hugging Face mediumAdept

    LoRA freezes pretrained weights and trains small rank-decomposition matrices, and diffusers now supports applying it to Stable Diffusion's cross-attention layers for both full fine-tuning and Dreambooth. Training fits in 11 GB of VRAM (a 2080 Ti) without 8-bit optimizers, uses a much higher learning rate (1e-4 vs ~1e-6), and produces ~3 MB weight files, roughly 1000x smaller than the UNet. A walkthrough covers the training script on a Pokémon dataset, looking up the base model from Hub metadata, and loading LoRA weights at inference with load_attn_procs. LoRA is also compared with Textual Inversion and Pivotal Tuning.

  • State of open video generation models in Diffusers

    Hugging Face mediumAdept

    Open video generation models such as HunyuanVideo, CogVideoX, LTX-Video, Mochi-1 and Allegro share a common architecture: T5-style text encoders, a DiT-based denoiser over 3D spatio-temporal tokens, a spatially and temporally compressing VAE, and a scheduler. Diffusers runs them in a few lines of code but they need a lot of memory, about 60 GB for HunyuanVideo at default settings. Benchmarks combining bitsandbytes/FP8 quantization, CPU and group offloading, VAE tiling and layerwise casting bring HunyuanVideo down to about 6.6 GB with little extra latency. Timestep and guidance distillation speed up generation, and the finetrainers repo supports LoRA fine-tuning.

  • 🧨 Accelerating Stable Diffusion XL Inference with JAX on Cloud TPU v5e

    Hugging Face mediumAdept

    Hugging Face Diffusers can now serve Stable Diffusion XL with JAX on Cloud TPU v5e. JIT compilation over static shapes plus pmap data parallelism lets a v5e-4 produce four 1024×1024 images in about 2.3s of generation time, after a one-time compile of roughly three minutes. A step-by-step pipeline converts parameters to bfloat16 while keeping scheduler state in float32 to avoid degraded or black images, then replicates inputs with per-device RNG seeds. Benchmarks show TPU v5e delivering up to 2.4x better performance per dollar than TPU v4 at similar latency.

The quest for software engineering knowledge.

Look:
Layout: