LRQ uant: Learnable and Robust Post-Training Quantization for Large Language Models (2024)

Abstract: Post-training quantization (PTQ) for large language models (LLMs) significantly accelerates model inference and relieves memory constraints, without incurring model training. A “smoothing paradigm” is commonly used in LLM quantization, which transfers the quantization difficulty of activation to weight quantization using mathematically equivalent transformations. However, existing methods face two issues: 1) Most smoothing parameters are hand-crafted defined which leads to suboptimal results; 2) There are significant performance degradations when tested on unseen datasets. To address these challenges, this paper introduces a robust learnable smooth-based PTQ framework, called LRQuant. Firstly, we consider a learnable paradigm to find optimal smoothing parameters which are initialized by logarithmic activation equivalent. In addition, we empirically found that only relying on MSE loss could hardly lead to optimal quantization results, and we then propose a novel loss function based on the negative logarithm of cosine similarity (NLC loss) between outputs of full-precision and quantized block. At last, we pioneeringly introduce Test-time adaptation (TTA) into LLM quantization, which allows for rapid model adaptation during testing to improve generalization performance. More surprisingly, we find that by using our TTA method, we can achieve better results on test sets than directly using test sets for calibration in some cases while avoiding catastrophic forgetting. Codes are available at https://github.com/zjq0455/RLQ.

## introduction quantization @xcite @xcite ) is a well-known model compression technique converting the weights of large language models (llms) and activations from full precision to lower-bit representations. ## lrquant in this section, we provide a detailed introduction to our lrquant as shown in figure 3 . we first describe the learnable parameters and nlc loss and then introduce our tta approach for quantized models on unseen datasets. ## experiments in this section, we conduct extensive experiments to validate our lrquant achieves the following objectives: (1) demonstrates outstanding performance in challenging quantization tasks (w4a4 and w6a6) through the presented learnable parameters and nlc loss. (2) enhances model performance on unseen test sets using our tta scheme. ## conclusion in this paper, we propose a robust smoothbased ptq framework namely lrquant. firstly, lrquant defines learnable smoothing parameters and initializes them using lae. subsequently, we introduce a novel block-wise loss function namely nlc loss which further considers the directional similarity of outputs. the experiments substantiate that our lrquant attains state-of-the-art levels on challenging weight-activation quantization tasks. moreover, we pioneeringly proposed a tta scheme for llm quantization to improve generalization performance on unseen datasets by adapting the learnable parameters of the last block based on the test data. the experiments indicate that our method not only relieves catastrophic forgetting but also surpasses re-calibration using the target set, thereby significantly promoting the deployment efficiency of quantized models in some cases.