CODA: Repurposing Continuous VAEs for Discrete Tokenization

Zeyu Liu, Zanlin Ni, Yeguo Hua, Xin Deng, Xiao Ma, Cheng Zhong, Gao Huang

TL;DR

This paper introduces CODA, a novel framework that repurposes existing continuous Variational Autoencoders (VAEs) into powerful discrete tokenizers for image generation. By decoupling compression from discretization and focusing on adapting pre-trained VAEs, CODA achieves state-of-the-art reconstruction quality with significantly reduced training time and improved codebook utilization compared to traditional methods.

What Problem Does This Paper Address?

The field of AI-generated content (AIGC) is increasingly exploring discrete token-based approaches for image generation, drawing inspiration from the success of language models. These discrete tokenizers transform images into sequences of discrete codes, enabling efficient generation and unification of multimodal tasks. However, current methods for learning these tokenizers face several challenges:

  • Joint Compression and Discretization: Traditional approaches attempt to learn both image compression and discretization simultaneously. This can lead to unstable training, low codebook utilization (meaning many of the learned codes are rarely used), and suboptimal reconstruction quality.
  • Inefficiency: Training discrete tokenizers from scratch is computationally expensive and time-consuming.
  • Performance Gap: Despite advancements, discrete tokenizers often lag behind continuous methods in terms of reconstruction fidelity. For instance, standard VQGAN tokenizers achieve a significantly worse FID score than VAEs used in diffusion models.

CODA aims to bridge this gap by proposing a new paradigm that leverages the strengths of pre-trained continuous VAEs, which are already highly optimized for perceptual compression, and adapting them for discrete tokenization.

Methods

CODA's core innovation lies in its decoupling of compression and discretization. Instead of learning both from scratch, it repurposes off-the-shelf continuous VAEs for compression and then applies a carefully designed discretization process. The framework involves two main stages:

  1. Leveraging Continuous VAEs for Compression: CODA starts with a pre-trained continuous VAE. The VAE's encoder is used to compress the input image into a continuous latent representation.
  2. Principled Discretization: The continuous latent representation is then discretized using novel techniques:
  3. Residual Quantization: This method iteratively refines the approximation of the continuous latent vector. Each quantization layer builds upon the residual of the previous one, progressively minimizing quantization error and increasing representational capacity. This is inspired by techniques used to approximate continuous functions.
  4. Attention-Based Quantization: To address the issue of ambiguous code assignment and low codebook utilization, CODA introduces an attention-based mechanism. This frames discretization as a retrieval task where features and codebook embeddings are projected and normalized onto a hypersphere. A softmax attention mechanism then computes a sparse and unambiguous assignment of features to discrete codes, promoting better codebook coverage and utilization.
  5. VAE Parameter Adaptation (LoRA): To further bridge the gap between continuous and discrete representations, CODA incorporates LoRA (Low-Rank Adaptation) modules. These modules allow for fine-tuning of the VAE's encoder and decoder parameters to better accommodate the distribution shift induced by discretization, leading to improved reconstruction quality.

Datasets

  • ImageNet 256x256: This dataset is used for both training the CODA tokenizer and evaluating generative models.
  • MS-COCO: Used for text-to-image generation experiments.

Key Insights and Ideas

  • Decoupling is Key: The paper strongly advocates for decoupling compression and discretization, challenging the conventional wisdom that these tasks must be learned jointly. This separation allows for leveraging highly optimized pre-trained components.
  • Residual Quantization for Capacity: Iteratively refining approximations with residual quantization significantly enhances the representational capacity of the discrete latent space, leading to better reconstruction.
  • Attention for Sparsity and Utilization: Attention mechanisms are crucial for achieving sparse code assignments, preventing codebook collapse, and ensuring high codebook utilization, which is a persistent problem in VQ-based methods.
  • Fine-tuning VAEs is Beneficial: Adapting the pre-trained VAE's parameters, even slightly with LoRA, makes a significant difference in bridging the performance gap between continuous and discrete representations.
  • Efficiency Gains: Repurposing existing VAEs dramatically reduces the training budget required for high-quality discrete tokenizers.

Key Results

  • Reconstruction Quality: CODA achieves competitive reconstruction FID (rFID) scores, notably 0.43 for 8x compression and 1.34 for 16x compression on ImageNet 256x256. This is a significant improvement over standard VQGAN, which achieves an rFID of 4.98 for 16x compression.
  • Codebook Utilization: CODA achieves 100% codebook utilization, a substantial improvement over typical VQ-based methods that often struggle with low utilization.
  • Training Efficiency: CODA requires 6x less training budget compared to standard VQGAN training settings.
  • Generative Performance: When combined with MaskGIT for image generation, CODA achieves a lower FID of 3.17 compared to 4.92 for standard MaskGIT, demonstrating enhanced generation quality. It also shows strong overall performance against other leading generation paradigms.

Limitations and Future Work

  • Limitations:
    • The paper acknowledges that while adapting VAE parameters is beneficial, the exact asymmetry observed in training decoder vs. encoder LoRA weights warrants further investigation.
  • While CODA significantly reduces training time, the initial training of the continuous VAEs is still a prerequisite.
  • Future Work:
    • The authors suggest that CODA unlocks new potential for enhanced discrete generation, implying further exploration of generative models built upon this tokenizer.
  • The framework's ability to scale to larger codebook sizes and higher compression ratios could be further investigated.
  • Exploring other adaptation techniques beyond LoRA for VAEs could yield further improvements.

Summary updated

BibTeX
@inproceedings{liu2025coda,
  author = {Zeyu Liu and Zanlin Ni and Yeguo Hua and Xin Deng and Xiao Ma and Cheng Zhong and Gao Huang},
  title = {{CODA: Repurposing Continuous VAEs for Discrete Tokenization}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2025},
}
Figure