9 lessons

GPUs & Accelerators

Throughput hardware and its price: why GPUs win on wide regular work, why transfers and divergence undo it, and what specialized accelerators trade away to be fast at one thing.

SourceCompilerInstructionsFront EndExecutionRegistersCachesMemoryI/OBehavior
CPU or GPU: Two Bets About What Work Looks Like
▶ lab

A CPU spends its transistor budget making one instruction stream go fast — speculation, out-of-order issue, large caches. A GPU spends a comparable budget on many simple lanes running the same operation over different data. Neither is faster; the shape of your work decides which bet pays.

Q · What is a CPU doing with all the transistors a GPU spends on lanes, and how do I tell which of the two my workload actually wants?
What Is Actually Inside a GPU
▶ lab

A host CPU, a device with many compute units, an unusually large register file, a small block of programmer-managed on-chip memory per unit, and a large pool of high-bandwidth global memory. The register file being large — and being the thing that limits how many lanes stay resident — is the part that surprises people.

Q · What are the parts of a GPU, and which of them ends up limiting how much parallelism I actually get?
Lanes, Divergence and Coalescing

Lanes execute in lockstep groups: one instruction, many lanes, different data. Two consequences follow and both are unlike anything on a CPU — a data-dependent branch makes the group execute both sides in sequence, and the memory addresses the lanes request must line up or the traffic multiplies.

Q · Why does an `if` inside a GPU kernel cost so much more than the same `if` on a CPU, and why does the access pattern matter more than the number of bytes?
The Transfer You Forgot to Count
▶ lab

Host memory and device memory are separate pools connected by a bus that is slow relative to both. A kernel ten times faster than the CPU loses if you pay two crossings to use it — so the real question is not how fast the kernel is, but at what input size the whole path overtakes staying put.

Q · When does the cost of getting data onto the device and back exceed the time the device saves?
What GPU-Friendly Work Has in Common

Dense linear algebra, graphics, model training and inference, image processing, scientific simulation. The list looks unrelated until you notice that every entry is wide, regular and reuses each loaded byte many times — and that the workloads which disappoint share the opposite properties.

Q · What do the workloads that genuinely suit a GPU have in common, and how do I tell in advance whether mine is one of them?
Accelerators: The Specialization Spectrum

GPUs, AI accelerators, NPUs and FPGAs are not four unrelated products. They are points on one axis running from fully general to fully fixed, and each step along it trades away the ability to run arbitrary work in exchange for doing one kind of work with less silicon and less power.

Q · What separates a GPU from an AI accelerator from an FPGA, and what does each give up to be good at what it is good at?
The Specialization Trade-off

Specialized hardware is more efficient because it does less. That is a genuine gain and a genuine risk: the efficiency comes from decisions frozen at design time, and workloads have a habit of changing shape faster than silicon can be replaced.

Q · What exactly am I giving up when I choose more specialized hardware, and how do I decide whether the exchange is worth it?
LLM Inference Is a Memory Bandwidth Problem
▶ lab

The path from prompt to token runs through matrix operations on an accelerator, and the surprise is which resource binds. Generating tokens one at a time reads the entire model from memory per token, so inference is usually bandwidth-bound rather than compute-bound — which is why model size and memory bandwidth dominate the conversation.

Q · When an agent sends a prompt to a model, what does the hardware actually do — and which resource runs out first?
Model Memory, and Why the Naive Number Is Always Too Low

Parameters times bytes per parameter gives a floor, not an answer. Activations, the KV cache that grows with context and concurrency, and runtime overhead all sit on top — which is why a model that "fits in memory" by the simple calculation frequently does not.

Q · How much memory does serving a model actually need, and what does reducing precision buy in hardware terms?