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

A unified theoretical and empirical framework that traces training instability and codebook collapse to one cause: a mismatch between feature and code vector distributions.

Xianghong Fang1Litao Guo2Hengchao Chen1 Yuxuan Zhang1Xiaofan Xia1Dingjie Song4 Yexin Liu2Hao Wang5Harry Yang2 Qiang Sun1Yuan Yuan3

1University of Toronto2The Hong Kong University of Science and Technology3Boston College4Lehigh University5Southern University of Science and Technology

01   Motivation

Two failures. One distributional cause.

Vector quantization relies on the straight-through estimator and a learned codebook. When features and codes occupy different regions of the latent space, assignments concentrate on only a few codes: quantization error grows, gradient estimates become unreliable, and most of the codebook goes unused.

Comparison of distribution mismatch, where features cluster around a few code vectors, and distribution match, where code vectors cover the feature distribution.
Matching changes the geometry of quantization. Aligned code vectors cover the feature space, reducing distortion while activating the full codebook.
01

Quantization error

Average distortion between each feature and its nearest code. Lower error tightens the bound on the STE gradient gap.

02

Utilization rate

The fraction of code vectors selected by at least one feature. Full utilization is the first defense against collapse.

03

Codebook perplexity

The effective number of uniformly selected codes. It reveals imbalance that utilization alone cannot capture.

02   Theoretical insight

In high-dimensional latent spaces, the asymptotically optimal codebook distribution approaches the feature distribution.

Support. Matching supports is necessary and sufficient for full utilization and vanishing worst-case quantization error as the codebook grows.

Density. Optimal code density is proportional to f(d+2)/d. As dimension d grows, the exponent tends to 1, motivating direct distribution alignment.

03   Methodology

Match globally. Quantize locally.

Wasserstein VQ adds a global distribution alignment objective to the local nearest-neighbor VQ loss. Alignment gradients update only the codebook; the encoder remains free to learn expressive feature distributions.

Wasserstein VQ architecture showing an encoder, vector quantizer, decoder, and Wasserstein distribution matching loss between encoder features and codebook vectors.
Wasserstein VQ integrates into standard encoder-quantizer-decoder pipelines as an auxiliary codebook objective.

Distribution matching objective

Lmatch = D(PA, PB)

Here, PA is the empirical encoder-feature distribution and PB is the distribution of code vectors.

A practical closed form

Under a mild Gaussian approximation, the quadratic Wasserstein distance aligns the mean and covariance of features and codes. It avoids pairwise comparisons and adds only modest overhead at large codebook sizes.

Wasserstein VQ

Efficient first- and second-order matching for approximately Gaussian latent spaces.

MMD VQ

Nonparametric matching for strongly non-Gaussian features, with higher quadratic cost.

04   Results

Complete codebooks. Sharper reconstructions.

Across FFHQ and ImageNet, distributional matching prevents collapse at unprecedented codebook scales. The same principle transfers to multi-scale VAR, improving quantization and reconstruction under a controlled architecture.

Tables 1 & 2

VQ-VAE at 100,000 codes

Wasserstein VQ is the only method to use the entire codebook on both datasets, while also delivering the best reconstruction metrics.

MethodUtilization ↑Perplexity ↑PSNR ↑SSIM ↑Rec. loss ↓
Vanilla VQ0.6%481.027.8674.20.0118
STE++0.5%450.727.5272.40.0130
EMA VQ2.7%2,087.528.4374.80.0105
Online VQ3.6%1,556.827.1271.10.0142
Wasserstein VQ100%93,152.729.5378.00.0083

FFHQ · 256 tokens · codebook size K = 100,000

Table 6

Distribution matching strengthens VAR

With the VAR encoder-decoder and latent features held fixed, Wasserstein matching lowers quantization error, increases perplexity, and improves reconstruction fidelity.

MethodCodesError ↓Utilization ↑Perplexity ↑r-FID ↓
VAR4,0960.283100%2,981.40.92
Wasserstein VAR-c4,0960.255100%3,286.20.81
Wasserstein VAR-c8,1920.240100%6,518.20.73
0.73r-FID at K = 8,192

Wasserstein VAR-c improves from 0.83 after 5 adaptation epochs to 0.73 after 15.

Original FFHQ images in the top row and reconstructions from Wasserstein VQ in the bottom row.
FFHQ / Wasserstein VQ Original 256 x 256 inputs are shown above; reconstructions are shown below.
Original ImageNet images in the top row and reconstructions from Wasserstein VAR in the bottom row.
ImageNet / Wasserstein VAR Original 256 x 256 inputs are shown above; reconstructions are shown below.

05   Takeaways

Distributional matching turns a fragile lookup table into a faithful map of the latent space.

It unifies optimization stability and codebook collapse under one geometric explanation.

It scales to codebooks with 100,000 entries while maintaining complete utilization.

It is architecture-agnostic, supporting VQ-VAE, VQGAN, and downstream token-based models.

06   Citation

Build on this work.

Please cite the paper if distributional matching helps your research.

@article{fang2026distributional,
  title   = {Distributional Matching for Vector Quantization:
             A Unified Theoretical and Empirical Framework},
  author  = {Fang, Xianghong and Guo, Litao and Chen, Hengchao and
             Zhang, Yuxuan and Xia, Xiaofan and Song, Dingjie and
             Liu, Yexin and Wang, Hao and Yang, Harry and Sun, Qiang and
             Yuan, Yuan},
  journal = {arXiv},
  year    = {2026}
}