Every inference decision you will make later, from batch size to how many GPUs a model needs, comes back to two numbers on a GPU's spec sheet: how much memory it has and how fast it can move data. This lesson builds the mental model of a GPU an infrastructure engineer needs: why it beats a CPU at inference, what streaming multiprocessors, CUDA cores and Tensor Cores do, and why memory capacity and bandwidth, more than raw compute, decide what you can serve.
- Explain why neural-network inference runs far faster on GPUs than on CPUs
- Describe streaming multiprocessors, CUDA cores, Tensor Cores and the memory hierarchy
- Estimate whether a model fits in a GPU's VRAM from its parameter count and precision
- Estimate an upper bound on single-request decode speed from memory bandwidth
- Read a GPU spec sheet and pick out the numbers that matter for serving
Why GPUs: a few smart cores versus thousands of simple ones
A CPU has a handful of powerful cores built for low-latency, branch-heavy work: an operating system, a web server, a database query planner. A GPU has thousands of simpler arithmetic units built to apply the same operation to huge amounts of data at once. Neural-network inference is almost entirely the second kind of work: multiplying large matrices of weights by matrices of activations, billions of identical multiply-add operations with no branching.
That is why a GPU can be tens to hundreds of times faster than a CPU for the same model. CPUs still matter in an inference server: they tokenize text, run the HTTP server and the scheduler, and feed the GPU. A slow or overloaded CPU can starve an expensive GPU, which is one of the first things to check when GPU utilisation is mysteriously low.
| CPU | GPU | |
|---|---|---|
| Cores | Tens of complex cores | Thousands of simple arithmetic units |
| Optimised for | Latency of one thread, branching | Throughput of many identical operations |
| Memory | Large, slower system RAM | Smaller, much faster on-package memory (HBM or GDDR) |
| Role in serving | Tokenizing, scheduling, HTTP, orchestration | The model's matrix maths |
Inside a GPU: SMs, CUDA cores and Tensor Cores
An NVIDIA GPU is built from many streaming multiprocessors (SMs). Each SM has general-purpose CUDA cores for ordinary floating-point and integer arithmetic, Tensor Cores that perform small matrix multiply-accumulate operations in a single step, a large register file, and fast on-chip shared memory and L1 cache. Work is scheduled in groups of 32 threads called warps, which execute the same instruction together. AMD GPUs use different names (compute units, matrix cores) for the same ideas.
For transformer inference, Tensor Cores do almost all the useful work, because attention and feed-forward layers are matrix multiplications. Tensor Cores are fastest at low precision: each new GPU generation has added support for smaller number formats (FP16 and BF16, then FP8, then 4-bit formats on the newest parts). Halving the bytes per number roughly doubles the Tensor Core throughput and halves the memory needed, which is why quantization matters so much for serving.
Peak TFLOPS figures on spec sheets are usually quoted for the lowest precision and with sparsity. Compare like with like: the same precision, dense, on the formats your model and engine actually use.
The memory hierarchy, and why bandwidth is king
Data lives at several levels: registers and shared memory inside each SM (tiny, fastest), an L2 cache shared by all SMs (megabytes), and VRAM, the GPU's main memory (tens of gigabytes, high-bandwidth memory on datacenter parts). The model's weights and the KV cache live in VRAM, and every generated token requires reading the weights from VRAM into the SMs.
Two VRAM numbers dominate inference. Capacity decides what fits: the weights, the KV cache for every active request, and some working space. Bandwidth, in terabytes per second, decides how fast the weights can be streamed through the SMs. When generating one token for one request, the GPU must read every weight once but does only about two floating-point operations per weight, so it spends most of its time waiting on memory. Single-request decoding is memory-bandwidth-bound, and you will quantify that in the profiling lesson.
Weights in VRAM = parameters x bytes per parameter
8B params x 2 bytes (FP16) = 16 GB
8B params x 1 byte (FP8) = 8 GB
Decode upper bound at batch 1 ~ bandwidth / bytes read per token
2,000 GB/s / 16 GB ~ 125 tokens/s (FP16)
2,000 GB/s / 8 GB ~ 250 tokens/s (FP8)Batching is the escape hatch: if 32 requests decode together, the weights are read once per step but used 32 times, so throughput rises almost for free until compute or KV-cache memory runs out. Much of the rest of this track is about exploiting that.
Reading a spec sheet as an inference engineer
| Spec | Why it matters for serving |
|---|---|
| Memory capacity (GB) | Largest model plus KV cache that fits; how many concurrent requests |
| Memory bandwidth (TB/s) | Decode speed per request; usually the binding limit |
| Tensor Core TFLOPS at your precision | Prefill speed and large-batch throughput |
| Supported formats (FP8, FP4) | Whether quantized models run natively and fast |
| Interconnect (NVLink, PCIe) | How well a model split across GPUs performs |
| Power (W) | Rack density and running cost |
- A card with more VRAM but less bandwidth can hold a bigger model yet generate each token more slowly.
- Consumer GPUs are fine for learning and small models; datacenter GPUs add HBM, NVLink, ECC memory and partitioning features such as MIG.
- Price per GPU-hour only becomes meaningful once you divide by tokens served: cost per million tokens, covered in the production stage.