---
title: Smoothed Vector Quantization Techniques
url: https://www.emergentmind.com/topics/smoothed-vector-quantization
type: topic
---

# Smoothed Vector Quantization Techniques

Smoothed vector quantization designates a family of methods that modify classical vector quantization (VQ) so that the quantizer is less brittle with respect to optimization, codebook usage, or distortion. In standard deep-learning VQ, an encoder output is replaced by a single nearest codebook vector, which yields a discrete bottleneck but also introduces non-differentiability, codebook collapse, and residual quantization error. Recent work uses the term *smoothed* in several technically distinct senses: soft simplex assignments and convex mixtures of codewords, regularization that pushes softened assignments toward simplex vertices, random rotations that smooth coordinate statistics before scalar quantization, spatial interpolation-and-pooling around hard assignments, and geometry-aware backward maps that smooth gradient propagation without altering the hard forward assignment [2310.03004] [2509.22161] [2504.19874] [2601.00222] [2410.06424].

## 1. Classical VQ and the rationale for smoothing

In VQ-VAE-style models, an encoder \(E_\phi\) maps an input \(x\) to a latent \(z_e\), and quantization replaces \(z_e\) by its nearest codebook element:
\[
z_q := Q(z_e) = c_k,\quad \text{where } k = \arg\min_{1 \le j \le K}\|z_e - c_j\|.
\]
A canonical VQ-VAE objective combines reconstruction with codebook and commitment terms:
\[
\mathcal{L}_{\textrm{VQ}} = \|x-\hat{x}\|_2^2 + (1-\beta)\|sg[z_e]-z_q\|_2^2 + \beta\|z_e - sg[z_q]\|_2^2,
\]
with \(sg[\cdot]\) denoting stop-gradient and \(\beta>0\) the commitment weight [2310.03004].

The central difficulty is that nearest-neighbor selection is non-differentiable. Classical practice therefore uses the straight-through estimator (STE), which preserves the hard forward pass but substitutes a heuristic backward pass. The literature surveyed here identifies three recurrent pathologies of this construction. First, non-differentiability means the gradient estimator is only a surrogate. Second, codebook collapse arises when a few centroids dominate assignments and updates. Third, hard one-hot assignment is lossy: the residual \(\epsilon = z_q - z_e\) is generally nonzero even though STE treats the quantizer as if it were identity in backpropagation [2310.03004].

A parallel line of work frames VQ more directly as a rate–distortion problem. With bit budget \(B=b\cdot d\), a vector quantizer \(Q:\mathbb{R}^d\to\{0,1\}^B\) and decoder \(Q^{-1}\) are evaluated by mean-squared error
\[
D_{\mathrm{mse}}(Q;x) := \mathbb{E}_Q[\|x-Q^{-1}(Q(x))\|_2^2]
\]
and, for query \(y\), inner-product distortion
\[
D_{\mathrm{prod}}(Q;x,y) := \mathbb{E}_Q[|\langle x,y\rangle-\langle y,Q^{-1}(Q(x))\rangle|^2].
\]
The information-theoretic lower bounds reported for worst-case unit-norm inputs scale as \(4^{-b}\) for MSE and \((1/d)\cdot 4^{-b}\) for inner products [2504.19874].

A useful distinction follows from these formulations. Some smoothed-VQ methods smooth the *assignment itself*; others smooth the *statistics of the input* or the *backward signal* while retaining hard assignment. The term is therefore broader than “soft VQ” in the narrow simplex-mixture sense.

## 2. Simplex-based smoothing: soft assignments, convex mixtures, and vertex concentration

The most direct form of smoothed VQ replaces a one-hot code index by a point on the probability simplex. In this setup, a codebook \(C\in\mathbb{R}^{d\times M}\) is combined with a simplex vector \(s\in\Delta^{M-1}\),
\[
\Delta^{M-1}=\{s\in\mathbb{R}^M\mid s_i\ge 0,\ \sum_{i=1}^M s_i=1\},
\]
and the quantized representation becomes
\[
\hat{x} = C s.
\]
This formulation preserves differentiability through \(s\) and generalizes hard VQ, which is recovered when \(s\) is a canonical basis vector \(e_m\) [2509.22161].

