NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Universally Quantized Neural Compression

Eirikur Agustsson, Lucas Theis

Abstract

Neural image compression typically relies on adding uniform noise during training as a differentiable proxy for quantization. However, at inference, models often revert to hard rounding, creating a "train-test mismatch" that degrades performance and introduces visual artifacts. This paper proposes universal quantization (dithered quantization) to align inference with training. By integrating this with a novel soft rounding technique and an expected gradient variance-reduction trick, the authors bridge the gap between differentiable proxies and discrete bottlenecks, achieving superior rate-distortion performance and more natural-looking reconstructions.

The Train-Test Mismatch in Compression

In lossy compression, mapping continuous latent representations to discrete bits requires quantization. Because the derivative of the standard rounding function is zero almost everywhere, it cannot be used directly in gradient-based optimization. The common solution is to add uniform noise during training. While effective for optimization, switching back to hard rounding at test time creates a mismatch: the model is optimized for a noisy channel but deployed on a deterministic rounding channel. This often results in suboptimal bit-rate efficiency and "blocking" artifacts in reconstructed images.

Proposed Methods

The authors introduce three key technical innovations to resolve this discrepancy:

1. Universal Quantization (UQ)

Instead of deterministic rounding at inference, the authors employ universal quantization (Ziv, 1985). This involves adding a random dither before rounding and subtracting it afterward. This process is statistically equivalent to adding uniform noise, ensuring that the inference phase perfectly matches the noise-based training phase.

2. Soft Rounding ($s_\alpha$)

To improve bit-rate efficiency while maintaining differentiability, the authors introduce a "soft rounding" function based on the hyperbolic tangent. By annealing the parameter $\alpha$, the function can transition from a smooth identity mapping to a sharp staircase function.

Soft rounding function $s_\alpha(y)$ and components of the expected gradient calculation.

3. Expected Gradients

High-fidelity soft rounding (high $\alpha$) can lead to high-variance gradients. The authors derive a mathematical trick to analytically integrate out the uniform noise when calculating gradients. This "Expected Gradient" approach provides a stable, "straight-through-like" gradient that significantly improves training stability and convergence speed, especially at high bitrates.

Experimental Results

The models were trained on 1 million high-resolution images and evaluated on the standard Kodak dataset.

Performance Gains

The proposed UN + UQ + SR (Uniform Noise + Universal Quantization + Soft Rounding) approach consistently outperformed the standard baseline. The improvement was most significant in linear models, where the architecture has less capacity to compensate for quantization errors.

Rate-distortion performance on a linear model and training convergence stability.

Qualitative Quality

Visually, universal quantization replaces structured blocking artifacts (common in JPEG and standard neural codecs) with a film-grain-like texture. While this may slightly lower PSNR, it is often perceptually preferred as it preserves more natural image characteristics.

Training Stability

As shown in the convergence plots, the "Expected Gradients" technique (denoted by 'E') is essential for training stability. Without it, models with high $\alpha$ values or high bitrates often fail to converge or exhibit erratic loss behavior.

Conclusion

This work demonstrates that the gap between "compression with quantization" and "compression via noisy channels" can be bridged effectively. By using universal quantization and soft rounding, neural codecs can achieve better rate-distortion trade-offs and improved visual quality by eliminating the long-standing train-test mismatch in the field.

Summary updated

BibTeX
@inproceedings{agustsson2020universally,
  author = {Eirikur Agustsson and Lucas Theis},
  title = {{Universally Quantized Neural Compression}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
}
Figure