GPUs for Inference

Topics Covered

Inside a GPU

Many simple cores

Tensor cores

The memory hierarchy

HBM is the inference bottleneck

Clock speed, power and sustained performance

Form factors

What this means for serving

Why one request leaves a GPU idle

Precision formats in hardware

Serving LLMs is a hardware problem as much as a software one. The cost, latency and capacity of a deployment are set by the GPUs it runs on, and choosing and using them well requires knowing what they are good at and where they bottleneck. This lesson explains GPU architecture at the level a serving engineer needs, the memory hierarchy, the roofline model, the main GPU generations and alternatives, and how to choose hardware for a workload. This first section looks inside a GPU.

Many simple cores

A CPU has a few dozen powerful cores designed to run complicated, branching code quickly, one thread at a time per core. A GPU has thousands of simpler arithmetic units organized to run the same instruction on many pieces of data at once. An NVIDIA H100 has 132 streaming multiprocessors, each with 128 general purpose arithmetic lanes and four tensor cores, for 16,896 such lanes on the full chip. Programs that apply the same operation to large arrays, such as matrix multiplication, run thousands of times faster on this design than on a CPU.

Work is launched on a GPU as kernels: functions executed by many threads at once, organized into blocks that are scheduled onto streaming multiprocessors. A transformer forward pass is a sequence of kernels, one or more per operation: matrix multiplications, attention, normalization, activation functions and so on. Each kernel launch has a small fixed cost of a few microseconds, which matters when a decode step consists of hundreds of small kernels, and is one reason engines fuse kernels and capture whole steps as CUDA graphs.

Tensor cores

Tensor cores are specialized units that perform small matrix multiply accumulate operations in one instruction, such as multiplying two small tiles of 16 bit numbers and adding the result to a 32 bit accumulator. They provide most of the floating point throughput of modern data center GPUs. On an H100 SXM, tensor cores deliver about 989 trillion dense bfloat16 operations per second and about 1,979 trillion dense FP8 operations per second, while the general purpose lanes provide only about 67 trillion 32 bit operations per second. Any operation that is not a matrix multiplication runs at a small fraction of peak.

This is why transformer inference is organized around matrix multiplications: projections and feed forward layers map directly onto tensor cores. It is also why lower precision formats speed up compute bound phases: each halving of precision roughly doubles tensor core throughput, from 16 bit to 8 bit and, on the Blackwell generation, to 4 bit formats. And it explains why non matrix operations such as softmax, normalization and sampling, though small in FLOPs, can take noticeable time if they are not fused into the matrix kernels around them.

Tensor cores multiply small tiles of two matrices in a single instruction and add the result to an accumulator. Big matrix products are many tiles in parallel.

The memory hierarchy

A GPU has several levels of memory with very different sizes and speeds. Registers, private to each thread, are the fastest and smallest. Shared memory and L1 cache, about 256 kilobytes per streaming multiprocessor on the H100, are fast on chip memory that threads in a block can share. The L2 cache, 50 megabytes on the H100, is shared across the chip. High bandwidth memory, HBM, is the large off chip memory where weights and the KV cache live: 80 gigabytes at about 3.35 terabytes per second on the H100 SXM, and 141 gigabytes at about 4.8 terabytes per second on the H200.

Moving data up this hierarchy is the main cost of most operations. A kernel that reads each weight from HBM once, uses it a few times and discards it is limited by HBM bandwidth. A kernel that loads a tile into shared memory and reuses it many times before loading the next is limited by compute. Writing efficient GPU code is mostly about maximizing reuse of data once it is on chip, which is exactly what FlashAttention does for attention, covered in lesson twelve.

HBM is the inference bottleneck

For decode, the critical number is HBM bandwidth, because each step reads all the weights and the KV cache from HBM with little reuse at small batch sizes. Weights cannot fit in on chip memory: even the 50 megabyte L2 cache holds a tiny fraction of a 16 gigabyte model. So every step streams gigabytes from HBM, and the step time is roughly the bytes read divided by bandwidth. A GPU with 40 percent more bandwidth, such as the H200 compared with the H100, decodes memory bound workloads about 40 percent faster, even though their compute peaks are the same.

HBM capacity matters as much as bandwidth. It decides whether a model fits on one GPU or needs several, and how much memory remains for the KV cache, which determines batch size. Each GPU generation has increased capacity: 40 or 80 gigabytes on the A100, 80 on the H100, 141 on the H200, 192 on the B200 and 288 on the B300. Larger memory lets a single GPU serve larger models or hold more cache, often a bigger practical improvement for inference than additional compute.

Clock speed, power and sustained performance

Peak numbers assume full clock speed. Under sustained heavy load, GPUs may lower clocks to stay within power and thermal limits; the H100 SXM is rated at up to 700 watts. Inference workloads that are memory bound often draw less power than training workloads and hold clocks well, while compute bound prefill at large batches can throttle. Data center cooling, power capping policies set by cloud providers and the airflow of the server chassis all influence sustained performance. Two nominally identical GPUs in different servers can differ by several percent in throughput, which matters when benchmarking.

Form factors

Data center GPUs come in different form factors. SXM modules mount on a baseboard that connects several GPUs with NVLink and allows higher power limits; they are standard in eight GPU servers such as NVIDIA HGX systems. PCIe cards plug into standard slots, run at lower power and usually connect to each other only over PCIe, with lower bandwidth between GPUs. The H100 PCIe has less memory bandwidth, about 2 terabytes per second, and lower peak compute than the SXM version. For models that fit on one GPU, PCIe cards can be cost effective; for models that need several GPUs with tensor parallelism, SXM systems with NVLink are usually necessary.

What this means for serving

For a serving engineer, the GPU reduces to a few numbers: HBM capacity, HBM bandwidth, peak dense tensor throughput at the precisions you will use, interconnect bandwidth to other GPUs, and price per hour. Capacity sets what fits. Bandwidth sets decode speed. Tensor throughput sets prefill speed and the batch size at which decode becomes compute bound. Interconnect sets how well models split across GPUs. Price turns all of it into cost per token. The rest of this lesson shows how to combine these numbers with a model and a workload.

Why one request leaves a GPU idle

A single decode request asks the GPU to multiply a weight matrix by one vector per layer. That keeps the memory system busy streaming weights, but it gives the tensor cores almost nothing to do, because each weight participates in a single multiply and add before being discarded. Thousands of arithmetic lanes sit waiting for bytes. The GPU is designed to be fed many independent pieces of work at once, and serving systems exist largely to collect enough concurrent requests to keep it busy. Every technique in the Making Inference Fast part of this course, from continuous batching to speculative decoding, can be read as a way to give the hardware more useful work per byte it reads.

Precision formats in hardware

Each GPU generation supports a specific set of number formats in its tensor cores. Ampere added bfloat16 and TF32. Hopper added FP8 in two variants, E4M3 with more precision and E5M2 with more range. Blackwell added FP4 and microscaling formats such as NVFP4 and MXFP4, where small groups of values share a scale factor. A model quantized to a format the hardware does not support natively must be converted back to a supported format inside the kernel, which saves memory and bandwidth but not compute. So the precision you can exploit for prefill speed depends on the generation you deploy on.

Five numbers describe a GPU for serving

Memory capacity, memory bandwidth, dense tensor throughput at your precision, interconnect bandwidth and hourly price. Almost every inference performance question can be estimated from these and the model configuration.