AI Blog
Model Quantization & Compression: The Complete Guide

Model Quantization & Compression: The Complete Guide

Published: May 7, 2026

machine-learningmodel-optimizationquantizationAIdeep-learning

Introduction

Imagine deploying a state-of-the-art language model on a smartphone — no cloud connection required, responding in milliseconds, consuming minimal battery. Just a few years ago, that would have sounded like science fiction. Today, thanks to model quantization and compression techniques, it's becoming standard practice across the AI industry.

As AI models grow increasingly powerful, they also grow increasingly heavy. GPT-3 weighs in at 175 billion parameters, requiring roughly 700 GB of GPU memory in full precision. Running such a model in production is both expensive and slow. Model compression techniques address this problem head-on, enabling engineers to shrink models dramatically — sometimes by 4x to 8x in size — while retaining 95–99% of their original performance.

In this guide, we'll break down the key techniques, compare popular tools, walk through real-world examples from companies like Google, Meta, and Qualcomm, and help you decide which approach best fits your project.


What Is Model Quantization?

Model quantization is the process of reducing the numerical precision of a model's weights and activations. Most neural networks are trained using 32-bit floating-point numbers (FP32). Quantization converts these to lower-precision formats such as:

  • FP16 (16-bit float) — ~2x memory reduction
  • INT8 (8-bit integer) — ~4x memory reduction
  • INT4 (4-bit integer) — ~8x memory reduction
  • INT1/Binary — extreme compression, significant accuracy trade-offs

Think of it like compressing a high-resolution photo: you reduce file size at the cost of some fine detail, but for most practical uses, the image looks nearly identical.

Why Does Precision Matter?

Neural networks are surprisingly robust to reduced numerical precision because:

  1. Most weights carry redundant information
  2. Small rounding errors average out across millions of operations
  3. Modern quantization methods compensate for precision loss during or after training

According to research from NVIDIA, INT8 inference can be 2–4x faster than FP32 inference on compatible hardware, with less than 1% accuracy degradation on most benchmark tasks.


Key Model Compression Techniques

Quantization is just one tool in the toolkit. Here's a comprehensive overview of the major compression strategies:

1. Quantization (Post-Training vs. Quantization-Aware Training)

There are two main flavors:

Post-Training Quantization (PTQ) converts a pre-trained FP32 model to lower precision after training. It's fast and requires no retraining, making it ideal for production deployment. Tools like ONNX Runtime and TensorRT support PTQ natively.

Quantization-Aware Training (QAT) simulates quantized inference during training, allowing the model to adapt to precision loss. QAT typically yields 1–3% better accuracy than PTQ, especially for aggressive quantization levels like INT4.

2. Pruning

Pruning removes redundant or low-importance weights from a neural network. There are two main approaches:

  • Unstructured pruning: Removes individual weights (fine-grained, harder to accelerate on hardware)
  • Structured pruning: Removes entire neurons, heads, or layers (coarser, but hardware-friendly)

Research from MIT shows that up to 90% of weights in overparameterized networks can be pruned with minimal accuracy loss — a phenomenon known as the Lottery Ticket Hypothesis.

3. Knowledge Distillation

Knowledge distillation trains a small "student" model to mimic the behavior of a large "teacher" model. The student doesn't just learn from labels — it learns from the teacher's soft probability distributions, which carry richer information.

This technique was famously used to create DistilBERT, a distilled version of BERT that:

  • Is 40% smaller
  • Runs 60% faster
  • Retains 97% of BERT's language understanding performance on the GLUE benchmark

4. Weight Sharing and Low-Rank Factorization

Weight sharing clusters similar weights together and forces them to use the same value, reducing the number of unique parameters stored.

Low-rank factorization decomposes large weight matrices into products of smaller matrices. For a matrix of size m × n, this can reduce parameters from m×n to (m×r) + (r×n) where r << min(m,n).

5. Sparse Representations

Sparse models contain mostly zero-valued weights. Hardware accelerators like NVIDIA's Ampere architecture include dedicated sparse tensor cores that can skip zero-value computations, delivering up to 2x throughput improvement for 50%-sparse models.


