Module 7 · AI infrastructureLesson 73 of 888 minAdvanced
GPU architecture and memory
GPUs have thousands of simple cores and very fast memory. For language models, how much memory and how fast it can be read matter more than raw compute.
Try a 7B model on the 24 GB GPU, then add users until the KV cache doesn't fit. Switch to 70B and see what it takes to fit.
Modern AI runs on GPUs (and similar accelerators like TPUs). Knowing a few numbers about them explains most AI infrastructure decisions.
What's inside
- Thousands of cores that do the same maths on lots of data at once, especially matrix multiplication. Specialised tensor cores make that even faster.
- High-bandwidth memory (HBM): 24 to 192 GB on one card, readable at 1 to 8 terabytes per second.
- Fast links between GPUs (NVLink) so several GPUs can act together.
Memory decides what fits
Model weights take roughly:
parameters x bytes per parameter
| Model | 16-bit | 8-bit | 4-bit |
|---|---|---|---|
| 7B | 14 GB | 7 GB | 3.5 GB |
| 13B | 26 GB | 13 GB | 6.5 GB |
| 70B | 140 GB | 70 GB | 35 GB |
On top of weights, each conversation needs a KV cache (more in its own lesson), which grows with how long the conversation is. Long contexts and many users can use more memory than the model itself.
Bandwidth decides speed
To generate one token, the GPU must read all the weights from memory. A 14 GB model on a GPU with 3.35 TB/s bandwidth can produce at most about 240 tokens per second for a single user, no matter how many cores it has.
That's why generation is called memory-bound. The fix is to batch: process many users' next tokens in the same pass, so each weight read is shared. Throughput rises almost for free until compute becomes the limit.
Prefill vs decode
- Prefill: reading the prompt. All prompt tokens are processed in parallel. Compute-bound and fast.
- Decode: generating the answer one token at a time. Memory-bound.
Serving systems schedule these two phases differently, and the rest of this module explains how.