L1 Beginner · Module 2: Why GPUs: hardware first principles

2.7Thought experiment: designing an LLM processor

Forget GPUs for a moment and design a chip just for LLM inference, using only what this module taught. You will rediscover HBM, batching, quantization, SRAM-only accelerators and disaggregated serving, and see why each one is a trade-off.

~20 min

By the end you will be able to

  • ✓Turn a serving target into bandwidth, capacity and compute requirements
  • ✓Evaluate design options for decode by the bytes they move
  • ✓Explain the trade-offs behind GPUs, SRAM-based chips and wafer-scale chips
  • ✓See why prefill and decode want different hardware

This chapter is a design exercise. You are building a chip to serve Llama-3-70B. Use pencil and paper; every number follows from the chapters you have already read.

The requirements

  • Model: 70 B parameters. In BF16 that is 140 GB of weights.
  • Per-user speed: 50 tokens/s, so a decode step must finish in 20 ms.
  • Traffic: many users at once. The more you serve per chip, the lower the cost per token.
  • Context: up to 8K tokens per user. With GQA (80 layers, 8 KV heads of 128), the KV cache is about 320 KB per token, or 2.5 GB per full-length user.

Step 1: bandwidth

Every decode step must read all the weights (2.6):

B  ≥  140 GB20 ms=7 TB/sB \;\geq\; \frac{140\ \text{GB}}{20\ \text{ms}} = 7\ \text{TB/s}

That is about two H100s’ worth of HBM, for one user. Compute is not the issue: 140 GFLOP per token in 20 ms is 7 TFLOP/s, under 1% of an H100’s peak.

Step 2: the design options

Option A: more HBM bandwidth. Put more HBM stacks around a big die. A B200-class chip has about 8 TB/s and 192 GB, which just meets the target for a single user. This is the GPU path, and it is limited by HBM cost and packaging.

Option B: reuse each byte across users (batching). Serve 64 users in the same step. The weights are read once and used 64 times, so bandwidth per token falls 64×. The catch: each user brings their own KV cache, which is read every step and cannot be shared, and the batch has to fit in memory alongside the weights. This is the whole of Module 10.

Option C: fewer bytes per weight (quantization). At 4 bits, the weights are 35 GB and the bandwidth need falls to 1.75 TB/s. Quality has to be checked, and the arithmetic needs to unpack the low-bit formats efficiently (Module 12).

Option D: all on-chip SRAM. Skip HBM and keep everything in on-chip SRAM, which is far faster. But SRAM is about a hundred times less dense than DRAM. A chip with 230 MB of SRAM (the size used by Groq’s LPU) needs about 600 chips to hold 140 GB. A wafer-scale chip (Cerebras WSE-3, 44 GB of SRAM on a single wafer) needs several wafers. Very fast per user, but expensive in silicon per model, and the chips need fast links between them.

Option E: split the model across chips. Spread each layer over NN chips (tensor parallelism). Each chip reads 1/N1/N of the weights, and the bandwidths add up. The cost is communication between chips on every layer (14.2).

OptionWhat it changesMain cost
A. More HBMraises BBHBM price, packaging, power
B. Batchingdivides weight bytes by batch sizeKV cache memory, per-user latency
C. Quantizationdivides weight bytes by 2–4×accuracy risk, kernel complexity
D. SRAM onlyraises BB enormouslycapacity: hundreds of chips per model
E. Multi-chipmultiplies BB by chip countinterconnect, communication per layer

Real deployments combine them: GPUs with HBM (A), large batches (B), FP8 or INT4 weights (C), and 4–8-way tensor parallelism (E).

Step 3: don’t forget prefill

Prefill processes thousands of prompt tokens at once. Its arithmetic intensity is in the thousands, so it is compute-bound (3.4). A chip designed purely for decode bandwidth (Option D, say) can be weak at prefill, and a chip designed for prefill FLOPs wastes them on decode. That mismatch is why large deployments run prefill and decode on separate pools of hardware and transfer the KV cache between them (15.1).

Sources

repo · BGEBEFORE-GPU-ENGINEERINGBEFORE-GPU-ENGINEERINGPhase 1 ends with this thought experiment: designing a processor for LLMs from first principles.
book · FREGLYAI Systems Performance EngineeringChris FreglyGPU architecture chapters: how real accelerators trade compute, memory and interconnect.

Check your understanding

0 / 4 answered
  1. 1.A 140 GB model must produce one token every 20 ms for a single user. What bandwidth does that need?

  2. 2.Why does batching reduce the bandwidth needed per generated token?

  3. 3.What is the main drawback of an SRAM-only inference chip?

  4. 4.Why do large deployments sometimes run prefill and decode on separate hardware?