The Core Problem
Storing seven billion weights at two bytes each requires about 14 GB before activations, cache and runtime overhead. Weight storage is not the same measurement as total inference memory.
Quantization compresses the weights from 16-bit floats to lower precision (8-bit, 4-bit, sometimes 3-bit or even 2-bit). The question isn't whether to quantize, for inference, you almost certainly should. The question is how, because the methods differ in ways that affect quality, speed, and compatibility.
Method 1: GPTQ (Post-Training Quantization via Optimal Brain Surgeon)
GPTQ was the first method that made 4-bit quantization practical for large models. It's based on a clever mathematical insight: instead of quantizing each weight independently (which is what naive round-to-nearest does), GPTQ quantizes one column of the weight matrix at a time and adjusts the remaining columns to compensate for the quantization error.
The algorithm, simplified:
# Pseudocode for GPTQ quantization of one linear layer
def gptq_quantize(W, H, bits=4, group_size=128):
"""
W: weight matrix [out_features, in_features]
H: Hessian approximation (X^T @ X from calibration data)
"""
Q = torch.zeros_like(W)
Err = torch.zeros_like(W)
# Process columns left to right
for col in range(W.shape[1]):
# Quantize this column
q = quantize_to_grid(W[:, col], bits, group_size)
Q[:, col] = q
# Compute error from quantizing this column
err = (W[:, col] - q) / H[col, col]
# Compensate: adjust remaining unquantized columns
W[:, col+1:] -= err.unsqueeze(1) @ H[col, col+1:].unsqueeze(0)
return Q
The Hessian matrix H is computed from a small calibration dataset (typically 128 samples from C4 or WikiText). This is the key, GPTQ uses second-order information about how the loss landscape curves around each weight, making smarter quantization decisions than simple rounding.
Pros:
- Excellent quality for GPU inference
- Kernel availability must be checked against the target runtime
- Mature ecosystem (AutoGPTQ, transformers integration)
Cons:
- Requires GPU for quantization (the Hessian computation is expensive)
- Not great for CPU inference
- Group quantization adds complexity to the weight format
Method 2: AWQ (Activation-Aware Weight Quantization)
AWQ's insight is elegant: not all weights are equally important. Weights that multiply large activations have more impact on output quality. So instead of treating all weights equally, AWQ finds the "salient" weights (those multiplied by large activations) and protects them.
The trick is that AWQ doesn't keep salient weights at higher precision. Instead, it applies a per-channel scaling factor before quantization that spreads the range of salient weights across more quantization bins:
# AWQ's core insight
def awq_scale_weights(W, activations, alpha=0.5):
"""
Scale weights based on activation magnitudes before quantizing.
This protects important weights by giving them more quantization bins.
"""
# Compute per-channel activation magnitudes
act_scales = activations.abs().mean(dim=0)
# Scale factor: channels with larger activations get scaled up
# before quantization (more bins), then scaled back down at runtime
scales = act_scales.pow(alpha)
# Apply: W_scaled = W * diag(scales)
# After quantization: W_q * diag(1/scales) ≈ W
W_scaled = W * scales.unsqueeze(0)
return W_scaled, scales
The beauty is that the scaling is mathematically equivalent, you scale up before quantization and scale down at runtime, so the fp16 output is the same. But the quantized representation is more accurate because more bits are allocated to the weights that matter most.
Compare calibration choices on held-out tasks and report the model revision, dataset, quantizer and runtime. This article does not provide a supported perplexity ranking of these methods.
Method 3: GGUF (llama.cpp's Format)
GGUF isn't a quantization algorithm, it's a file format and ecosystem. llama.cpp implements several quantization methods under the GGUF umbrella, and the naming convention is initially confusing:
- Q4_0: Simple 4-bit quantization with 32-weight blocks, one scale per block
- Q4_1: Q4_0 + per-block minimum value (effectively an offset)
- Q4_K_S: K-quant small, uses importance metrics to vary precision per tensor
- Q4_K_M: K-quant medium, more tensors get 5-bit treatment
- Q5_K_M: K-quant medium at 5-bit base
- Q8_0: 8-bit quantization (good baseline, nearly lossless)
The K-quants are the interesting ones. They use a heuristic: attention projection layers (Q, K, V, O matrices) are more sensitive to quantization error than FFN layers. So Q4_K_M quantizes attention layers at 5-bit while keeping FFN at 4-bit:
# Quantizing with llama.cpp
./llama-quantize input-model-f16.gguf output-q4km.gguf Q4_K_M
Mixed-precision layouts use different representations for different tensors; inspect the output file rather than inferring its size from the format name.
Why GGUF wins for local inference:
- CPU+GPU hybrid: llama.cpp can split layers between CPU and GPU. Got a laptop with 8GB VRAM and 32GB RAM? Put 20 layers on GPU and 12 on CPU.
- Memory-mapped loading: The model file is
mmap'd, with pages loaded as needed; measure cold and warm startup separately. - Apple Silicon optimized: Metal shaders for M-series GPUs use unified memory efficiently.
- No Python dependency: The inference server is pure C++. Deployment is copy a binary and a model file.
Method 4: SqueezeLLM
SqueezeLLM is the method that receives comparatively little attention, which is arguably a mistake. It does something fundamentally different from the other three: it separates weights into a "dense" quantized component and a "sparse" correction matrix:
W ≈ W_quantized + S (sparse correction)
The sparse matrix S contains corrections for the weights where quantization error is highest (the outliers). The size of that correction and its memory overhead depend on the configuration.
The storage cost and quality effect of sparse corrections must be evaluated for the chosen model.
The catch: SqueezeLLM inference requires custom CUDA kernels for the sparse-dense decomposition, and the ecosystem support is minimal. You'll be writing your own serving code. For research or internal tools, worth it. For production serving at scale, the ecosystem maturity of GPTQ/AWQ/GGUF wins.
How to compare methods
Use the same model revision, input corpus, output limits and evaluation tasks. Record quantization settings, calibration data, runtime versions, hardware, warm-up and repeated runs. Report weight storage, peak process memory, time to first token, throughput and task quality separately.
Select candidates that the target runtime supports, then measure them against the unquantized baseline. A smaller weight file does not establish lower process memory, faster execution or acceptable task quality. The linked experiment below illustrates why those outcomes need separate measurements.
Reproducible experiment: weight size and process memory
Quantization Quality Lab separates storage, memory, latency and retrieval quality in a real MiniLM CPU comparison between FP32 and dynamic int8. Weight files became 23.5% smaller, but median process RSS after loading increased from 355.22 to 404.26 MiB. Median warm inference improved while int8 p95 latency worsened at 64 and 128 tokens. Top-1 results stayed unchanged in the small held-out set, but one query's rank worsened at shorter lengths.
The public repository retains timings, embeddings, rankings, hashes and negative outcomes. The experiment covers one Xeon host, one encoder and synthetic retrieval tasks. It does not measure generation, perplexity or the GPTQ, AWQ and GGUF methods compared above.
Editorial review, 2026-11-10: Removed measurements and experience claims that lacked linked supporting evidence. The linked project reports retain their stated scope; this article is not a production case study.