Education › Inference › Stage 1: GPU & systems foundation

GPU architecture for inference

CPU vs GPU, SMs, CUDA and Tensor Cores, VRAM and memory bandwidth — and why inference workloads favour GPUs.

Beginner ~30 min read Module 1 of 15

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.

After this module you can
  • 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.

CPUGPU
CoresTens of complex coresThousands of simple arithmetic units
Optimised forLatency of one thread, branchingThroughput of many identical operations
MemoryLarge, slower system RAMSmaller, much faster on-package memory (HBM or GDDR)
Role in servingTokenizing, scheduling, HTTP, orchestrationThe 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.

Note

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.

GPUPCIe: load, launchbandwidth-boundfeedmatrix mathsCPUtokenize, scheduleVRAM (HBM)weights + KV cacheL2 cacheshared by all SMsSMsTensor CoresNext token
Every decode step streams the weights from VRAM through L2 into the SMs, so memory bandwidth, not Tensor Core speed, usually sets the pace.

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.

Back-of-envelope sizing (example numbers, not a specific product)
text
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

SpecWhy 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 precisionPrefill 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.
Hands-on practice

Size models against real GPUs

  1. Pick three GPUs (one consumer card, two datacenter parts) and write down memory capacity, memory bandwidth and dense FP16 Tensor Core TFLOPS from the vendor spec sheets.
  2. Pick three open-weight models of different sizes and compute their FP16 and FP8 weight sizes with parameters x bytes.
  3. Mark which model fits on which GPU, leaving at least 20% of VRAM for KV cache and working memory.
  4. For each fitting pair, estimate the batch-1 decode upper bound as bandwidth divided by weight bytes.
  5. If you have any NVIDIA GPU, run nvidia-smi and compare the reported memory with the spec sheet.
  6. Write a short table of your findings; you will check these estimates against real benchmarks in stage 4.
Cheat sheet

GPU architecture for inference — at a glance

Main things to focus on

  • Inference is matrix maths: thousands of simple GPU units beat a few complex CPU cores.
  • Tensor Cores do the heavy lifting, faster at lower precision.
  • VRAM capacity decides what fits; VRAM bandwidth decides decode speed.
  • Single-request decode is memory-bandwidth-bound; batching reuses each weight read.
  • The CPU still tokenizes and schedules; a starved GPU shows low utilisation.
  • Compare spec-sheet TFLOPS at the same precision, dense.

Sizing formulas

weights_bytes = params x bytes_per_paramFP16/BF16 = 2, FP8 = 1, 4-bit = 0.5
max_tok_s(batch 1) ~ bandwidth / weights_bytesUpper bound on decode speed per request
FLOPs per token ~ 2 x paramsForward pass cost, ignoring attention
VRAM needed ~ weights + KV cache + ~10% overheadRule of thumb for fit

Vocabulary

SMStreaming multiprocessor: the GPU's building block
CUDA coreGeneral-purpose arithmetic unit inside an SM
Tensor CoreMatrix multiply-accumulate unit; does the transformer maths
Warp32 threads executing the same instruction
HBM / VRAMHigh-bandwidth on-package memory holding weights and KV cache

Precision formats

FP324 bytes; training master weights, rarely used to serve
BF16 / FP162 bytes; the default serving precision
FP81 byte; native on recent datacenter GPUs
INT4 / FP4Half a byte; aggressive quantization, check quality

First commands

nvidia-smiGPUs, memory in use, utilisation, processes
nvidia-smi -LList GPUs with their UUIDs
nvidia-smi -q -d MEMORYDetailed memory report

Common pitfalls

  • Buying GPUs on peak TFLOPS when your workload is bandwidth-bound decode.
  • Forgetting the KV cache when checking whether a model fits.
  • Comparing a sparse FP8 figure on one card with a dense FP16 figure on another.
  • Ignoring CPU capacity, so tokenization and scheduling starve the GPU.
  • Assuming lower precision is free without checking output quality.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →