Distributional Matching for Vector Quantization: A Unified Theoretical and Empirical Framework

Xianghong Fang, Litao Guo, Hengchao Chen, Yuxuan Zhang, XiaofanXia, Dingjie Song, Yexin Liu, Hao Wang, Harry Yang, Qiang Sun, Yuan YuanarXiv 2026

TL;DR

Vector Quantization (VQ) models often suffer from training instability and codebook collapse because the learned codebook distribution fails to match the encoder's feature distribution. This paper introduces a unified framework that explicitly aligns these distributions using Wasserstein distance or Maximum Mean Discrepancy (MMD). By doing so, it consistently achieves 100% codebook utilization and superior image reconstruction fidelity with negligible computational overhead.

What Problem Does This Paper Address?

Vector Quantization (VQ) is a core component of modern visual tokenizers (like VQ-VAE and VQGAN) used in autoregressive image generation. It works by mapping continuous latent features from an encoder onto a discrete set of learnable vectors in a "codebook."

Figure 1: The symbols · and × represent the feature and code vectors, respectively. The left figure illustrates the distributional mismatch between the feature and code vectors, while the right figure visualizes their distributional match.

Despite its popularity, VQ is notoriously difficult to optimize due to two interconnected challenges:

  1. Training Instability: Because the quantization step is non-differentiable, researchers use a Straight-Through Estimator (STE) to copy gradients from the decoder back to the encoder. However, if the gap between the continuous feature and its assigned codebook vector is large, this gradient approximation becomes highly inaccurate, destabilizing training.
  2. Codebook Collapse: Often, only a tiny fraction of the codebook vectors are ever active. The remaining vectors receive no gradients and are never updated, leading to severe underutilization of the model's capacity and massive information loss.

The authors argue that these are not separate issues, but rather symptoms of a single underlying flaw: a fundamental geometric mismatch between the distribution of the encoder's feature vectors and the codebook vectors.

Methods

The authors propose a Distributional Matching Framework that introduces an auxiliary alignment loss ($\mathcal{L}_{\text{match}}$) to minimize the divergence between the feature distribution ($P_A$) and the codebook distribution ($P_B$). Crucially, gradients from this loss are only back-propagated to the codebook, preserving the encoder's feature expressiveness.

To evaluate and guide this alignment, they define a criterion triple:

  • Quantization Error ($\mathcal{E}$): The average distortion introduced by quantization.
  • Codebook Utilization Rate ($\mathcal{U}$): The percentage of codebook vectors actively used.
  • Codebook Perplexity ($\mathcal{C}$): A measure of how uniformly the codebook vectors are selected.

The framework is instantiated in two ways:

  • Wasserstein VQ (Parametric): Uses the quadratic Wasserstein distance. By applying a mild Gaussian approximation to the latent features, the objective simplifies into an elegant, computationally efficient closed-form solution based purely on sample means and covariances.
  • MMD VQ (Non-parametric): Uses Maximum Mean Discrepancy (MMD) to align distributions without making any parametric assumptions, offering a robust alternative for highly multi-modal, non-Gaussian distributions.

Datasets

The authors evaluated their approach across four standard image benchmarks:

  • Low-resolution: CIFAR-10 and SVHN.
  • High-resolution: FFHQ and ImageNet-1K.

Key Insights and Ideas

  • A Unified Geometric View: Training instability and codebook collapse are solved simultaneously by global distribution matching. Aligning the global distribution naturally minimizes local quantization errors (stabilizing the STE) and spreads assignments evenly across the codebook (preventing collapse).
  • The High-Dimensional Exponent Convergence: Mathematically, as the feature dimension $d \to \infty$, the optimal codebook density converges directly to the feature density. This provides a rigorous theoretical justification for explicitly forcing $P_B \approx P_A$ in high-dimensional latent spaces.
  • Natural Gaussianity: Deep neural network features often naturally approximate Gaussian distributions because multivariate normal distributions maximize entropy for a given covariance. Quantile-Quantile (Q-Q) plots on real image features confirmed that the central mass of the learned latents strongly conforms to a Gaussian profile.
Figure 3: Qualitative analyses of the criterion triple (E, U, C): The red and green disks represent the uniform distributions of feature and code vectors, respectively.

Key Results

  • 100% Codebook Utilization: Across massive codebook sizes (up to 100,000 vectors on ImageNet-1K), Wasserstein VQ consistently maintained 100% codebook utilization ($\mathcal{U}$) and exceptionally high perplexity ($\mathcal{C}$), whereas vanilla VQ collapsed to utilization rates below 1%.
  • Reconstruction Fidelity: On ImageNet-1K with a codebook size of 100,000, Wasserstein VQ improved the Peak Signal-to-Noise Ratio (PSNR) from 24.43 to 25.88 and substantially reduced the pixel-level reconstruction loss compared to Vanilla VQ.
  • Computational Efficiency: Unlike prior optimal transport methods (like VQ-WAE) which suffer from prohibitively complex potential networks, the closed-form Gaussian Wasserstein VQ introduces negligible runtime overhead, making it highly scalable.

Limitations and Future Work

  • Downstream Generative Validation: Due to limited computational resources, the authors did not directly validate whether this improved tokenizer reconstruction quality translates into better downstream autoregressive or diffusion-based image generation.
  • Sensitivity to Non-Gaussianity: While Wasserstein VQ is highly efficient, its performance degrades slightly if the latent space exhibits strong non-Gaussian characteristics (e.g., highly distinct multi-modal clusters). Though MMD VQ solves this, it comes at a significantly higher computational cost ($O((N+K)^2)$ complexity).

Summary updated

BibTeX
@misc{fang2026distributional,
  author = {Xianghong Fang and Litao Guo and Hengchao Chen and Yuxuan Zhang and XiaofanXia and Dingjie Song and Yexin Liu and Hao Wang and Harry Yang and Qiang Sun and Yuan Yuan},
  title = {{Distributional Matching for Vector Quantization: A Unified Theoretical and Empirical Framework}},
  year = {2026},
  eprint = {2607.15933},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.15933},
}
Figure