The TPU Chip & the Systolic Array
How a TPU actually computes a matrix multiply — a systolic array of multiply-accumulate cells that reads each input once and reuses it, trading memory traffic for raw throughput.
100Foundational TPU architecture & provisioningLesson 3 of 8ShowHide
Chapter 1 of 2 in TPU Training Infrastructure
- The TPU Chip & the Systolic ArrayYou're here
Prerequisites: Why TPUs? Cloud TPUs & the TPU VM
The one-line summary
A TPU is, at its core, a machine for one operation: matrix multiply. A modern transformer spends the vast majority of its FLOPs in matmuls — attention and the MLP blocks — so Google built silicon that does nothing else, very fast. The trick that makes it fast isn't a faster multiplier. It's a layout — the — that reads each input from memory once and reuses it across thousands of multipliers.
The problem: a CPU re-fetches everything
On a general-purpose CPU (the von Neumann model), every arithmetic step is in principle a round trip: fetch the operands from memory, multiply, write the result back. Caches soften this, but they only delay the wall — the multiplier is fast; the memory traffic is the bottleneck. For a 3×3 matmul — 27 , two operand reads each — that's about 54 memory reads. Scale to a 4096×4096 matmul and the chip spends almost all its time waiting on memory, not computing.
The idea: pump once, reuse (why "systolic")
The name comes from biology: systole is the heart's contraction. Data is pumped through a grid of cells in rhythmic beats. You load the weights into the cells once (a layout); then activations stream in from one edge and march cell to cell. Each cell does one MAC per beat and hands its data to the neighbour — so a single value fetched from memory feeds a whole row of multipliers before it's discarded.
See it move
The simulation has two views. Start on Why: CPU vs TPU and run the comparison: both do the same 27 multiply-accumulates, but watch the memory-read counters diverge — the CPU re-fetches operands ~54 times where the array reads each input once.
Then switch to How: the array. Weights sit in the cells; activations enter from the left through the incoming queue and flow right; partial sums flow down. The inputs enter staggered — each row a beat behind the one above — so every activation meets the right partial sum in step; that's why the computing cells form a moving diagonal wavefront. Pump the clock and watch utilization climb as the wavefront fills the grid:
By the middle cycles, most cells are computing at once — all fed by data that was read from memory a single time. That concurrency × reuse is the entire source of a TPU's throughput.
CPU vs systolic, in numbers
This is the MXU inside the TensorCore
In a real chip, that array is the (Matrix Multiply Unit) — classically a 128×128 grid of MACs (16,384 multipliers) that computes one 128×128 matmul tile per pass — sitting inside each (a v5p chip carries several MXUs, plus a vector and scalar unit for the non-matmul work). Inputs are multiplied in bf16 and accumulated in fp32. The array is fed from : a TPU v5p chip has ~95 GB of HBM at roughly 2.8 TB/s and delivers about 459 bf16 TFLOP/s — a number you only reach if the MXU stays fed.
Why bf16, and arithmetic intensity
Keeping the MXU fed is a bandwidth game. The metric is — FLOPs per byte read from memory. Divide v5p's ~459 TFLOP/s by its ~2.8 TB/s and you get a ridge point of roughly 165 FLOP/byte: feed the MXU fewer FLOPs per byte than that and it sits idle waiting on HBM; more, and it runs compute-bound near peak. The systolic array's reuse is what pushes you past the ridge. Two levers help:
- halves the bytes moved versus fp32 while keeping fp32's exponent range — so twice as many numbers fit through the same HBM bandwidth, and the MXU runs at its bf16 rate.
- Batching reuses the same stationary weights across many activations, so each weight read pays off over more MACs.
- Lower precision goes further still — TPU 8t's native FP4 needs a quarter of bf16's bytes per parameter (half of FP8's). It's the extreme of this lever: fewer bytes moved per FLOP, so memory-bound work speeds up.
This is the mental model behind everything later in the path: the array is only worth its TFLOPs when you keep it busy. The utilization metric (MFU) you'll chase in L300 is just "how full was this array, really?"
Why bf16, not fp32 — range over precision
Halving the bytes only helps if the numbers still come out right. The trick is which bits you drop. A float is sign + exponent (range) + mantissa (precision). keeps fp32's full 8-bit exponent — so the exact same dynamic range — and throws away mantissa bits instead. The alternative 16-bit format, fp16, does the opposite: more mantissa, but a 5-bit exponent that overflows and underflows at the extremes.
That matters because ML training spans a huge range — tiny gradients near 1e-7
up to activations near 1e5 — and needs the range far more than the last digits
of precision. Drag the value and watch fp16 break where bf16 holds:
So bf16 is the sweet spot: fp32's range, half the memory (→ 2× the arithmetic intensity), and the small rounding error averages out across millions of updates. And because the MXU multiplies in bf16 but accumulates in fp32, the running sums stay accurate — you get the memory win without the error piling up.
The padding trap
There's a catch that can turn a compute-bound job into a mysterious OOM: the MXU works in fixed tiles (128×128, or 256×256 on v6e/v7), and the memory system prefers multiples of 8 and 128. Any dimension that doesn't line up is silently padded with zeros by the XLA compiler — and those zeros are real: they burn compute and on-chip memory for nothing.
Try it. Raise the batch to cross the ridge into compute-bound, then mis-size the
feature dimension (e.g. 4096 → 4097, or pick the 256-tile chip) and watch the
padding waste — and the memory footprint — spike:
The takeaway: shapes are not free. Align batch and feature dimensions to the MXU tile and the memory lanes, or you'll pay for zeros — sometimes with an out-of-memory crash on a job you were certain was compute-bound.
Why it matters for ML
Transformers are mostly matmul, so the MXU is where your model's compute actually happens — and where your money goes. As an infrastructure engineer your job is to keep that array fed: pick bf16, size batches and shapes so the matmuls are big and weights are reused, and avoid stalls that leave the wavefront half-empty. Every higher level of this path — sharding, pipelines, collectives — exists to keep more of these arrays busy at once.
Put it together
Watch utilization peak
In the simulation above, pump the clock and note the cycle where utilization is highest. Those cells are all computing on data read from memory once.
Contrast with the CPU
Re-read the comparison above. Say in one sentence why the CPU needs ~54 memory reads where the array needs ~18 — it's about reuse, not multiplier speed.
Reason about keeping it fed
Explain how bf16 and larger batches raise arithmetic intensity, and why that keeps the MXU compute-bound rather than stalling on HBM.
Review
Systolic array
Check yourself
Why is a general-purpose CPU slow at large matrix multiplies compared with a systolic array?
Go deeper
JAX quickstart — run your first matmul →
Run a matmul in JAX (on a TPU VM if you have one), then dump the HLO to see XLA lower it onto the MXU.
Work the bandwidth math
For a 128×128 systolic MXU fed from HBM at ~2.8 TB/s, explain why a CPU's fetch-per-op model is memory-bound while the array is compute-bound. Define arithmetic intensity, then show how switching fp32 → bf16 and increasing batch size each change where the bottleneck sits.