Skip to content
BIASED

Domain-specific architectures and the TPU

Why specialize, five Hennessy–Patterson guidelines, TPU v1’s 256×256 MACs, systolic arrays, roofline and bfloat16, TPUs vs GPUs.

Why specialize

Free clock speedups ended; Amdahl limits multicore. Large wins now come from hardware for one big, regular domain.

Hennessy–Patterson: dedicated memories, transistors into arithmetic and memory, simplest fitting parallelism, narrowest sufficient types, a domain language — not a full OoO general core.

Worked example. The peak is 65,536 MACs×2×700×106 s−1=91.75≈9265{,}536 MACs × 2 × 700 × 10^6\ s^{-1} = 91.75 ≈ 9265,536 MACs×2×700×106 s−1=91.75≈92 TOPS. One weight tile takes 65,536 B/(34×109 B/s)=1.9365{,}536\ B / (34 × 10^9\ B/s) = 1.9365,536 B/(34×109 B/s)=1.93 µs to fetch, which is 1,349 cycles at 700 MHz. A MatrixMultiply with a batch of M=200 rows keeps the array busy for only 200 cycles. Unless a tile is reused for at least about 1,350 rows, the array waits for weights. The paper’s choice of 4,096 accumulators comes from the same number: about 1,350 rows rounded up to 2,048, doubled so that one half can be filled while the other is read (Jouppi et al., 2017, §2).

The previous note took one matrix product on one core of a general-purpose processor from 0.55 to 14.6 GFLOP/s by rewriting loops, and a vendor library reached 255 GFLOP/s. Every step fitted the computation better to hardware designed to run any program. This note goes the other way: hardware designed for one kind of program. It covers why such domain-specific architectures (DSAs) became attractive, the guidelines for designing one, and the best documented example, Google’s first Tensor Processing Unit, whose heart is a grid of 65,536 multipliers that does nothing but matrix products. This note is a branch: the rest of the course does not depend on it.

TPU v1

TPU v1: PCIe coprocessor, 256×256 8-bit MAC array (92 TOPS @ 700 MHz), 24 MiB Unified Buffer, 4 MiB float32 accumulators, weights from 8 GiB DDR3 @ 34 GB/s.

Weight-stationary systolic: weights sit in cells; activations move right, partial sums down; y_{mn}=\sum_k x_{mk}w_{kn}. One buffer read feeds many MACs; an MMM-row alone needs M+K+N-2 cycles on a K× N array.

The first TPU, from Jouppi et al. (2017): 256 x 256 MACs at 700 MHz, weights from DDR3 at 34 GB/s macs, clock, bw = 256 * 256, 700e6, 34e9 print(macs, round(2 * macs * clock / 1e12, 2), round(macs * clock / bw)) # peak TOPS (2 ops per MAC); ridge in MACs per weight byte # 65536 91.75 1349 tile = 256 * 256 # one tile of 8-bit weights, bytes print(tile // 1024, round(tile / bw * 1e6, 2), round(tile / bw * clock)) # KiB, microseconds and cycles to fetch it # 64 1.93 1349

The TPU is a coprocessor on the PCIe bus of a server, like a GPU, but it fetches no instructions of its own: the host sends them. It has about a dozen instructions in the CISC style, each of which can run for thousands of cycles, and a four-stage pipeline that overlaps them so that the matrix unit is kept busy (Jouppi et al., 2017, §2). The die is made in a 28 nm process, runs at 700 MHz, and has a thermal design power of 75 W; it drew 40 W when busy (Table 2).

Roofline, later TPUs, GPUs

Roofline ridge ≈ 1350 MAC/weight-byte: MLPs/LSTMs memory-bound, CNNs compute-bound. Later TPUs: training, bfloat16, 128×128, HBM, huge pods. GPUs reach similar peaks with tensor cores inside a more general chip. Why specialize. Free clock speedups ended; Amdahl limits multicore. Large wins now come from hardware for one big, regular domain — neural-net inference/training being the headline. Hennessy–Patterson guidelines: dedicated memories close to compute, transistors into arithmetic and memory not OoO control, the simplest parallelism that fits (systolic, SIMD), the narrowest types that suffice (int8, bf16), and a domain language/compiler — not a second general-purpose core. TPU v1: PCIe coprocessor, 256×256 8-bit MAC array (92 TOPS @ 700 MHz), 24 MiB Unified Buffer, 4 MiB float32 accumulators, weights from 8 GiB DDR3 @ 34 GB/s. Weight-stationary systolic: weights sit in cells; activations move right, partials down. Roofline ridge ≈ 1350 MAC/weight-byte: MLPs/LSTMs memory-bound, CNNs compute-bound on that machine. Later TPUs add training, bfloat16, 128×128 arrays, HBM, pods of thousands of chips. GPUs reach similar peaks with tensor cores inside a more flexible SIMT machine — pick DSA when the graph is stable and energy/perf matter; pick GPU when the model and batching still churn. Systolic timing: on a K× N weight-stationary array, filling and draining pipelines means an MMM-row takes about M+K+N-2 cycles of useful fire plus fill — the note’s figure walks activations across and partial sums down. Quantization to int8 multiplies peak throughput but demands calibration so accuracy does not fall off a cliff; bf16 keeps float range with a 7-bit fraction, matching training’s need for wide exponents. Energy, not only TOPS, drives DSA adoption: moving a byte from HBM can cost orders of magnitude more energy than an 8-bit MAC. That is why the Unified Buffer and on-chip accumulators matter as much as the array dimensions. When the model changes weekly, the GPU’s generality wins; when a recommendation model is fixed and queried at huge QPS, a TPU pod’s efficiency wins. Next: What an operating system does — the program that turns one machine into many. Read_Weights fetches a tile of 256×256256 × 256256×256 8-bit weights, 64 KiB, from an off-chip 8 GiB DDR3 Weight Memory at 34 GB/s into the Weight FIFO, four tiles deep. Inside the matrix unit, a tile in use and the next one are held at once, so that loading a new tile, which takes 256 cycles to shift in, overlaps with work on the current one. The fill and the drain cost K+N−2K + N - 2K+N−2 cycles. For one operation on the 256×256256 × 256256×256 array they are 510 cycles, against MMM cycles of steady work: a batch of M=200 alone would keep the array busy

Check your understanding

The same questions as in Pulse. Answers are shared between modes.

Full notes

Answers are saved on the server and tied to this browser until you sign in.