Large language models can require substantial memory bandwidth and compute during inference. Quantization reduces those requirements by representing some model values with fewer bits than the floating-point formats commonly used during training.
The idea sounds simple: store numbers with lower precision. In practice, useful quantization is a trade-off among memory, latency, hardware support, implementation complexity, and model quality. Understanding that trade-off helps you choose a configuration based on measurements instead of assuming that fewer bits are always better.
What quantization changes
A neural network contains many numerical values, especially weights. A model stored with 16-bit weights needs roughly two bytes per weight before accounting for runtime buffers and other overhead. If those weights can instead be represented with 8 or 4 bits, their raw storage requirement falls substantially.
For example, ignoring metadata and packing overhead, one billion parameters require approximately:
16-bit weights: 2.0 GB
8-bit weights: 1.0 GB
4-bit weights: 0.5 GBThis does not mean a one-billion-parameter model will use exactly those amounts of memory at runtime. Inference also needs memory for activations, attention state, temporary buffers, runtime data structures, and often a key-value cache. Quantization primarily reduces the components that are actually stored or computed at lower precision.
Quantization maps values to a smaller set
Suppose a group of floating-point weights contains values across a continuous range. Integer quantization approximates those values with a limited set of representable levels.
A simplified affine mapping looks like this:
q = round(x / scale) + zero_pointwhere x is the original value and q is its quantized representation. During computation, the runtime interprets the quantized value using the corresponding scale and, when applicable, zero point.
Because several original values can map to the same quantized level, the process introduces quantization error. Good quantization methods choose scales, grouping strategies, and numerical formats that keep this error small enough for the target workload.
Bit width is only part of the design
It is tempting to describe a model simply as “8-bit” or “4-bit,” but that label leaves out important details.
A quantization scheme can vary in several ways:
- What is quantized. Weights may use low precision while activations remain in a floating-point format, or both may be quantized.
- How values are grouped. One scale can cover a large tensor, a channel, or a smaller group of weights. Smaller groups can preserve local ranges better but require more metadata.
- Which numerical format is used. Integer and low-precision floating-point formats have different ranges and hardware characteristics.
- When quantization happens. A model can be quantized after training, or quantization effects can be incorporated during training.
Two models described as 4-bit can therefore have different memory footprints, quality, and inference speed.
Post-training quantization is the practical starting point
Post-training quantization converts an already trained model without repeating the full training process. This makes it attractive when the goal is to deploy an existing model more efficiently.
Some methods quantize weights directly. Others use a calibration dataset to observe representative activations or estimate which values are especially sensitive to reduced precision. Calibration data does not need to reproduce the entire training corpus, but it should resemble the inputs the deployed model will receive.
Poor calibration can produce a model that looks acceptable on generic prompts while degrading on the actual application workload. Treat calibration data as part of the deployment configuration and keep it representative.
Quantization-aware training is a different trade-off
Quantization-aware training exposes the model to simulated quantization effects during training or fine-tuning. The optimization process can then adapt parameters to some of the error introduced by lower precision.
This can improve low-precision quality in cases where post-training quantization loses too much accuracy, but it costs additional training time and operational complexity. It is not automatically necessary for every model or bit width.
A sensible progression is usually to test a well-supported post-training method first, measure the result, and consider training-aware approaches only when the quality target cannot otherwise be met.
Why lower precision can improve inference speed
Quantization often helps because inference for large models moves enormous amounts of weight data through the memory hierarchy. Smaller weights reduce memory traffic and may allow more of the model to fit in faster memory.
Specialized hardware can also execute supported low-precision operations more efficiently than higher-precision alternatives. However, a smaller model file does not guarantee lower latency.
A runtime may need to dequantize values, use kernels that are poorly optimized for a particular format, or fall back to operations that do not benefit from the chosen precision. Performance depends on the complete combination of model format, inference engine, hardware, batch size, sequence length, and workload.
Measure on the deployment target rather than extrapolating from file size alone.
Keep the key-value cache in mind
For autoregressive language models, generated tokens create key and value tensors that are reused by attention in later decoding steps. This key-value cache grows with sequence length and can become a significant part of memory consumption, especially with long contexts or concurrent requests.
Quantizing model weights does not automatically quantize the key-value cache. If your workload is dominated by long contexts, reducing weight memory may produce less total-memory improvement than expected.
When comparing configurations, record both the model’s resident memory and the incremental memory consumed as context length and concurrency increase.
Quality loss is workload dependent
Quantization error does not affect every task equally. A configuration that performs well for conversational text may behave differently on code generation, mathematical reasoning, multilingual input, structured extraction, or a domain with unusual vocabulary.
Average benchmark scores can also hide important regressions. A small overall change may contain a large decline on one class of requests that matters to your application.
Evaluate quantized models with the same representative test set used for other model changes. Useful checks include:
- task success or accuracy;
- instruction following;
- structured-output validity;
- long-context behaviour;
- output consistency across important prompt classes;
- latency to first token and per-token decoding speed;
- peak memory usage and sustainable concurrency.
Compare against the unquantized or higher-precision model as a baseline.
Do not assume the lowest bit width wins
Moving from 16-bit to 8-bit may provide a useful memory reduction with little visible quality change for a particular model and runtime. Moving further to 4-bit can save more memory, but the additional approximation may become noticeable. The exact result depends on the model and quantization method.
There is also little value in choosing a very compact format if the target runtime lacks efficient kernels for it. A theoretically smaller representation can be slower than a slightly higher-precision format with mature hardware acceleration.
The best precision is therefore the lowest-cost configuration that still meets your quality and latency requirements, not necessarily the configuration with the fewest bits.
Build a repeatable comparison
Treat quantization as an inference configuration that needs regression testing. A useful experiment keeps the model, prompts, decoding parameters, and hardware fixed while changing the quantization setup.
Record at least:
model version
quantization method and bit width
runtime and hardware
representative quality metrics
peak memory
first-token latency
decode throughput
maximum useful concurrencyRun the same evaluation whenever you change the model, quantizer, runtime, or hardware. This makes it possible to distinguish a real improvement from a result caused by a different benchmark environment.
Choose quantization from deployment constraints
Quantization is most valuable when it solves a concrete deployment constraint. If a model barely exceeds available accelerator memory, moderate quantization may make deployment possible without changing the model architecture. If memory bandwidth limits decoding speed, a well-supported low-precision format may improve throughput. If quality is the dominant requirement and memory is plentiful, aggressive quantization may offer little benefit.
Start by defining the constraint, establish a higher-precision baseline, and then test progressively smaller representations. Stop reducing precision when quality, latency, or runtime compatibility no longer improves the overall system.
Quantization is not merely compression. It is a deployment decision that changes how numerical approximation, hardware efficiency, memory use, and model behaviour interact. The right choice comes from evaluating all four together.