Post-training quantization (PTQ) reduces excessive hardware cost by quantizing full-precision models into lower bit representations on a tiny calibration set, without retraining. Despite the remarkable progress made through recent efforts, traditional PTQ methods typically encounter failure in dynamic and ever-changing real-world scenarios, involving unpredictable data streams and continual domain shifts, which poses greater challenges. In this paper, we propose a novel and stable quantization process for test-time adaptation (TTA), dubbed TTAQ, to address the performance degradation of traditional PTQ in dynamically evolving test domains. To tackle domain shifts in quantizer, TTAQ proposes the Perturbation Error Mitigation (PEM) and Perturbation Consistency Reconstruction (PCR). Specifically, PEM analyzes the error propagation and devises a weight regularization scheme to mitigate the impact of input perturbations. On the other hand, PCR introduces consistency learning to ensure that quantized models provide stable predictions for same sample. Furthermore, we introduce Adaptive Balanced Loss (ABL) to adjust the logits by taking advantage of the frequency and complexity of the class, which can effectively address the class imbalance caused by unpredictable data streams during optimization. Extensive experiments are conducted on multiple datasets with generic TTA methods, proving that TTAQ can outperform existing baselines and encouragingly improve the accuracy of low bit PTQ models in continually changing test domains. For instance, TTAQ decreases the mean error of 2-bit models on ImageNet-C dataset by an impressive 10.1\%.
翻译:后训练量化(PTQ)通过在小型校准集上将全精度模型量化为低位表示,无需重新训练,从而降低过高的硬件成本。尽管近期研究取得了显著进展,但传统的PTQ方法通常在动态且不断变化的真实场景中遭遇失效,这些场景涉及不可预测的数据流和持续的域偏移,带来了更大挑战。本文提出一种新颖且稳定的测试时适应(TTA)量化流程,称为TTAQ,以解决传统PTQ在动态演化的测试域中性能下降的问题。为应对量化器中的域偏移,TTAQ提出了扰动误差缓解(PEM)和扰动一致性重建(PCR)。具体而言,PEM通过分析误差传播机制,设计了一种权重正则化方案以减轻输入扰动的影响;而PCR引入一致性学习,确保量化模型对同一样本产生稳定的预测。此外,我们提出自适应平衡损失(ABL),通过利用类别的频率与复杂度调整逻辑值,从而有效缓解优化过程中因不可预测数据流导致的类别不平衡问题。在多个数据集上结合通用TTA方法进行的广泛实验表明,TTAQ能够超越现有基线方法,并在持续变化的测试域中显著提升低位PTQ模型的精度。例如,TTAQ将ImageNet-C数据集上2位模型的平均误差降低了10.1%。