Bringing Nunchaku 4-bit Diffusion Inference to Diffusers
Diffusers can now load SVDQuant/Nunchaku 4-bit (W4A4) diffusion checkpoints natively via from_pretrained(), with CUDA kernels fetched from the Hub through the kernels package instead of compiled locally. Nunchaku Lite patches stock nn.Linear modules with SVDQ W4A4 layers for attention/MLP projections and AWQ W4A16 layers for modulation layers. Because it skips architecture-specific fused kernels, it is slower than the original Nunchaku engine. On an RTX PRO 6000 it still gives about a 1.35x speedup and up to 50% lower peak VRAM versus BF16, rising to 1.8x with torch.compile. The companion diffuse-compressor toolkit calibrates, quantizes, packages and publishes new models, and model-specific adapters handle structural rewrites such as fused QKV.
Related posts
- Exploring Quantization Backends in Diffusers
Hugging Face mediumAdeptHugging Face Diffusers supports several quantization backends (bitsandbytes, torchao, Quanto, GGUF and native FP8 layerwise casting) that shrink large diffusion models such as Flux-dev, whose full BF16 pipeline needs about 31 GB. Benchmarks on an H100 put BnB 4-bit NF4 at about 12.6 GB after loading with no inference slowdown, while torchao and Quanto INT4 cut memory further but take roughly 109 seconds per image versus 12 seconds for BF16. Code examples apply PipelineQuantizationConfig to the transformer and T5 encoder, load pre-quantized GGUF files, and combine quantization with CPU offloading, group offloading and torch.compile. The 8-bit quality differences are usually hard to see, and NF4 is suggested as the best tradeoff.
- Diffusers welcomes Stable Diffusion 3.5 Large
Hugging Face mediumAdeptStable 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.
- Memory-efficient Diffusion Transformers with Quanto and Diffusers
Hugging Face mediumAdeptWeight quantization with Quanto cuts the GPU memory of Transformer-based diffusion pipelines (PixArt-Sigma, Stable Diffusion 3, Aura Flow) with little quality loss and a modest latency cost. Quantizing the text encoders as well as the diffusion transformer matters most: PixArt drops from about 12 GB to 5.4 GB with FP8. For SD3, the second text encoder should be left unquantized. Benchmarks on an H100 show that bfloat16 and qint8 with fused QKV projections reduce latency. INT4 saves the most memory but is slower and needs the final proj_out layer excluded to preserve quality. Code covers quantizing, saving and loading quantized Diffusers models.
- (LoRA) Fine-Tuning FLUX.1-dev on Consumer Hardware
Hugging Face hardMasterFLUX.1-dev can be LoRA fine-tuned on a single consumer GPU by combining QLoRA (4-bit NF4 base transformer via bitsandbytes), 8-bit AdamW, gradient checkpointing, cached VAE latents and precomputed CLIP/T5 text embeddings, so that only the quantized transformer plus adapters sit in GPU memory. On an RTX 4090, a rank-4 LoRA at 512x768 peaked around 9 GB VRAM, compared with 26 GB for BF16 LoRA and an estimated ~120 GB for full fine-tuning, and 700 steps took about 41 minutes to learn Alphonse Mucha's style. The guide includes the diffusers training script settings, an embedding precompute script, FP8 training with torchao for faster runs on compatible hardware, and options for loading or merging the trained adapters at inference.
- State of open video generation models in Diffusers
Hugging Face mediumAdeptOpen 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.