0%
LLM Inference and Serving: GPUs, Batching, and Cost
How Inference Works
Hardware and Memory
Serving Systems
Quantization
Quantization stores model weights, and sometimes activations and the KV cache, in fewer bits than the 16 bit formats models are trained in. Because decode is memory bound, halving the bytes of the weights nearly halves the time to read them, and frees memory for larger batches and longer contexts. Done well, quantization cuts serving cost substantially with little loss of quality. Done carelessly, it quietly degrades answers in ways benchmarks may miss. This lesson explains why quantization works, the main number formats, the methods used to quantize weights, activations and caches, and how to evaluate quality before shipping. This first section explains the motivation.
Bytes are the bottleneck
Lesson five showed that a decode step reads every weight from high bandwidth memory, and for small and medium batches this read dominates step time. A 70 billion parameter model in 16 bit precision holds 140 gigabytes; reading it at 3.3 terabytes per second takes over 40 milliseconds per step on one GPU, before any cache reads. Storing the same weights in 8 bits halves the read to about 20 milliseconds; in 4 bits, it falls to about 10. Since decode speed and cost per token follow the bytes moved, quantization is one of the few changes that speeds up every decode step for every user.
Memory capacity as well as bandwidth
Quantization also changes what fits. A 70 billion parameter model in 16 bits needs at least two 80 gigabyte GPUs just for weights, with tensor parallelism and its communication overhead. In 8 bits it fits on one 80 gigabyte GPU with a small cache, and comfortably on one 141 gigabyte H200. In 4 bits it fits on one 48 gigabyte card. Fewer GPUs per replica means less communication, simpler deployment and lower cost. The memory freed from weights also becomes KV cache, so the same GPU runs larger batches or longer contexts.
Why models tolerate fewer bits
Neural network weights are trained in 16 or 32 bit formats, but they do not need that much precision to compute good outputs. Each weight contributes a small part to sums over thousands of terms, and small errors in individual weights tend to average out. Experiments since the early days of deep learning showed that 8 bit weights lose almost nothing for most models, and careful methods bring 4 bit weights close to full precision for large language models. Larger models tend to tolerate quantization better than small ones, since each weight carries less of the total information.
Where quantization does not help
Quantization helps most when decode is memory bound, which is the common case for interactive serving. When batches are large and steps become compute bound, weight only quantization helps less, because the arithmetic still runs in 16 bits after dequantizing the weights. To speed up compute bound work, both weights and activations must be quantized so the tensor cores can run low precision arithmetic, such as FP8 on Hopper and FP4 on Blackwell. Prefill is usually compute bound, so it benefits mainly from activation quantization, not weight only formats.
Quality is the price
Every quantization method introduces error, and the question is whether the error matters for your task. Benchmarks often show small average drops, but some tasks, such as long reasoning chains, code generation, math and low resource languages, can be more sensitive than averages suggest. Quantization is therefore an engineering trade off that must be measured on the workload, not a free speedup. The rest of this lesson builds the vocabulary to make that trade off well.
The landscape at a glance
In current practice, FP8 weights and activations on Hopper or newer GPUs are the most common production choice for large models, giving near lossless quality and roughly twice the throughput of 16 bit. Four bit weight only methods such as AWQ and GPTQ are popular for fitting large models on fewer or smaller GPUs, especially for low batch serving. FP4 formats on Blackwell promise another doubling for compute bound work. KV cache quantization to 8 bits is increasingly common for long context serving. Each of these is covered in the sections that follow.
Who quantizes
Many open models are published with official quantized checkpoints, often FP8, produced by the model developers with careful calibration. Community repositories offer AWQ, GPTQ and GGUF versions of popular models. Engines such as vLLM, SGLang and TensorRT LLM can also quantize on the fly at load time for some formats, and tools such as LLM Compressor, the TensorRT Model Optimizer and AutoAWQ let teams produce their own. Using an official checkpoint is usually the safest starting point, since the developers have evaluated it.
A worked example of the savings
Consider serving a 70 billion parameter model for a chat product at moderate concurrency. In BF16 on four H100 GPUs with tensor parallelism, each replica reads 35 gigabytes of weights per GPU per step and spends part of each step on all reduce communication. Switching to FP8 halves weight bytes per GPU and allows the same model on two GPUs instead of four, with half the communication partners. If throughput per replica stays similar or rises, cost per token roughly halves, because each replica now uses half the hardware. Switching instead to 4 bit AWQ fits the model on a single H100 with room for cache, removing tensor parallelism entirely, though at high batch the 4 bit kernels lose some of their advantage. These are the kinds of savings that make quantization the first optimization many teams try after adopting a modern engine.
Quantization is not compression in general
Quantization reduces the precision of each number but keeps the model architecture and number of parameters. Other techniques reduce model size differently: pruning removes weights or whole structures, distillation trains a smaller model to imitate a larger one, and low rank factorization replaces matrices with products of smaller ones. These can combine with quantization. Distillation followed by quantization, for example, produces small fast models for narrow tasks. Quantization is the most widely used of these in serving because it applies to an existing model without retraining and is supported by every major engine.
The quality and cost frontier
It helps to picture quantization choices on a chart with cost per token on one axis and task quality on the other. BF16 sits at the top right, best quality and highest cost. FP8 usually sits almost level with it but much further left, cheaper with nearly the same quality, which is why it has become the default. Four bit methods move further left again, with a quality drop that ranges from negligible to noticeable depending on the model and task. The goal is to find the leftmost point that stays above your quality bar. That point differs between products: a casual chat feature may accept a small drop for half the cost, while a coding assistant or medical summarizer may not.
Quantization and energy
Moving bytes costs energy as well as time. Reading a value from high bandwidth memory takes far more energy than a multiply add on that value, so cutting the bytes per weight also cuts power per token. For operators running large fleets, this shows up as lower electricity and cooling costs and, where power is the binding constraint on how many GPUs a data center can host, as more tokens from the same power budget. Energy per token is becoming a headline metric for serving efficiency, and quantization is among the most direct ways to improve it, alongside batching and better kernels. Teams reporting sustainability metrics increasingly track tokens per kilowatt hour next to tokens per dollar.
When to skip quantization
Quantization is not always worth the effort. For a small model that already fits comfortably on one GPU with plenty of cache, serving low traffic, the speedup may be modest and the evaluation work may outweigh the savings. For tasks where every point of quality matters and cost is secondary, full precision may be the right choice. The decision should follow from measured gains and quality, not from habit.
Decode time follows bytes moved. Cutting the bytes per weight speeds up every step for every user, which is why quantization is often the cheapest large win in serving.