# Why GPUs

> [!NOTE]
>
> **In one minute**
>
> - A model is mostly **multiplications of large tables of numbers**. A GPU does thousands of them at once; a CPU does a few dozen.
> - A data-centre GPU also has very **fast memory** stacked next to the chip (HBM): it reads data several tens of times faster than a server's RAM.
> - Two numbers on a data sheet matter most for serving: **GPU memory** (does the model fit?) and **memory bandwidth** (how fast does it answer?).

**Before you start.** [How a large language model answers](<https://ai.ozarland.com/understand/how-an-llm-answers/index.md>). This page is background, except the figures marked DOC ([Conventions](<https://ai.ozarland.com/start/conventions/index.md>)).

## The work: multiplying tables of numbers

Inside a model, each layer multiplies the input (a table of numbers for the tokens) by a table of weights, then applies a simple function. A large model does this with tables of thousands by thousands of numbers, for dozens of layers, for every token. The operations are simple and **independent of each other**: they can all run at the same time.

## CPU and GPU: a few experts or a large crowd

|  | CPU | GPU |
| --- | --- | --- |
| Cores | Tens, each fast and clever (branches, caches, prediction) | Thousands, each simple, grouped to run the same instruction on many numbers |
| Best at | Varied, sequential work: an operating system, a database | The same operation on huge amounts of data: graphics, models |
| Memory | Server RAM, hundreds of GB, read at hundreds of GB/s | HBM on the board, tens of GB, read at several TB/s |

A CPU is a few experts who can each solve any problem. A GPU is a stadium of people who each add two numbers when told to: useless for a complex task, unbeatable for a billion additions.

## Tensor cores and low precision

Recent GPUs add **tensor cores**: units built only for multiplying small matrices, much faster than the general cores. They are fastest at low precision (16, 8, sometimes 4 bits), which is why models are served in BF16, FP8 or 4-bit formats ([What a model is](<https://ai.ozarland.com/understand/what-is-a-model/index.md#parameters-the-numbers-that-hold-what-was-learned>)).

## High-bandwidth memory

The memory of a data-centre GPU is **HBM** (high-bandwidth memory): memory chips stacked next to the processor in the same package. It is small compared with server RAM, but much faster. Because decoding reads every weight for each token ([How a large language model answers](<https://ai.ozarland.com/understand/how-an-llm-answers/index.md#worked-example-why-bandwidth-sets-the-speed>)), memory bandwidth often matters more than compute for serving.

## Reading a data sheet

Taking one common data-centre GPU as an example, the NVIDIA H100 SXM is given with DOC ([NVIDIA H100](<https://www.nvidia.com/en-us/data-center/h100/>)):

| Line of the data sheet | H100 SXM | What it tells you |
| --- | --- | --- |
| GPU memory | 80 GB | The largest model (weights + KV cache) one GPU can hold |
| GPU memory bandwidth | 3.35 TB/s | The speed of decoding for each user |
| NVLink | 900 GB/s | How fast this GPU talks to the other GPUs of the server ([Linking GPUs](<https://ai.ozarland.com/hardware/linking-gpus/index.md>)) |
| PCIe Gen5 | 128 GB/s | How fast it talks to the server's CPU and network cards |
| Multi-Instance GPU | Up to 7 instances of 10 GB | How finely it can be split ([Sharing a GPU](<https://ai.ozarland.com/hardware/sharing-a-gpu/index.md>)) |
| Max power | Up to 700 W | What your racks and cooling must supply, per GPU |

The compute figures (in TFLOPS) are also on the sheet, often for sparse low-precision maths that real models rarely reach. Compare GPUs on the same precision, and look at memory first.

## Common mistakes

- **"More TFLOPS, faster chatbot."** For one user, the answer speed follows memory bandwidth, not compute.
- **"A gaming GPU is the same thing, cheaper."** It may run small models well, but has less memory, no HBM, and is often not supported for virtualisation by its vendor.
- **"The GPU uses the server's RAM."** The model must be in the GPU's own memory to run at speed. Server RAM is a slow fallback.

## Check yourself

> [!NOTE]
>
> **Which data-sheet line tells you whether a 70B model in BF16 fits on one GPU?**
>
> GPU memory. 70B in BF16 needs 140 GB for the weights alone, more than the 80 GB of an H100 SXM, so it needs at least two such GPUs.

> [!NOTE]
>
> **Why are models served in 16, 8 or 4 bits rather than 32?**
>
> Smaller numbers take less memory, are read faster, and tensor cores compute fastest at low precision.

> [!NOTE]
>
> **What is HBM, and why does it matter for serving?**
>
> Memory stacked in the GPU package, read at several TB/s. Decoding reads every weight for each token, so its speed follows that bandwidth.

## Go further

- Next page: [How much memory a model needs](<https://ai.ozarland.com/hardware/memory-a-model-needs/index.md>).
