Rate-Distortion Optimized Post-Training Quantization for Learned Image Compression

Junqi Shi, Ming Lu, Zhan Ma

Abstract

Quantizing floating-point neural networks to fixed-point representations is essential for Learned Image Compression (LIC) to ensure decoding consistency across hardware and reduce computational complexity. However, existing quantization-aware training (QAT) methods are computationally expensive. This paper proposes Rate-Distortion Optimized Post-Training Quantization (RDO-PTQ), a lightweight, "plug-and-play" approach for converting pretrained FP32 LIC models to INT8 without retraining. We theoretically demonstrate that minimizing parameter-wise mean square error (MSE) is sub-optimal for compression tasks. Instead, RDO-PTQ optimizes quantization parameters to minimize the actual Rate-Distortion (R-D) loss using a small calibration set. Experimental results show that RDO-PTQ achieves near-lossless performance compared to floating-point models, with significant reductions in storage and complexity.

Introduction

Learned Image Compression (LIC) models, typically structured as Variational Auto-Encoders (VAEs), have achieved state-of-the-art performance. Despite their success, deployment on edge devices is hindered by the high memory and compute demands of 32-bit floating-point (FP32) operations. Furthermore, hardware-specific floating-point implementations can lead to inconsistent reconstructions, causing "decoding failures" in sensitive entropy-coded bitstreams.

While Quantization-Aware Training (QAT) can mitigate these issues by training models for 8-bit integer (INT8) precision, it requires massive datasets and extensive retraining. Standard Post-Training Quantization (PTQ) is a faster alternative but often fails in compression tasks because it focuses on minimizing the MSE of weights rather than the end-to-end compression performance.

The Sub-optimality of Weight MSE

A core insight of this work is that minimizing quantization-induced error in model parameters (weights, biases, activations) does not guarantee optimal compression performance. In LIC, the goal is to balance file size (Rate) and image quality (Distortion). As shown in the figure below, the relationship between weight error ($\Delta w$) and the change in R-D loss ($\Delta J$) is non-monotonic. A smaller weight error can sometimes lead to a larger R-D loss, proving that task-agnostic PTQ is insufficient for LIC.

The non-monotonic relationship between weight error ($\Delta w$) and R-D loss ($\Delta J$), proving that minimizing parameter MSE is sub-optimal for compression tasks.

Methodology: RDO-PTQ

To address this, we propose RDO-PTQ, which treats quantization as a task-oriented optimization problem.

Task-Oriented Objective

Instead of rounding weights to the nearest integer, we optimize quantization parameters (scaling factors and rounding offsets) to minimize the R-D loss function: $J = R + \lambda D$. This ensures the quantized model retains the intended compression characteristics.

Layer-wise Optimization and Adaptive Rounding

To maintain efficiency, RDO-PTQ optimizes the model layer-by-layer. We use a tiny calibration set of just 10 images. For each layer, we employ an adaptive rounding strategy to determine whether to round specific values up or down based on the impact on the final R-D loss.

Bias Rescaling

Naive quantization of bias terms often leads to significant performance drops or data overflows. We introduce a "Bias Rescaling" technique that ensures bias terms fit strictly within INT8 constraints while preserving the activation states necessary for accurate compression logic.

Experimental Results

We evaluated RDO-PTQ on standard datasets including Kodak and Tecnick. The results demonstrate that our method achieves performance nearly identical to the original FP32 models.

Rate-Distortion performance comparison on Kodak (a) and Tecnick (b) datasets. The proposed RDO-PTQ (dashed lines) closely tracks the FP32 performance, significantly outperforming other PTQ methods like RAQ.

For state-of-the-art models like Lu2022 and Cheng2020, RDO-PTQ limits the BD-rate loss to between 3.7% and 5.8%, whereas competing PTQ methods like RAQ or FQ-ViT often suffer losses exceeding 20%. Additionally, the model storage size is reduced by 75% (4x reduction).

Beyond compression, RDO-PTQ shows excellent generalization. In Super-Resolution tasks, the INT8 models performed within 0.02 dB of their FP32 counterparts. In ImageNet classification, RDO-PTQ maintained high accuracy even at ultra-low bit-widths (2-bit or 4-bit weights), outperforming existing PTQ techniques.

Conclusion

RDO-PTQ provides a robust and efficient framework for deploying LIC models on resource-constrained hardware. By shifting the focus from parameter error to task-specific R-D optimization, we enable high-performance 8-bit quantization without the need for expensive retraining. Future work will explore global optimization strategies and hardware-specific tuning for further speedups on NPUs.

Summary updated

BibTeX
@article{shi2022rate,
  author = {Junqi Shi and Ming Lu and Zhan Ma},
  title = {{Rate-Distortion Optimized Post-Training Quantization for Learned Image Compression}},
  journal = {IEEE Trans. Circuits Syst. Video Technol.},
  year = {2022},
  url = {https://openreview.net/forum?id=jjn3PQAdIC},
}
Figure