AI Accelerators
AI Engineer path · lesson 102 of 124Find out which ceiling you are actually under. Walk the roofline from prefill to decode, climb the three-level memory hierarchy, and compute a real model's bandwidth utilization to see why quantization speeds up generation without doing less arithmetic.
Key insight
Inference can exceed the cost of training. Desislavov et al. (2023) put it at up to 90% of the machine learning costs for deployed AI systems — which is the whole reason this chapter exists, and the reason a separate class of inference chips is worth designing.
Which number is the bottleneck?
Sort each workload by what limits it on the accelerator.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
Compute-bound (FLOPS)
Drop items hereMemory-bandwidth-bound
Drop items hereTest your knowledge
A GPU beats a CPU on ML workloads mainly because:
The short version
A kitchen. A CPU is one brilliant chef who can cook anything in sequence; a GPU is a thousand line cooks who can only chop, but all at once. Neither matters if the pantry is down the hall — most of the time the kitchen is not waiting on knives, it is waiting on ingredients.
In more depth
AI Accelerators
Every latency and cost number traces back to two hardware quantities: how fast the chip does arithmetic, and how fast it moves bytes.
CPU vs GPU
Which ceiling are you under?
From the Roofline paper (Williams et al., 2009). The deciding quantity is arithmetic intensity — operations per byte of memory access.
| Phase | Bound | Fixed by |
|---|---|---|
| Prefill (input, processed in parallel) | Compute-bound | More FLOP/s |
| Decode (one output token at a time) | Memory bandwidth-bound | More bandwidth, or fewer bytes |
This single fact explains three things that look unrelated: quantization speeds up generation despite doing no less arithmetic; batching is nearly free during decode; and speculative decoding works because verification consumes idle FLOPs.
The three memory levels
| Level | Bandwidth | Capacity |
|---|---|---|
| GPU on-chip SRAM | often exceeding 10 TB/s | typically 40 MB or under |
| GPU HBM | 256 GB/s – over 1.5 TB/s | ~24–80 GB |
| CPU DRAM | 25–50 GB/s | 16–64 GB, or a TB+ |
PyTorch and TensorFlow do not expose fine-grained memory control — hence CUDA, Triton, ROCm.
MFU and MBU
nvidia-smi's utilization measures time active, not efficiency, and is near-useless.
Worked example: 7B in FP16 at 100 tokens/s = 7B × 2 × 100 = 700 GB/s; on an A100-80GB at a theoretical 2 TB/s, MBU = 70%.
Power
A100 has 54B transistors; H100 has 80B. An H100 at peak for a year uses ~7,000 kWh against a US household's 10,000 kWh. Maximum power draw is roughly 1.1–1.5× TDP.
Interview Questions
References & Further Reading
Love this visualization?
Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.
100% free • No credit card required