Accelerators: GPU, TPU, CPU and Edge — What the Memory Hierarchy Decides
You'll be able to:
You can read an accelerator spec sheet (peak FLOPs, memory capacity, memory bandwidth, interconnect) and place a given model and workload on the roofline, explain why FlashAttention is a memory-hierarchy trick rather than a maths trick, and say what changes when the target is a laptop CPU or a phone instead of a data-centre GPU.
Reading a spec sheet like an inference engineer
Every accelerator datasheet lists the same three numbers that decide inference performance: peak arithmetic throughput (FLOPs per second at a given precision), memory capacity, and memory bandwidth. A fourth, interconnect bandwidth between chips, decides how well the model splits across several devices. Marketing emphasises FLOPs; module 1 should have convinced you that for most decode workloads bandwidth and capacity are what you are buying.
The roofline, in one paragraph
Divide peak FLOPs by memory bandwidth and you get the device's ridge point, in FLOPs per byte. A workload whose arithmetic intensity (FLOPs it performs per byte it moves) is below that point is memory-bound; above it, compute-bound. Decode at batch size 1 performs about 2 FLOPs per weight while moving 2 bytes per weight (16-bit): intensity ≈ 1. Data-centre GPUs have ridge points in the hundreds, so single-request decode uses well under 1% of peak compute. Batching 64 requests raises intensity to about 64 — still below the ridge on big chips. Prefill of a 2,000-token prompt has intensity in the thousands and is firmly compute-bound. NVIDIA's "GPU Performance Background" guide is the vendor's own explanation of this model and of why matrix dimensions that are multiples of 8 or 16 matter for its tensor cores.
Worked example
A hypothetical device: 1,000 TFLOP/s dense 16-bit, 3 TB/s bandwidth, 80 GB capacity.
- Ridge point: 1,000 × 10¹² ÷ 3 × 10¹² ≈ 333 FLOPs/byte.
- A 7B model at 16-bit is 14 GB; it fits, with 66 GB left for KV cache and activations. A 70B model (140 GB) does not; at 4-bit (35 GB) it does, leaving about 45 GB for KV cache and activations.
- Single-request decode of the 7B model: 3 TB/s ÷ 14 GB ≈ 214 tokens/s ceiling; the compute needed, 14 GFLOP per token, would allow 70,000 tokens/s — the arithmetic units are 99.7% idle.
- At batch 64 the ceiling is still about 214 steps/s (same bytes per step) but now 13,700 tokens/s in aggregate, and compute utilisation rises to around 20%. Only at batch sizes in the hundreds does the device become compute-bound.
Those four lines explain most purchasing decisions: a chip with more bandwidth per dollar wins for interactive decode; one with more FLOPs per dollar wins for prefill-heavy or massively batched work; one with more capacity lets you avoid multi-chip sharding, which costs interconnect traffic every layer.
GPU, TPU and the memory hierarchy
GPUs and TPUs reach their peak FLOPs only when data is staged in on-chip memory (registers, shared memory/SRAM, the TPU's vector memory) rather than streamed from HBM. The "What Is a TPU?" chapter of How to Scale Your Model describes the TPU's systolic array and its deliberately simple memory system: huge matrix throughput fed by a compiler-scheduled pipeline, and inter-chip links designed so that very large models can be sharded across pods. GPUs are more general and more forgiving of irregular work; TPUs are extremely efficient when the computation is big, regular matrix multiplication — which transformer prefill and large-batch decode are.
FlashAttention (Dao et al.) is the clearest demonstration that the hierarchy, not the arithmetic, is the lever. Standard attention writes the full N×N score matrix to HBM and reads it back for the softmax and the value multiply. FlashAttention tiles the computation so each block of scores is computed, normalised and multiplied in on-chip SRAM and never materialised in HBM. It does more FLOPs than the naïve version (it recomputes pieces of the softmax) and is still several times faster, because the bytes moved to slow memory drop by an order of magnitude. The attention results are identical — it is an exact method.
CPUs, laptops and phones
Off the data-centre, the constraints flip in two ways. First, bandwidth is far lower (tens to a few hundred GB/s), so decode ceilings are a few tens of tokens per second for small models and quantization is not optional — this is why llama.cpp's integer kernels and Apple's unified-memory machines are the dominant local-inference story. Second, capacity is shared with the operating system and everything else, so a 4-bit 7B model occupying 4 GB may be the largest thing that fits. Edge NPUs in phones are built for int8 or lower and for fixed shapes; dynamic sequence lengths and large vocabularies stress them. Power and thermal limits mean sustained throughput is lower than the first ten seconds suggest — measure for minutes, not moments.
What is still unsettled
Vendors are shipping native 8-bit and 4-bit floating-point formats and hardware for sparse and mixture-of-experts models, which changes the effective bytes per parameter and the arithmetic intensity of the same model. Memory-bandwidth growth has lagged compute growth for a decade; whether stacked memory, compute-near-memory or very large on-chip SRAM designs change that is the question that will shape the next generation of inference hardware.
What to remember
- Ridge point = peak FLOPs ÷ bandwidth. Decode at small batch sits far below it; prefill sits far above it.
- Capacity decides whether a model fits on one device; bandwidth decides interactive decode speed; FLOPs decide prefill and large-batch throughput; interconnect decides the cost of sharding.
- FlashAttention is faster because it avoids HBM round-trips, not because it does less maths — an exact algorithm with a better memory plan.
- On CPUs and edge devices bandwidth and capacity shrink first; quantization, fixed shapes and thermal limits dominate the design.
Curated Materials
2.1hThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- GPU decoder keeps pace with a superconducting qubit clock on a continuous stream, with NVIDIA NVQLink interconnectAlice & Bob ·
- DeepSeek Opens Source Production-Level Ascend Inference Code36Kr ·
- NVIDIA and Cerebras Partner to Accelerate AI Agent Inference with Two-Stage Compute Architecture36Kr ·
Test your knowledge
5 questions in 100 seconds, on a page of its own. Read everything above first.
Test your knowledge →Module Mission
35–45 minPick three devices you can find public spec sheets for (for example one data-centre GPU, one consumer GPU and the CPU in your own laptop). For each, write down peak dense 16-bit FLOPs, memory capacity and memory bandwidth, then compute the arithmetic intensity (FLOPs per byte) at which it switches from memory-bound to compute-bound. Place single-request decode and a 64-request batched decode of a 7B model on each roofline and state, per device, which one is the bottleneck and whether the model fits in memory at 16-bit and at 4-bit.
Loading your work…