SANA: Efficient High-Resolution Image Synthesis with Linear Diffusion Transformers

Enze Xie, Junsong Chen, Junyu Chen, Han Cai, Haotian Tang, Yujun Lin, Zhekai Zhang, Muyang Li, Ligeng Zhu, Yao Lu, Song HanarXiv 2024 · DOI

TL;DR

Sana is a new text-to-image diffusion model that achieves high-resolution (up to 4096x4096) image generation with remarkable speed and efficiency, even on consumer hardware. It accomplishes this by introducing a deeply compressed autoencoder, linear attention mechanisms, and a decoder-only LLM for text encoding, leading to a 100x speedup over state-of-the-art models.

What Problem Does This Paper Address?

The field of text-to-image generation has seen rapid progress, with models like Stable Diffusion, Imagen, and DALL-E producing increasingly impressive results. However, a significant challenge has been the trade-off between image quality/resolution and computational cost. State-of-the-art models often require massive parameter counts (billions) and extensive computational resources for both training and inference, making them inaccessible to many users and limiting their deployment on edge devices. This paper aims to bridge this gap by developing a text-to-image framework that is both highly efficient and capable of generating high-resolution, high-quality images.

Methods

Sana introduces several key innovations to achieve its efficiency and quality:

  • Deep Compression Autoencoder (AE): Traditional AEs in diffusion models typically compress images by a factor of 8 (8x). Sana employs an AE that achieves a 32x compression factor. This drastically reduces the number of latent tokens that the diffusion model needs to process, leading to significant speedups in training and inference.
  • Linear Diffusion Transformer (DiT): The standard attention mechanism in transformers has a quadratic complexity (O(N^2)), which becomes a bottleneck for high-resolution images. Sana replaces this with a linear attention mechanism, reducing the complexity to O(N). They also introduce a "Mix-FFN" which incorporates depth-wise convolutions to better capture local information, compensating for any potential loss from linear attention.
  • Decoder-only LLM as Text Encoder: Instead of traditional text encoders like T5, Sana utilizes a decoder-only LLM (specifically Gemma-2) for better text understanding and instruction following. To stabilize training with LLMs and enhance text-image alignment, they introduce "Complex Human Instructions" (CHI) and a normalization layer for text embeddings.
  • Flow-DPM-Solver: To further accelerate the sampling process, Sana uses a modified DPM-Solver that adapts a velocity prediction model to a data prediction one, inspired by rectified flow methods. This allows for stable, high-quality image generation with significantly fewer sampling steps (10-20 vs. 30-50 for traditional solvers).
  • Efficient Training and Data Curation: The paper also mentions techniques like multi-caption auto-labeling using VLMs and a CLIP-score-based sampler to improve training data quality and consistency.

Datasets

The paper mentions using the MJHQ-30K dataset for training and evaluation. They also refer to standard benchmarks for evaluating text-image alignment and human preference, such as GenEval, DPG-Bench, and ImageReward.

Key Insights and Ideas

  • Aggressive Compression is Key: The paper strongly advocates for aggressive compression in the autoencoder (32x) as a primary driver of efficiency for high-resolution image generation. They argue that high-resolution images inherently contain redundant information that can be effectively compressed.
  • Linear Attention Works for Generation: Contrary to some prior work that explored linear attention primarily for dense prediction tasks, Sana demonstrates its effectiveness for image generation, achieving comparable quality to quadratic attention with significant speed benefits.
  • LLMs as Text Encoders are Powerful but Tricky: While decoder-only LLMs offer superior text understanding, their direct integration into diffusion models can lead to training instability. The proposed CHI and normalization techniques are crucial for harnessing their power.
  • No Positional Encoding Needed: Surprisingly, the authors found they could remove positional embeddings from their DiT architecture without a loss in performance, further simplifying the model.

Key Results

  • Unprecedented Speed and Efficiency: Sana-0.6B achieves over 100x faster throughput compared to models like Flux-12B. It can generate a 1024x1024 image in under 1 second on a 16GB laptop GPU.
  • High-Resolution Generation: Sana can generate images up to 4096x4096 resolution, with the 4K images containing more detail than 1K images.
  • Competitive Quality: Despite its efficiency, Sana achieves competitive performance on various benchmarks (FID, CLIP Score, GenEval, DPG-Bench, ImageReward), often outperforming or matching larger models. For example, Sana-0.6B achieves a GenEval score of 0.64 with only 0.6B parameters, while Flux-dev (12B parameters) scores 0.67.
  • Improved Text Rendering: The paper highlights Sana's ability to render text accurately in generated images, a common challenge for many diffusion models.

Limitations and Future Work

  • Safety and Controllability: The authors acknowledge that fully guaranteeing the safety and controllability of generated images remains a challenge.
  • Complex Cases: Generating faces and hands, as well as text rendering in certain complex scenarios, can still be challenging.
  • Future Work: The authors plan to build an efficient video generation pipeline based on Sana.

Summary updated

BibTeX
@misc{xie2024sana,
  author = {Enze Xie and Junsong Chen and Junyu Chen and Han Cai and Haotian Tang and Yujun Lin and Zhekai Zhang and Muyang Li and Ligeng Zhu and Yao Lu and Song Han},
  title = {{SANA: Efficient High-Resolution Image Synthesis with Linear Diffusion Transformers}},
  year = {2024},
  eprint = {2410.10629},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.10629},
}
Figure