Before you start: words you need#
Lesson 2.g explained why a GPU beats a CPU at inference. This lesson opens the box. These words appear on every page of Modules 4–6:
| Word | Plain meaning |
|---|---|
| SM (streaming multiprocessor) | One of the GPU’s ~100–160 independent processors. Think “a GPU is a few hundred small CPUs glued together”. |
| CUDA core | One arithmetic lane inside an SM — a calculator that does one multiply-add per clock. Not a CPU core; it cannot run a program on its own. |
| Tensor core | A special unit inside each SM that multiplies small matrices in one step. Almost all AI arithmetic runs here. |
| Thread | One instance of your program working on one piece of data. A GPU runs tens of thousands at once. |
| Warp | A group of 32 threads that the hardware runs in lockstep, like 32 people following one instructor. |
| HBM (high-bandwidth memory) | The GPU’s main memory: stacked DRAM chips beside the processor. Holds the model weights and the KV cache. |
| Bandwidth | How many bytes per second memory can deliver. For LLM decode, the most important number on the spec sheet. |
| L2 cache / shared memory / registers | Smaller, faster memories closer to the arithmetic. Lesson 4.d covers all of them. |
1. What is it?#
A GPU is a chip organised around one idea: do the same operation on enormous amounts of data, and spend the transistors on arithmetic units and memory bandwidth rather than on making one instruction stream fast.
Here is an NVIDIA H100, the most widely deployed AI GPU of 2023–2025 and still common in 2026, drawn from the outside in:
H100 SXM:
┌─────────────────────────────────────────────────────────────┐
│ GPC 0 GPC 1 ... GPC 7 │
│ ┌────────┐ ┌────────┐ ┌────────┐ │
│ │ 9 TPCs │ │ 9 TPCs │ │ 9 TPCs │ │
│ │ = SMs │ │ │ │ │ │
│ └────────┘ └────────┘ └────────┘ │
│ │
│ 132 SMs enabled · 16,896 FP32 lanes · 528 tensor cores │
├─────────────────────────────────────────────────────────────┤
│ L2 cache 50 MB │
├─────────────────────────────────────────────────────────────┤
│ HBM3 80 GB @ 3.35 TB/s (5 stacks) │
└─────────────────────────────────────────────────────────────┘
↕ NVLink 900 GB/s to other GPUs ↕ PCIe Gen5 x16 ~64 GB/s to the CPURead it bottom-up, because that is the order that matters for inference:
- HBM — 80 GB is how much model and KV cache fits; 3.35 TB/s is how fast it can be read.
- L2 cache — a 50 MB staging area shared by every SM.
- SMs — 132 independent processors, grouped for wiring purposes into GPCs (graphics processing clusters) and TPCs (texture processing clusters, two SMs each). The grouping names are historical; you will rarely need them.
- Links — NVLink to neighbouring GPUs (Module 9), PCIe to the host CPU (9.b).
For LLM serving, the two numbers that matter most sit on the bottom row: HBM capacity (what fits) and HBM bandwidth (how fast decode runs). Section 7 ranks the rest.
Diagram — a GPU from the outside in#
flowchart TB
CPU["Host CPU + system RAM"] -->|"PCIe"| GPU
subgraph GPU["GPU"]
direction TB
subgraph SMS["Streaming multiprocessors — 100 to 160 of them"]
direction LR
SM1["SM<br/>warp schedulers<br/>CUDA cores<br/>tensor cores<br/>registers<br/>shared memory / L1"]
SM2["SM"]
SM3["SM ..."]
end
L2["L2 cache — tens of MB, shared by all SMs"]
HBM[("HBM — tens to hundreds of GB at several TB/s")]
SMS --> L2 --> HBM
end
GPU <-->|"NVLink"| PEER["Other GPUs"]
class SM1,SM2,SM3 compute
class L2,HBM memory
class CPU,PEER neutral2. Why does it exist?#
GPUs were built for graphics: colour two million pixels, each independently, with the same small program (a “shader”), sixty times a second. That workload has perfect data parallelism, almost no branching, and huge memory traffic. A chip designed for it looks nothing like a CPU.
Neural networks turned out to have exactly the same shape — the same multiply-and-add applied to millions of numbers — and lesson 2.h tells how GPUs went from games to AI.
The design bet, stated plainly: give up fast single-thread performance, branch prediction and deep caches; spend the silicon on arithmetic units and memory bandwidth instead. For inference, that bet pays roughly 10x in memory bandwidth and 100x or more in matrix throughput over a server CPU.
3. Simple analogy#
A CPU is eight master craftsmen; a GPU is an assembly line with sixteen thousand stations.
Each craftsman has a full workshop and can build anything, quickly, one item at a time. Each station on the assembly line does one simple step. Any single item takes longer to go down the line, but the line turns out thousands of items in the time a craftsman makes one — as long as every station has work. Keeping every station busy is the theme of Modules 4–6: it is why batch size (2.d) and occupancy (6.c) matter so much.
4. Tiny example#
Read your own GPU’s specification with PyTorch:
import torch
p = torch.cuda.get_device_properties(0)
print(f"name {p.name}")
print(f"compute capability {p.major}.{p.minor}") # 9.0 = Hopper, 10.0 = Blackwell B200
print(f"SMs {p.multi_processor_count}")
print(f"total memory {p.total_memory/1e9:.1f} GB")
print(f"max threads/SM {p.max_threads_per_multi_processor}")
print(f"shared mem/block {p.shared_memory_per_block/1024:.0f} KB")
print(f"warp size {p.warp_size}")Compute capability is NVIDIA’s version number for the instruction set: 8.0 is A100 (Ampere), 9.0 is H100/H200 (Hopper), 10.0 is B200/GB200 and 10.3 is B300/GB300 (Blackwell, data-center parts), 12.x is Blackwell for workstations and PCs. Compilers and kernels are built per compute capability, which is why an old kernel library can refuse to run on a new GPU.
Now work out a peak from first principles. Each FP32 lane does one fused multiply-add (FMA) per clock, and an FMA counts as 2 FLOPs:
FP32 peak = SMs × FP32 lanes per SM × 2 FLOPs × clock
H100 SXM: 132 × 128 × 2 × 1.98 GHz (boost) ≈ 67 TFLOP/s (NVIDIA's datasheet: 67)And measure the bandwidth you actually get:
import torch, time
n = 2_000_000_000 // 4 # 2 GB of float32
a = torch.empty(n, device='cuda', dtype=torch.float32)
b = torch.empty_like(a)
for _ in range(3): b.copy_(a) # warm up
torch.cuda.synchronize(); t0 = time.perf_counter()
for _ in range(20): b.copy_(a)
torch.cuda.synchronize()
dt = (time.perf_counter() - t0) / 20
print(f"{2*n*4/dt/1e9:.0f} GB/s") # each copy reads and writes every byteOn an H100 SXM this prints around 2,800–3,000 GB/s: about 85–90% of the 3.35 TB/s on the
datasheet, which is normal. Write both numbers in your numbers.md. You will use them in
every estimate from here on.
5. Technical explanation#
Inside an SM (Hopper)#
┌────────────────────────── SM ──────────────────────────┐
│ L1 instruction cache │
│ ┌──────────────┬──────────────┬────────────┬────────┐ │
│ │ Partition 0 │ Partition 1 │ Partition 2│ Part. 3│ │
│ │ warp sched. │ warp sched. │ ... │ ... │ │
│ │ 32 FP32 lanes│ 32 FP32 │ │ │ │
│ │ 16 INT32 │ │ │ │ │
│ │ 1 tensor core│ 1 TC │ 1 TC │ 1 TC │ │
│ │ 64 KB regs │ 64 KB │ 64 KB │ 64 KB │ │
│ │ 8 load/store │ │ │ │ │
│ │ 4 SFU │ │ │ │ │
│ └──────────────┴──────────────┴────────────┴────────┘ │
│ 256 KB combined L1 / shared memory (configurable split)│
│ TMA — Tensor Memory Accelerator (Hopper): async copies │
└─────────────────────────────────────────────────────────┘What each part does:
- 4 partitions, each with a warp scheduler. Every clock, each scheduler picks one ready warp and issues one instruction for its 32 threads.
- Up to 64 warps (2,048 threads) resident per SM. Far more than can run at once — on purpose. When one warp waits hundreds of cycles for memory, the scheduler switches to another at no cost, because every warp’s state already lives in the register file. This is latency hiding, the GPU’s answer to the CPU’s caches (4.c explains it fully).
- 256 KB of registers per SM, split among the resident threads. A kernel that uses more registers per thread leaves room for fewer warps (6.c).
- 256 KB of L1 / shared memory, split by the program: shared memory is a scratchpad the programmer controls; L1 is an automatic cache (4.d).
- 4 tensor cores, one per partition: these do the matrix multiplications (4.f).
- SFUs (special function units) compute
exp,sin, reciprocal square root — needed for softmax and normalisation. - TMA copies whole tiles between HBM and shared memory in the background, so warps can compute while the next data arrives (6.e, 13.l).
What changed in Blackwell#
Blackwell (B200, B300 — lesson 7.c) keeps the same SM idea and changes three things that matter for kernels:
- Two dies act as one GPU. A B200 package holds two chips joined at 10 TB/s; software sees one device with 148 SMs and 192 GB of HBM3e at about 8 TB/s.
- Tensor memory (TMEM). Each SM gets 256 KB of dedicated memory beside the tensor cores to hold
matrix-multiply results, instead of using registers. A single thread can launch a large matrix
operation (
tcgen05.mma), and two SMs can cooperate on one. - 4-bit floating point (NVFP4, MXFP4) in the tensor cores (4.f, 13.g).
The consequence: kernels written for Hopper run on Blackwell but do not reach its speed until they are rewritten for these features. That is why engine release notes in 2025–2026 are full of “SM100 kernels” (SM100 = compute capability 10.0).
The generations at a glance#
| V100 (2017) | A100 (2020) | H100 (2022) | B200 (2024–25) | |
|---|---|---|---|---|
| SMs | 80 | 108 | 132 | 148 (two dies) |
| Memory | 32 GB HBM2 | 80 GB HBM2e | 80 GB HBM3 | 192 GB HBM3e |
| Bandwidth | 0.9 TB/s | 2.0 TB/s | 3.35 TB/s | ~8 TB/s |
| Dense FP16/BF16 tensor | 125 TF | 312 TF | 990 TF | ~2,250 TF |
| Dense FP8 | — | — | 1,979 TF | ~4,500 TF |
| NVLink per GPU | 300 GB/s | 600 GB/s | 900 GB/s | 1.8 TB/s |
| New for inference | tensor cores | BF16, sparsity, MIG | FP8, TMA, clusters | FP4, TMEM, two dies |
This table only shows the trend. Module 7 covers every current product — H200, B300, Rubin, AMD Instinct, TPU, Trainium — in detail, with sources.
The trend to remember: from V100 to B200, tensor FLOPs grew about 18x while bandwidth grew about 9x. Arithmetic keeps outrunning memory, so each generation makes more work memory-bound (2.f). That is why batching, quantization and caching become more important with every new GPU, not less. Rubin (2026) narrows the gap a little with HBM4 at ~22 TB/s (7.e).
MIG (Multi-Instance GPU)#
A100 and later can be split into up to seven isolated instances, each with its own SMs, L2 slice and memory. It matters for platforms that host many small models; 21.d covers MIG, MPS and time-slicing together.
What a GPU is bad at#
✗ Branchy code where neighbouring threads take different paths (warp divergence, 6.c)
✗ Pointer chasing and random memory access (6.b)
✗ Long chains where each step depends on the previous one
✗ Small amounts of work (launch overhead dominates) (5.d)
✗ Frequent back-and-forth with the CPU (9.b)
✗ Anything that needs one operation to finish very quicklyAll of these appear in an LLM stack: decode is a chain of dependent steps, tokenisation is branchy, sampling is small work. The parts of an inference server that stay on the CPU are exactly the parts on this list.
6. Under the hood#
Where the transistors go, roughly:
Server CPU: ~5% arithmetic, ~40% cache, ~30% control and prediction, ~25% I/O
GPU (H100): ~35% arithmetic (incl. tensor cores), ~25% memory system,
~15% register file, ~10% scheduling, ~15% I/OA single H100 has more register file (132 × 256 KB ≈ 33 MB) than a server CPU has L1 and L2 cache combined. It needs it: every one of up to 270,000 resident threads keeps its working state in registers so the scheduler can switch between warps in one clock.
7. Performance implications#
For LLM inference, rank the specs by how much they matter:
1. HBM bandwidth decode speed, directly (each token reads all weights + KV cache)
2. HBM capacity what fits; how much KV cache; how many users at once
3. Tensor FLOPs prefill speed; large-batch decode
4. Supported formats FP8 and FP4 halve or quarter the bytes per weight (4.f, 13.e, 13.g)
5. NVLink bandwidth multi-GPU scaling (Modules 9, 14)
6. L2 size modest; helps small working sets
7. Clock speed mostly irrelevant; it is a bandwidth gameChoose GPUs for LLM serving by bandwidth and capacity. An H200 has the same FLOPs as an H100 but 43% more bandwidth and 76% more memory: for inference it is clearly better, for training nearly the same.
8. Production implications#
- Know your fleet.
nvidia-smi -qandtorch.cuda.get_device_propertiestell you exactly what each node has. - Check power and clock limits. A GPU in a hot or power-capped chassis runs at lower clocks;
watch
clocks_event_reasonsinnvidia-smi -q -d PERFORMANCE(4.g). - Enable persistence mode (
nvidia-smi -pm 1) so the driver is not re-initialised on every process start. - Match the GPU to the work: bandwidth-heavy decode → H200, B200/B300; compute-heavy prefill or vision → any high-FLOP part; small models at low traffic → L4, L40S or MIG slices. Module 8 turns this into a method.
- Watch for Xid errors in
dmesg— hardware faults that show up as mysterious CUDA errors.
9. Common mistakes#
Choosing GPUs by TFLOPs for a decode-bound workload. Decode needs bandwidth.
Thinking a “CUDA core” is like a CPU core. It is one arithmetic lane of a 32-wide unit; 16,896 CUDA cores are 132 processors, not 16,896.
Ignoring capacity. A model that does not fit is not slow — it does not run.
Not checking for throttling. A power-capped GPU silently runs 10–20% slower.
Running old kernels on new GPUs and blaming the hardware. A Hopper-era kernel on a B200 can leave half the chip’s capability unused; check that your engine version has kernels for your compute capability.
10. Hands-on exercise#
A. Inventory. Run the property script and record everything in numbers.md. Compute the
theoretical FP32 peak from first principles and compare it with the datasheet.
B. Measure the two constants. Measure achieved HBM bandwidth (the copy benchmark) and achieved
BF16 tensor TFLOP/s (time torch.matmul on two 8192×8192 BF16 matrices: FLOPs = 2·n³). What
fraction of the datasheet do you reach for each?
C. Compare generations. For every GPU you can rent, tabulate bandwidth, capacity, BF16 FLOPs and $/hour. Compute $ per TB/s and $ per TFLOP. Which is the best value for decode? For prefill?
D. Throttling. Run a sustained heavy load and watch nvidia-smi -q -d PERFORMANCE. Can you
trigger a power cap? What happens to throughput?
E. MIG (if available). Partition a GPU and measure the bandwidth one 1g slice gets compared
with the whole GPU. Is it proportional?
11. Interview questions#
- Describe an SM and what it contains.
- Why does a GPU keep far more threads resident than it can execute at once?
- Why have workloads become more memory-bound with each GPU generation, and what does that mean for inference?
- Which GPU spec matters most for decode? For prefill? Why?
- Name five things GPUs are bad at and where each appears in an LLM serving stack.
- What does compute capability mean, and why does it matter when you upgrade from H100 to B200?
12. Further reading#
Checked on 11 November 2026.
- [FUNDAMENTAL] NVIDIA Hopper architecture in depth and the Blackwell architecture technical brief
- [FUNDAMENTAL] Kirk, Hwu & El Hajj, Programming Massively Parallel Processors (4th ed.), chapters 1–4
- [REFERENCE] CUDA C++ Programming Guide — Hardware Implementation, and Compute Capabilities
- [REFERENCE] NVIDIA H100 datasheet
- [ESTABLISHED] Jia et al., “Dissecting the NVIDIA Volta GPU Architecture via Microbenchmarking” — the method still applies to every newer GPU