Finite Scalar Quantization: VQ-VAE Made Simple

Fabian Mentzer, David Minnen, Eirikur Agustsson, Michael Tschannen

TL;DR

Finite Scalar Quantization (FSQ) simplifies discrete latent representation learning by replacing complex vector quantization with a fixed-grid scalar approach. By projecting latents to a few dimensions and rounding to integers, FSQ eliminates the need for auxiliary losses and "tricks" like codebook reseeding while achieving near 100% codebook utilization and scaling better to large codebooks than traditional VQ-VAEs.

What Problem Does This Paper Address?

Vector Quantization (VQ) is a cornerstone of modern generative modeling, used in everything from VQ-VAE to high-end image and video generation transformers. However, VQ is notoriously difficult to optimize. Because the quantization step (finding the nearest neighbor in a learned codebook) is non-differentiable, researchers rely on the Straight-Through Estimator (STE).

Even with STE, VQ suffers from "codebook collapse," where only a small fraction of the available codewords are actually used by the model. To combat this, practitioners have developed a complex arsenal of "tricks": commitment losses, Exponential Moving Average (EMA) codebook updates, codebook reseeding (randomly restarting unused vectors), and entropy penalties. The authors of this paper ask a simple question: Can we get the benefits of discrete representations without all this overhead?

Methods

The authors propose Finite Scalar Quantization (FSQ). Instead of searching a high-dimensional learned codebook for the nearest neighbor, FSQ uses a simple, fixed grid.

  1. Projection: The encoder projects the input into a very low-dimensional space (typically $d < 10$).
  2. Bounding: Each dimension is passed through a bounding function (like a scaled $tanh$) to limit its range.
  3. Rounding: The bounded values are rounded to the nearest integer.
A comparison of FSQ's fixed grid vs. VQ's learned Voronoi partitioning.

The "codebook" in FSQ is implicit—it is simply the set of all possible integer combinations within the defined bounds. Because the grid is fixed, there is no need for commitment losses or codebook updates. The encoder is naturally incentivized to use all available "bins" to minimize reconstruction error.

Implementation comparison showing FSQ's lack of auxiliary losses and parameters.

Datasets

The authors evaluated FSQ across several demanding computer vision tasks:

  • ImageNet (128x128 and 256x256): Used for image generation benchmarks with the MaskGIT architecture.
  • NYU Depth v2: Used for monocular depth estimation.
  • COCO: Used for panoptic segmentation.
  • ImageNet (Colorization): Used to test the model's ability to predict color from grayscale inputs.

Key Insights and Ideas

  • Fixed is often better than learned: By fixing the quantization grid, FSQ avoids the moving-target problem of VQ. The encoder and decoder are powerful enough to "absorb" the rigidity of the fixed grid, leading to representations of similar complexity to VQ.
  • High Utilization by Design: FSQ consistently achieves ~100% codebook usage. In contrast, VQ utilization often drops sharply as the codebook size increases, even with entropy regularization.
  • Scaling Superiority: As shown in Figure 3, VQ performance (measured by Reconstruction FID) often plateaus or degrades with very large codebooks because it fails to use the extra capacity. FSQ continues to improve as the codebook grows.
Trade-offs showing FSQ scaling better than VQ for large codebook sizes.
  • Low Dimensionality: While VQ typically uses latent vectors with $d \ge 512$, FSQ achieves comparable results with $d < 10$. This significantly reduces the number of parameters in the final layers of the encoder and the start of the decoder.

Key Results

FSQ proves to be a "drop-in" replacement for VQ with minimal performance trade-offs:

  • Image Generation: On ImageNet 256, FSQ achieved a Sampling FID of 4.534 (with 100% codebook usage), nearly identical to the VQ-based MaskGIT's 4.509 (which only used 81% of its codebook).
  • Dense Prediction: In the UViM framework, FSQ performed competitively across depth estimation, segmentation, and colorization. For depth estimation, FSQ achieved an RMSE of 0.473 vs. VQ's 0.468.
  • Robustness: When auxiliary "tricks" like codebook splitting were removed from VQ, its performance degraded significantly (e.g., depth RMSE jumped to 0.490 and usage dropped to 0.78%). FSQ remained stable without any such mechanisms.
Visual samples from UViM showing FSQ produces results comparable to VQ.

Limitations and Future Work

  • Hyperparameter Sensitivity: FSQ introduces a new hyperparameter: the number of levels $L$ for each dimension. The authors found a heuristic ($L_i \ge 5$) that works well, but optimal configurations might require tuning.
  • Small Codebooks: For very small codebook sizes, VQ can sometimes outperform FSQ because the learned, non-linear partitioning of VQ is more expressive than a coarse fixed grid.
  • Future Directions: The authors suggest exploring FSQ in other domains where VQ is dominant, such as audio synthesis (e.g., SoundStream) and multimodal large language models.

Summary updated

BibTeX
@inproceedings{mentzer2024finite,
  author = {Fabian Mentzer and David Minnen and Eirikur Agustsson and Michael Tschannen},
  title = {{Finite Scalar Quantization: VQ-VAE Made Simple}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=8ishA3LxN8},
}
Figure