Masked Autoencoders Are Effective Tokenizers for Diffusion Models

Hao Chen, Yujin Han, Fangyi Chen, Xiang Li, Yidong Wang, Jindong Wang, Ze Wang, Zicheng Liu, Difan Zou, Bhiksha Raj

TL;DR

This paper introduces MAETok, a new tokenizer for Latent Diffusion Models (LDMs) that swaps out the traditional Variational Autoencoder (VAE) for a plain Autoencoder trained with masked modeling. By forcing the encoder to learn a highly "discriminative" latent space with fewer modes, the authors achieve state-of-the-art image generation on ImageNet with just 128 tokens, resulting in a massive 76x training speedup and 31x higher inference throughput compared to previous top-tier models.

What Problem Does This Paper Address?

Latent Diffusion Models (like Stable Diffusion) don't work directly on pixels; they operate in a compressed "latent space" created by a tokenizer. For years, the gold standard for these tokenizers has been the Variational Autoencoder (VAE), which uses a specific mathematical constraint (KL divergence) to ensure the latent space is "smooth."

However, VAEs often struggle with high-fidelity reconstruction because that smoothness comes at the cost of fine detail. On the flip side, plain Autoencoders (AEs) reconstruct images beautifully but often produce "messy" or entangled latent spaces that are incredibly difficult for a diffusion model to learn. This paper asks a fundamental question: What actually makes a latent space "good" for diffusion? Is the "smoothness" of a VAE actually necessary, or is there a better way to organize data for generative models?

Methods

The authors propose MAETok, which shifts the focus from variational constraints to structural organization.

MAETok Architecture
  1. 1D Transformer Architecture: Unlike traditional CNN-based tokenizers, MAETok uses a Vision Transformer (ViT). It maps an image into a set of learnable "latent tokens" (specifically 128 tokens), regardless of the input resolution.
  2. Masked Modeling: Borrowing from the Masked Autoencoder (MAE) paradigm, they randomly mask 40–60% of the image patches during training. The encoder must then aggregate information from the visible patches into the latent tokens.
  3. Auxiliary Semantic Teachers: To ensure the latent space is semantically rich, they use "auxiliary shallow decoders." These small networks are tasked with predicting features from pre-trained models (like DINOv2 or CLIP) and low-level features (like HOG) for the masked patches. This forces the encoder to understand what is in the image, not just what the pixels look like.
  4. Decoupling Reconstruction and Semantics: High masking ratios usually hurt reconstruction quality. To fix this, the authors use a two-stage process: they first train the whole system with masking, then freeze the encoder and fine-tune only the decoder on unmasked images. This allows the model to keep its "smart" latent space while recovering pixel-perfect details.

Datasets

The models were trained and evaluated using:

  • ImageNet-1K: The primary benchmark for both 256x256 and 512x512 generation.
  • LAION-COCO: A subset was used to train a variant of the tokenizer that incorporates text-aligned features.
  • MS-COCO: Used specifically to evaluate the "zero-shot" reconstruction capabilities of the tokenizer on data it hadn't seen during training.

Key Insights and Ideas

  • Structure Over Smoothness: The most significant "aha moment" is that diffusion models don't need the smooth, Gaussian-prior distribution of a VAE. Instead, they thrive in a discriminative latent space where different classes or features are clearly separated into distinct clusters.
  • The GMM Connection: The authors used Gaussian Mixture Models (GMMs) to analyze different latent spaces. They proved (both theoretically and empirically) that a latent space with fewer modes (clusters) is significantly easier for a diffusion model to learn. MAETok naturally produces these "simpler" global structures.
GMM and Diffusion Loss Comparison
  • Token Efficiency: Most models use 256 or 1024 tokens to represent an image. MAETok shows that if your tokens are semantically "dense" enough, you only need 128 tokens to achieve better results. This reduction is the primary driver behind the massive speedups in training and inference.

Key Results

  • State-of-the-Art Generation: On ImageNet 512x512, MAETok achieved a gFID (Generation Frechet Inception Distance) of 1.69, outperforming much larger models like the 2-billion parameter USiT.
  • Efficiency: Because it uses fewer tokens, it enables a 76x faster training workflow and a 31x higher inference throughput for high-resolution (512x512) generation compared to previous SOTA methods like REPA.
  • Reconstruction Fidelity: Despite the heavy compression, it maintains high reconstruction quality, achieving an rFID of 0.48 on ImageNet 256x256.
  • Unconditional Strength: Interestingly, MAETok-based models perform exceptionally well even without Classifier-Free Guidance (CFG), suggesting the latent space itself captures much of the class-level semantics.

Limitations and Future Work

  • CFG Tuning Difficulty: The authors noted that because the "unconditional" class in their model learns such strong semantics, traditional linear Classifier-Free Guidance (CFG) is harder to tune. Small changes in the guidance scale can lead to large jumps in image quality.
  • Future Directions: The team suggests exploring more advanced guidance techniques (like Autoguidance) to better handle the rich semantics of the MAETok space. They also see this as a stepping stone toward even more efficient, large-scale generative modeling that moves away from the "VAEs-by-default" mindset.

Summary updated

BibTeX
@inproceedings{chen2025masked,
  author = {Hao Chen and Yujin Han and Fangyi Chen and Xiang Li and Yidong Wang and Jindong Wang and Ze Wang and Zicheng Liu and Difan Zou and Bhiksha Raj},
  title = {{Masked Autoencoders Are Effective Tokenizers for Diffusion Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=dzwUOiBlQW},
}
Figure