Google TPU architecture and systolic arrays
WHY does the TPU exist?
The WHY: Consider a fully-connected layer . To compute it, you must do many multiply-accumulates. On a CPU each MAC involves:
- fetch weight from register/cache,
- fetch activation,
- multiply, add to accumulator,
- write accumulator back.
The arithmetic is cheap; the data movement dominates energy and time. This is the memory wall. The fix: build hardware where a value, once loaded, is reused maximally before it leaves.
WHAT is a systolic array?
Key properties (WHAT to remember):
- Local wiring only → short wires → fast clock, low energy.
- Massive reuse → each operand read from memory once, used by a whole row/column.
- No instruction fetch per op → the dataflow is the program.

HOW does it compute a matrix multiply? (Derivation from scratch)
We want where is and is . Element:
Step 1 — map the sum onto a grid. Put PE in charge of computing . It must accumulate products. So each PE needs an internal accumulator:
Why this step? Each output needs its own running sum, so accumulation must be local to the cell.
Step 2 — deliver operands without global memory. In a weight-stationary array (what the TPU uses), preload weights into the cells (weight stays put). Then stream activations horizontally left→right, and stream partial sums vertically top→bottom.
At each clock a cell does:
Why this step? means the activation is passed along to the next cell — that's the one-read-many-uses trick.
Step 3 — skew the input (staggering). Because it takes cell some cycles for data to reach it, inputs are fed diagonally staggered (each row delayed by one clock). This keeps every cell busy on the right operands at the right time.
Step 4 — count the cost. A naïve implementation of an multiply reads operands from memory. The systolic array reads each of the input values once and does MACs inside — so the arithmetic intensity is:
Why this matters? Higher arithmetic intensity = fewer memory accesses per compute = you break through the memory wall. For a array that's ~128 MACs per byte fetched.
The full TPU block diagram (WHAT sits around the array)
- Matrix Multiply Unit (MXU) — the 256×256 systolic array. The workhorse.
- Weight FIFO — feeds weights from off-chip DRAM into the array.
- Unified Buffer (UB) — large (24 MB) on-chip SRAM holding activations; feeds the array and stores results. Keeps activations on-chip → avoids DRAM round-trips.
- Accumulators — collect the column partial sums coming out the bottom.
- Activation unit — applies ReLU / pooling etc. after the multiply.
- No cache, no branch predictor, no out-of-order — deliberately simple; all die area goes to arithmetic. This is the domain-specific bet.
Worked examples
Common mistakes (Steel-manned)
Flashcards
What does "systolic" refer to in systolic array?
What is the core computational unit in a systolic array?
Why does a systolic array beat a CPU for matmul?
What is the peak throughput of an N×N MAC array at clock f?
What is TPUv1's array size and rough throughput?
Was TPUv1 used for training or inference?
In a weight-stationary array, what stays put and what streams?
What is arithmetic intensity of an N×N systolic multiply?
Why do systolic arrays favor large batches?
What is the Unified Buffer in the TPU?
Name three CPU features the TPU deliberately omits.
The per-cell update equation in a weight-stationary PE?
Recall Feynman: explain it to a 12-year-old
Imagine a bucket-brigade line of kids putting out a fire. Each kid holds a fixed job (a weight). A bucket (a number) passes down the line; every kid pours a splash and adds it up, then hands the bucket to the next kid. Nobody runs back to the well for every splash — the bucket just keeps moving forward, and lots of kids work on it at once. That's a systolic array: numbers flow through a grid of little adders so you get tons of math done while only fetching each number once. The TPU is a huge grid of these little helpers built just for the math that AI needs.
Connections
- GPU architecture and SIMT execution — the alternative: temporal parallelism + caches vs. TPU's spatial dataflow.
- Memory wall and arithmetic intensity — the roofline reason TPUs exist.
- Matrix multiplication algorithms — the operation being accelerated.
- ASIC vs FPGA vs general-purpose processors — TPU as a domain-specific ASIC.
- Dataflow architectures — systolic arrays are a classic dataflow design (Kung & Leiserson, 1978).
- Quantization and 8-bit inference — why TPUv1 uses INT8 MACs.
- Roofline model — visualizing when you're compute- vs memory-bound.
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho, neural network ka zyada time matrix multiply karne me jata hai — bas bahut saare "multiply karo aur jodo" (MAC) operations. Normal CPU/GPU har MAC ke liye memory se number laata hai, multiply karta hai, wapas likhta hai — ye baar-baar memory se data laana hi asli bottleneck hai, jise hum memory wall kehte hain. Compute sasta hai, data laana mehnga.
Systolic array is problem ka jugaadu solution hai. Socho ek grid banaya jisme har chhota cell sirf ek MAC karta hai, aur cells sirf apne paas wale (neighbour) se juda hai. Ab data grid me se beh kar guzarta hai — jaise dil se khoon pump hota hai (isliye naam "systolic"). Ek number ek baar memory se aata hai aur poori row/column me use ho jaata hai, baar-baar memory jaane ki zaroorat nahi. Isse har byte ka reuse factor lagbhag ho jaata hai (256×256 array me 256 guna!).
TPU basically ek bada systolic array (256×256) hai jiske around memory (Unified Buffer) aur thoda control logic laga hai. Ek important baat: original TPUv1 sirf inference ke liye tha (8-bit integer) — training baad ke generations, yaani TPU v2 aur aage se shuru hui, jo bfloat16 floating point use karte hain. Iski peak power FLOP/s hoti hai — matlab parallelism spatial hai, cells ki square ke hisaab se scale karti hai. Ek cheez yaad rakho: array me pehle data ko poore grid me faelne me clock lagte hain (pipeline fill), isliye TPU chhote kaam me efficient nahi — bade batches pe magic dikhata hai. TPU me na cache hai, na branch predictor — saari jagah arithmetic ko de di, kyunki ye ek domain-specific ASIC hai, sirf AI ki math ke liye banaya gaya.