Training & Inference

AI Model Quantization for Inference: INT8, FP8, and Deployment Efficiency

AI model quantization stores a trained model's numbers in a smaller data type, such as 8 bits per weight in place of 16. We'd test it before adding GPUs to an inference deployment, because 8-bit weights need half the GPU memory of 16-bit weights.

NVIDIA's quantization guide shows the effect on Llama2 7B, a 7-billion-parameter model: its weights drop from about 14 GB at 16 bits (FP16) to about 7 GB at 8 bits (FP8). Accuracy can drop too, so check the quantized model on an in-house test set before it goes into production.

TL;DR: Convert the finished model to 8-bit integers (INT8) or FP8, a step called post-training quantization (PTQ), and test accuracy on in-house data. If accuracy drops, try three PTQ methods built to limit the loss (AWQ, GPTQ and SmoothQuant) before paying to retrain the model with quantization-aware training (QAT).

What Gets Quantized in a Model: Weights, Activations, and the KV Cache

NVIDIA's guide names three parts of a transformer model as quantization targets:

  1. Weights: the parameters the model learned in training. They stay fixed after training and take most of the model's memory, so they give the largest saving.
  2. Activations: the intermediate values each layer computes for each request. Their ranges change with each input and include outliers, which makes them harder to quantize than weights.
  3. KV cache: the stored attention keys and values of earlier tokens, kept so the model skips recomputing them for each new token. It grows with context length and with the number of requests served at once, so it competes with the weights for GPU memory.

A 70-billion-parameter model shows what the weight saving means for GPU count. Its weights take about 140 GB at 16 bits per parameter and about 70 GB at 8 bits, figures that come from multiplying parameter count by bytes per parameter.

On 80 GB GPUs, the 16-bit weights need two GPUs before counting runtime memory. The 8-bit weights fit on one GPU, with about 10 GB left for cached tokens and other runtime memory.

Larger deployments start GPU cluster capacity planning with the same multiplication.

Precision Formats in Practice: FP32, FP16/BF16, INT8, FP8, and INT4

A format with more bits holds more distinct values and costs more memory per value. IBM's explainer counts about 4 billion possible values in 32-bit floating point (FP32) and 256 in INT8.

Quantization rounds each original value to the nearest value in the smaller set, which costs some accuracy. The table compares the common formats for inference.

FormatBits per valueApproximate distinct valuesNote
FP3232~4 billion32-bit baseline
FP16 / BF1616~65,00016-bit baseline; BF16 keeps FP32's range
INT88256Half the memory of 16-bit formats
FP88~256Same memory as INT8, with a floating-point exponent
INT4 / NF4416Half the memory of 8-bit formats

INT8 and FP8 take the same memory. FP8 keeps a floating-point exponent, which gives it a wider range of values than INT8, so test which format holds accuracy better on hardware that supports both formats.

INT4 halves the footprint again and leaves 16 values per weight, the fewest in the table. NF4 is a 4-bit format with the same footprint.

Each scheme sets scaling factors, the numbers that map original values onto the smaller set. Two choices decide how well those factors fit the data:

  1. Symmetric or affine scheme: Each scheme uses a zero-point, the stored value that stands for real zero, and symmetric quantization fixes it at zero to skip many addition operations. NVIDIA reports that affine schemes, which store an offset zero-point, give little accuracy gain over symmetric quantization. NVIDIA's TensorRT and Model Optimizer tools use the symmetric scheme.
  2. Granularity: one scaling factor can cover a tensor (a block of numbers inside a layer), one channel of it or one small group of values. Per-tensor scaling is simplest and can give higher error. Per-channel scaling keeps an outlier channel from distorting the rest of the tensor, and per-block scaling gives finer control than per-channel scaling.

Post-Training Quantization vs Quantization-Aware Training: Cost and Testing Order

Run PTQ first, and pay for QAT when PTQ results miss the accuracy target. IBM's explainer describes PTQ as faster and cheaper, with more risk of losing accuracy.

IBM describes QAT as usually more accurate, at the cost of far more compute and representative training data.

PTQ of weights runs without extra data, because the weights stay fixed after training. Quantizing activations needs calibration: the team runs a small set of representative inputs through the model and records activation ranges to set the scaling factors.