Real-World Examples

Example 1: Google's MobileNet and Edge AI

Google's MobileNet family demonstrates the power of combining architectural efficiency with quantization. MobileNetV3, when quantized to INT8, runs inference on a Pixel phone in under 20 milliseconds — fast enough for real-time image classification without any cloud calls.

Google deployed quantized MobileNet models in Google Lens, which processes over 3 billion visual queries per month. Without quantization, on-device inference would be impractical on the majority of Android devices in the market.

Example 2: Meta's LLM.int8() for Large Language Models

In 2022, Meta AI researchers introduced LLM.int8(), a novel INT8 quantization technique specifically designed for large language models. The breakthrough was handling "emergent outliers" — a small subset of weights that resist quantization due to unusually large magnitudes.

LLM.int8() enables loading a 175B parameter model (like OPT-175B) in approximately 176 GB of memory instead of the 700 GB required for FP32 — a 4x reduction. This made it possible for researchers without access to massive GPU clusters to run state-of-the-art models. The technique was implemented in the popular bitsandbytes library, which is now a cornerstone of the Hugging Face ecosystem.

Example 3: Qualcomm and On-Device AI

Qualcomm's AI Engine, powering Snapdragon chipsets, uses a combination of INT8 and INT4 quantization to run models like Stable Diffusion and Llama 2 directly on smartphones. In 2023, Qualcomm demonstrated Stable Diffusion XL generating images in under 15 seconds on a Snapdragon 8 Gen 3 — a task that previously required a dedicated desktop GPU.

This was achieved through a combination of:

  • INT4 weight quantization for the UNet backbone
  • Structured pruning of attention heads
  • Hardware-optimized sparse operations

The result? A model that was originally 6.9 GB compressed to approximately 900 MB — an 87% size reduction.


Comparison of Key Quantization & Compression Tools

Tool Developer Supported Formats Key Technique Hardware Support Ease of Use
TensorRT NVIDIA FP16, INT8, INT4 PTQ + QAT NVIDIA GPU only ⭐⭐⭐
ONNX Runtime Microsoft FP16, INT8 PTQ CPU, GPU, NPU ⭐⭐⭐⭐
bitsandbytes Tim Dettmers / HF INT8, INT4 LLM.int8(), QLoRA NVIDIA GPU ⭐⭐⭐⭐⭐
AutoGPTQ PanQiWei et al. INT4, INT8 GPTQ (PTQ for LLMs) NVIDIA GPU ⭐⭐⭐⭐
llama.cpp Georgi Gerganov INT4, INT8, FP16 GGUF quantization CPU, Metal, CUDA ⭐⭐⭐⭐⭐
PyTorch Quantization Meta / PyTorch FP16, INT8 PTQ + QAT CPU, CUDA ⭐⭐⭐
Apple Core ML Apple FP16, INT8, INT4 PTQ Apple Silicon ⭐⭐⭐⭐

How to Choose the Right Technique

Selecting the right compression strategy depends on several factors:

Consider Your Deployment Target

Target Recommended Approach
Cloud GPU inference TensorRT INT8 or FP16
Mobile (Android) ONNX Runtime INT8 + MobileNet architecture
Mobile (iOS) Core ML quantization
Desktop CPU llama.cpp GGUF INT4/INT8
Edge devices (IoT) Aggressive INT4 + pruning

Consider Your Accuracy Requirements

For mission-critical applications (medical imaging, fraud detection), INT8 with QAT is the safest bet, preserving accuracy within 0.5% of baseline. For general-purpose applications (chatbots, content recommendation), INT4 quantization is often acceptable, especially with modern techniques like GPTQ.

Consider Your Development Resources

If you're resource-constrained, Post-Training Quantization is always the starting point — it requires no retraining, can be applied in minutes, and typically delivers solid results. For teams with more bandwidth, following PTQ with QAT can squeeze out significant additional performance.


Deep Dive: The GPTQ Algorithm

GPTQ (Generative Pre-trained Transformer Quantization) deserves special attention as it's become the de facto standard for quantizing large language models. Published by researchers at ETH Zurich in 2

Related Articles