Soft Convex Quantization (SCQ) instantiates this idea as a convex program. For input \(x\in\mathbb{R}^d\), codebook \(E=[e_1,\dots,e_K]\in\mathbb{R}^{d\times K}\), and nearest-neighbor one-hot assignment \(\tilde{\alpha}\), SCQ solves
\[
\min_{\alpha \in \Delta^{K-1}} \|x - E\alpha\|_2^2 + \lambda\|\alpha-\tilde{\alpha}\|_2^2.
\]
The first term minimizes quantization error; the second softly biases the solution toward the VQ one-hot assignment. The quantized output is \(y=E\alpha\). When \(\alpha\) is one-hot, SCQ reduces to standard VQ; as \(\lambda\to\infty\), the optimum converges to \(\tilde{\alpha}\) [2310.03004].

The same paper gives a batch formulation. If encoder outputs are flattened as \(Z_e^{\mathrm{flattened}}\in\mathbb{R}^{F\times M}\), with codebook \(C\in\mathbb{R}^{F\times K}\) and one-hot assignments \(\widetilde{P}\in\mathbb{R}^{K\times M}\), SCQ solves
\[
P^\star := \arg\min_{P} \|Z_e^{\mathrm{flattened}} - CP\|_F^2 + \lambda\|P-\widetilde{P}\|_F^2
\]
subject to \(P\ge 0\) and \(P^\top\mathbf{1}_K=\mathbf{1}_M\), so that each column of \(P\) lies on the simplex [2310.03004].

A later simplex-based approach emphasizes that smoothing should satisfy two criteria simultaneously: assignments should remain close to simplex vertices, and all codes should be used. Its regularizer minimizes the average distance between each canonical vertex \(e_m\) and its \(K\)-nearest smoothed assignments:
\[
\mathcal{L}_{\mathrm{KNN}} = \frac{1}{MK}\sum_{m=1}^M\sum_{k=1}^K \mathcal{D}(e_m,s^{(m,k)}).
\]
The paper studies both squared \(\ell_2\) distance,
\[
\mathcal{D}_{\ell_2}(e_m,s)=\|e_m-s\|^2=1+\|s\|^2-2s_m,
\]
and cross-entropy,
\[
\mathcal{D}_{\mathrm{CE}}(e_m,s)=-\log s_m.
\]
Because both induce ranking by the magnitude of \(s_m\), the \(K\)-nearest assignments to each vertex can be obtained by top-\(K\) selection on the corresponding simplex coordinate [2509.22161].

This regularizer is partly motivated by a critique of entropy-based usage penalties. Maximizing the perplexity of the *mean assignment* can be satisfied by diffuse or center-concentrated simplex distributions and therefore does not, by itself, enforce one-hotness. The cited work argues that this creates train–test mismatch when inference uses hard argmax codes [2509.22161]. A plausible implication is that “balanced usage” and “sharp assignment” are distinct objectives and should not be conflated.

## 3. Differentiability and optimization through the quantizer

SCQ treats smoothed quantization as a differentiable convex optimization layer. For a single embedding, with equality constraint \(g(\alpha)=1-\mathbf{1}^\top\alpha\) and inequality constraints \(h_i(\alpha)=-\alpha_i\le 0\), the Lagrangian is
\[
\mathcal{L}(\alpha,\nu,\mu)=\|x-E\alpha\|_2^2+\lambda\|\alpha-\tilde{\alpha}\|_2^2+\nu\Big(1-\sum_i\alpha_i\Big)-\sum_i \mu_i\alpha_i.
\]
Its KKT system includes stationarity,
\[
2E^\top(E\alpha-x)+2\lambda(\alpha-\tilde{\alpha})-\nu\mathbf{1}-\mu = 0,
\]
along with primal feasibility, dual feasibility, and complementary slackness \(\mu_i\alpha_i=0\). Differentiation through the forward solution is then performed by implicit differentiation of the KKT conditions, yielding exact gradients through the quantizer up to solver tolerances [2310.03004].