Hugging Face's Optimum guide puts a typical calibration set at about 200 examples. Dynamic quantization skips calibration and computes activation ranges at runtime, at some speed cost compared with ranges set in advance.

NVIDIA's guide lists three methods that cut accuracy loss beyond basic scaling:

  1. AWQ (activation-aware weight quantization): protects the small share of weight channels that matter most to output quality, found from activation statistics collected during calibration.
  2. GPTQ: quantizes each row of a weight matrix separately, guided by an estimate of how sensitive the output is to each weight (second-order, or Hessian, information).
  3. SmoothQuant: shifts quantization difficulty from activations to weights with per-channel scaling, so both can run at 8 bits.

Try AWQ or GPTQ next on a 4-bit model that fails its accuracy test, since both methods target weights. SmoothQuant fits a deployment that needs both weights and activations at 8 bits.

How Quantization Changes an Inference Deployment: Memory, Throughput, and Energy

Halving weight memory gives a deployment three options:

  1. More model copies per GPU: each GPU serves more requests at once.
  2. Fewer GPUs: the same copies need about half the GPU memory for their weights.
  3. More room for cached tokens: longer contexts and larger batches fit in the freed memory.

At small batch sizes (few requests processed together), memory bandwidth limits throughput more than arithmetic speed. Generating each token at batch size 1 means streaming the weights and KV cache from GPU memory to the compute units.

Model bandwidth utilization (MBU) measures how close a deployment gets to the hardware's peak memory bandwidth. Our explainer on GPU utilization metrics cites about 60% MBU on a pair of H100 80 GB GPUs at batch size 1, from one published benchmark.

An 8-bit model moves half the weight bytes per token of a 16-bit model, so the same bandwidth produces more tokens per second until larger batches make compute the limit. Before cutting GPUs, check that the 8-bit version still meets the latency target and the accuracy bar.

Quantization's effect on energy depends on model size and batch size. Hugging Face's Optimum guide reports the benchmark results below for NF4 and for INT8 in bitsandbytes, a widely used quantization library.

ConfigurationEnergy result
NF4 on models of 5B parameters or moreClose to FP16 energy use
NF4 on models under 3B parameters25 to 56% more energy than FP16
INT8 mixed precision at the bitsandbytes default17 to 33% more energy than FP16
Batch size raised from 1 to 8–6484 to 96% less energy per token

On models under 3B parameters, NF4 cut memory by about 75% and still used more energy, because converting values back for each calculation cost more than the bandwidth it saved.

The tests ran on consumer GPUs (NVIDIA RTX 4090D and RTX 5090), so read them as a direction for H100 or B200 fleets.

In that benchmark, a larger batch cut per-token energy far more than a change of precision. Our guide to GPU inference bottlenecks covers what to check when throughput still falls short after quantization.

Quantization Risk Tiers by Format, Model Size, and Method

The sources we reviewed don't publish an accuracy-loss figure that holds across models and tasks. Read a quoted figure as the result for one model, one format and one test set.

We sort quantization choices into three tiers by how much testing they need before deployment:

  1. Lowest risk: INT8 or FP8 on a widely used dense model, one that runs each weight for each token, checked once on an in-house test set.
  2. Test before deployment: INT4, NF4 on small models (under 3B parameters) or heavy KV cache quantization. Check accuracy for each, and check energy use for small NF4 models.
  3. Worth paying for QAT: PTQ and the three methods above still miss the accuracy target at the bit width that fits the memory budget. QAT recovers accuracy with a training-scale compute spend and representative data, so the memory saving has to justify that outlay.

If QAT means adding GPU capacity, compare renting H100s with buying them before committing to the training run.

FAQ

Can I mix precisions within one model?

Yes, weights, activations and the KV cache can each use a different format, because each is a separate quantization target. Hugging Face's guide treats the bitsandbytes default INT8 mode as mixed precision.

How do I measure whether quantization hurt accuracy?

Compare the quantized model with the FP16 version on an in-house test set before shipping it to production. Published accuracy figures come from other models and tasks, so the team's own test result carries more weight than a published figure.

When quantizing a model, should I start with PTQ or QAT?

PTQ comes first, because it converts the finished model without another training run. Switch to QAT when PTQ and its refinements still miss the accuracy target.