Post-Training Quantization with Adaptive Calibration: INT4 Inference for Large Language Models
Large language models (7B-70B parameters) require substantial computational resources for inference, limiting deployment on edge devices. Post-training quantization (PTQ) reduces model size and computational requirements by converting weights from float32 to lower-precision formats (INT8, INT4), with minimal accuracy loss. However, INT4 quantization presents challenges due to the reduced dynamic range (256 levels vs. 4.3B for float32). This study develops adaptive calibration techniques for INT4 post-training quantization of instruction-tuned language models, addressing distribution shift between calibration and deployment data. We evaluate multiple calibration strategies: (1) Min-Max static calibration (baseline), (2) Percentile-based (99th, 99.5th percentile), (3) Entropy-based calibration (KL divergence minimization), and (4) Mixed-precision quantization (INT4 for weights, INT8 for activations). Testing on Llama 7B, Mistral 7B, and Phi-2 models using standard benchmarks (MMLU 5-shot accuracy, HellaSwag, PIQA) and custom instruction-following tasks. Results show entropy-based calibration achieves 95.2% of full-precision performance on MMLU, compared to 91.8% for naive min-max quantization (3.4% recovery). Mixed-precision approaches recover 96.1% of performance while reducing model size by 4.1x. Quantization degrades performance more on reasoning-heavy tasks than factual knowledge tasks. The adaptive calibration method automatically selects which layers to keep at INT8 vs INT4 based on sensitivity analysis. Implementation uses NVIDIA CUDA kernels for efficient INT4 inference (~2.8x speedup on RTX 4090 vs. float32). This framework enables practical deployment of 7B+ parameter models on consumer GPUs with <5% accuracy loss.