For the task loss \(\mathcal{L}_{\mathrm{task}}\) and soft quantized output \(y=E\alpha\), the gradient with respect to the codebook contains both a direct term and a term through the dependence of \(\alpha\) on \(E\):
\[
\frac{\partial \mathcal{L}_{\mathrm{task}}}{\partial E}
=
\frac{\partial \mathcal{L}_{\mathrm{task}}}{\partial y}\alpha^\top
+
\frac{\partial \mathcal{L}_{\mathrm{task}}}{\partial y}E\frac{\partial \alpha}{\partial E}.
\]
The same mechanism transmits gradients back to encoder outputs through \(\partial \alpha/\partial x\) [2310.03004].

Exact interior-point solves are not scalable in the full batch formulation: the reported complexity is cubic in the number of decision variables, \(O((N K \widetilde{H}\widetilde{W})^3)\). SCQ therefore introduces a relaxation. It first solves the unconstrained regularized least-squares problem
\[
P \leftarrow (C^\top C + \lambda I)^{-1}\big(C^\top Z_e^{\mathrm{flattened}} + \lambda \widetilde{P}\big),
\]
a \(K\times K\) linear solve with cost \(O(K^3)\), and then projects each column of \(P\) onto the simplex by iterating nonnegativity clipping and sum-to-one correction. This removes the need for softmax or temperature parameterization while keeping runtime comparable to practical VQ implementations [2310.03004].

A different route to differentiability keeps the hard forward pass unchanged and smooths only the backward map. In the rotation trick, with encoder output \(z\), selected code \(q\), normalized vectors \(\hat z=z/\|z\|\) and \(\hat q=q/\|q\|\), and scale \(s(z,q)=\|q\|/\|z\|\), one constructs a rotation \(R(z,q)\) that aligns \(\hat z\) to \(\hat q\), and defines
\[
\hat e = T(z,q) = s(z,q)\,R(z,q)\,z.
\]
Because \(R\) preserves norms and \(s\) matches magnitudes, the forward map satisfies \(\hat e=q\). During backpropagation, \(T\) is treated as constant, giving
\[
\frac{\partial L}{\partial z} = (sR)^\top \frac{\partial L}{\partial \hat e}.
\]
The resulting gradient is deterministic and geometry-aware: unlike STE, it carries information about the angle and relative norm between \(z\) and its assigned code [2410.06424].

## 4. Other meanings of smoothing: random rotations and spatial interpolation

TurboQuant uses *smoothing* in a distributional sense rather than a simplex-mixture sense. For a unit-norm vector \(x\in S^{d-1}\), it applies a random orthogonal rotation \(R\) to produce \(y=Rx\). This transforms any worst-case input into a random point uniformly distributed on the sphere. Each coordinate then has density
\[
f_X(x)=\frac{\Gamma(d/2)}{\sqrt{\pi}\Gamma((d-1)/2)}(1-x^2)^{(d-3)/2},\qquad x\in[-1,1],
\]
which converges to \(N(0,1/d)\) in high dimensions. The paper argues that the resulting coordinates are nearly independent, justifying identical Lloyd–Max scalar quantizers per coordinate without data-dependent codebook training [2504.19874].

Under this construction, per-coordinate decision thresholds are the midpoints between centroids \(c_1\le \dots \le c_{2^b}\):
\[
\tau_i = (c_i+c_{i+1})/2.
\]
The MSE distortion obeys
\[
D_{\mathrm{mse}}(b)\le (\sqrt{3}\pi/2)\cdot 4^{-b},
\]
while the two-stage inner-product variant, which adds a 1-bit Quantized Johnson–Lindenstrauss residual quantizer, satisfies
\[
D_{\mathrm{prod}}(b)\le (\sqrt{3}\pi^2/d)\|y\|_2^2\cdot 4^{-b}.
\]
These bounds match the optimal \(4^{-b}\) and \(d^{-1}4^{-b}\) rates up to constant factors [2504.19874].

LooC introduces yet another meaning of smoothing. It does **not** use weighted combinations of codevectors. Instead, it splits each feature vector \(z_{i,j}\in\mathbb{R}^d\) into \(m\) contiguous segments \(z_{i,j}^{(q)}\in\mathbb{R}^{d^\*}\), with \(d^\*=d/m\), quantizes each segment with a single shared codebook, and reconstructs by concatenation:
\[
\hat z_{i,j} = [c(k^{(1)}_{i,j});\dots;c(k^{(m)}_{i,j})].
\]
Its smoothing mechanism is a parameter-free extrapolation-by-interpolation (EBI) pipeline: bilinear interpolation to a \(\beta h\times \beta w\) grid, compositional quantization at all interpolated locations, and \(\beta\times\beta\) average pooling back to the original spatial resolution,
\[
\tilde z_{i,j} = \frac{1}{\beta^2}\sum_{(u,v)\in \Omega_{i,j}} \hat z^{\mathrm{ex}}_{u,v}.
\]
The paper explicitly characterizes this as spatial smoothing rather than soft assignment over the codebook [2601.00222].

These examples show that “smoothed vector quantization” is not a single algorithmic template. In current usage, the smoothing target may be the assignment simplex, the input distribution, the local spatial neighborhood, or the backward Jacobian.

## 5. Empirical behavior across image, speech, retrieval, and LLM systems

SCQ reports large gains over matched VQ baselines in autoencoding and VQGAN-style settings. On CIFAR-10, across five runs of 50 epochs, SCQ achieved MSE \(1.53\times 10^{-3}\), quantization error \(0.15\times 10^{-3}\), and perplexity \(124.11\), compared with VQVAE at \(41.19\times 10^{-3}\), \(70.47\times 10^{-3}\), and \(6.62\), respectively. On GTSRB, SCQ reached MSE \(3.21\times 10^{-3}\), quantization error \(0.24\times 10^{-3}\), and perplexity \(120.55\). In LSUN Church and Classroom experiments with VQGAN losses, SCQGAN consistently improved both reconstruction loss and LPIPS, with the advantage increasing at smaller latent resolutions, which the paper interprets as better information preservation under stronger compression [2310.03004].

The simplex-vertex KNN regularizer produces a different empirical profile. On ImageNet autoencoding with latent \(64\times64\times32\) and codebook size \(M=8196\), Softmax + KNN-CE achieved 100% code use, rMSE \(0.199\), FID \(5.267\), and IS \(404.098\); Softmax + PPL, by contrast, had rMSE \(0.725\), FID \(83.070\), and IS \(77.981\). In Wav2Vec 2.0 on LibriSpeech, Softmax + KNN-CE achieved 100% usage for a single \(1\times1024\) codebook and for dual \(2\times320\) product quantizers, whereas STE, rotational estimation, and PPL baselines showed severe collapse in the reported configurations [2509.22161].

TurboQuant emphasizes online quantization quality and speed rather than learned latent autoencoding. For KV-cache quantization in Llama models, Needle-In-A-Haystack recall was reported as \(0.997\), matching full precision at compression ratios around \(4\times\) with 3–4 bits per channel. On LongBench, full cache at 16 bits scored \(50.06\), TurboQuant at 3.5 bits/channel also scored \(50.06\), and TurboQuant at 2.5 bits/channel scored \(49.44\). In nearest-neighbor search, TurboQuant consistently outperformed product quantization and RaBitQ in recall while reducing 4-bit indexing time to \(0.0007\)s, \(0.0013\)s, and \(0.0021\)s at dimensions \(200\), \(1536\), and \(3072\), respectively [2504.19874].

LooC combines compact codebooks with spatial smoothing. On MNIST, LooC with a \(32\times4\) codebook reported LPIPS \(0.0083\), rFID \(1.70\), SSIM \(0.9961\), and PSNR \(35.15\); with \(256\times4\), it improved to LPIPS \(0.0058\), rFID \(1.31\), SSIM \(0.9976\), and PSNR \(37.58\). On CIFAR10, the corresponding \(256\times4\) setting reported LPIPS \(0.0285\), rFID \(19.22\), SSIM \(0.9880\), and PSNR \(34.51\). On FFHQ \(256\times256\), LooC-VAE \(256\times4\) achieved 100% codebook usage, LPIPS \(0.0501\), rFID \(1.97\), SSIM \(0.8499\), and PSNR \(27.73\), while \(1024\times4\) further improved to LPIPS \(0.0346\), rFID \(1.37\), SSIM \(0.9276\), and PSNR \(32.44\) [2601.00222].

The rotation trick was evaluated across 11 VQ-VAE and VQGAN paradigms. In VQGAN on FFHQ+CelebA-HQ, code usage reportedly increased from about 27% to about 99%, quantization error fell from \(0.233\) to \(0.002\), validation loss from \(0.565\) to \(0.313\), and r-FID from \(4.7\) to \(3.7\). In latent-diffusion VQGAN on ImageNet with latent \(32\times32\times4\) and \(K=16384\), r-FID improved from \(5.0\) to \(1.6\), r-IS from \(141.5\) to \(190.3\), and usage from about 2% to about 9% [2410.06424].

## 6. Trade-offs, misconceptions, and open technical questions

A persistent misconception is that smoothed VQ is synonymous with softmax or Gumbel-softmax over codewords. The literature here contradicts that identification. SCQ and the KNN-to-vertices method are explicitly simplex-based; TurboQuant smooths coordinate statistics by random rotation; LooC smooths spatially by interpolation and pooling while keeping hard per-segment assignments; the rotation trick smooths only the gradient path [2310.03004] [2504.19874] [2601.00222] [2410.06424].

Another recurrent issue is the tension between smoothness and discrete fidelity. In SCQ, larger \(\lambda\) yields sparser, more VQ-like assignments, while smaller \(\lambda\) permits denser mixtures and lower quantization error but can reduce compressibility and downstream discrete modeling fidelity. The paper explicitly notes that excessively small \(\lambda\) may produce overly dense mixtures, and suggests post hoc top-1 or top-\(k\) discretization when strict discrete tokens are required, at some performance cost [2310.03004]. The KNN-regularization paper frames a closely related problem as train–test mismatch: diffuse assignments can satisfy mean-perplexity objectives without resembling the hard argmax codes used at inference [2509.22161].

Scalability constraints differ by method. SCQ’s exact differentiable convex optimization is expensive at scale, motivating the regularized linear solve plus simplex projection relaxation [2310.03004]. TurboQuant is online and data-oblivious but incurs \(O(d^2)\) dense rotation and projection costs per vector, which the paper identifies as a motivation for structured orthogonal transforms in future work [2504.19874]. The KNN regularizer is limited primarily by memory because it must retain large assignment matrices and perform per-code top-\(K\) selection; the paper therefore uses GPU-local KNN and discusses vertex subsampling or product quantization as scaling aids [2509.22161]. LooC notes that very large interpolation scale \(\beta\) can weaken local correlations and blur details, and that extreme segment granularity such as \(d^\*=1\) may cause over-fragmentation [2601.00222]. The rotation trick identifies numerical edge cases at \(z\approx 0\) and when \(\hat z\approx -\hat q\), where the rotation construction becomes ill-conditioned and requires \(\epsilon\)-stabilization or a 180-degree fallback [2410.06424].

Across these variants, the unifying principle is not a single formula but a shared design goal: preserve more information than hard nearest-neighbor VQ while reducing the optimization and utilization failures that arise from discrete assignment. The methods differ in where the smoothing is imposed, which failure mode they target most directly, and what compromises they make between exact discreteness, computational tractability, and downstream compatibility.

Source: https://www.emergentmind.com/topics/smoothed-vector-quantization