Skip to content

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

Hugging Face 7 min read Deep dive hardMaster

VQ-Diffusion

VQ-Diffusion is a conditional latent diffusion model whose noising and denoising run over a discrete VQ-VAE codebook rather than Gaussian noise. Each token can stay, be uniformly resampled, or become permanently masked, and a CLIP-conditioned encoder-decoder transformer predicts the full distribution of un-noised latents in one pass. Compared with autoregressive image transformers, it avoids raster-order directional bias and error accumulation, and its inference cost scales with diffusion steps rather than latent pixels, roughly a 10x big-O gain on 32x32 ITHQ latents and up to 15x faster in practice. The model can be run in a few lines with the Diffusers VQDiffusionPipeline.

Assumes: diffusion models (DDPM)transformers and attentionVQ-VAEautoregressive generative models

Related posts

  • Welcome aMUSEd: Efficient Text-to-Image Generation

    Hugging Face mediumAdept

    aMUSEd is an open, permissively licensed reproduction of Google's MUSE that generates images with masked image modeling instead of latent diffusion. A VQGAN tokenizes images, a U-ViT conditioned on CLIP-L/14 text embeddings predicts masked tokens, and inference iteratively keeps the most confident predictions under a cosine mask schedule. At ~800M parameters it needs fewer inference steps than diffusion models and can inpaint zero-shot, though its image quality is not state of the art. It ships in diffusers, and fine-tuning fits in under 11GB of VRAM with 8-bit Adam and fp16, or about 7GB with LoRA.

  • Introducing Würstchen: Fast Diffusion for Image Generation

    Hugging Face mediumAdept

    Würstchen is a text-to-image diffusion model whose text-conditional Prior (Stage C) runs in a latent space with 42x spatial compression, far beyond the usual 4-8x. Two decoder stages, a VQGAN (Stage A) and a Diffusion Autoencoder (Stage B), reconstruct images from that latent. The result is faster, lower-memory inference than SDXL and much cheaper training: 9,000 GPU hours for v1 and 24,602 for v2, against 150,000 for Stable Diffusion 1.4. The model is integrated into Diffusers, with example code for AutoPipeline inference, PyTorch 2 SDPA or xFormers attention, CPU offload and torch.compile, where compilation takes up to 2 minutes up front for faster runs afterwards.

  • 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.

  • 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.

  • Memory-efficient Diffusion Transformers with Quanto and Diffusers

    Hugging Face mediumAdept

    Weight 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.

The quest for software engineering knowledge.

Look:
Layout: