Apex › Hardware

How a TPU multiplies matrices (systolic array)

The matrix-multiply engine inside Google’s TPU: a grid of tiny multiply-accumulate cells. Matrix A streams in from the left and B from the top, each row and column staggered by a cycle; every cell multiplies its two inputs, adds to a running sum, and passes them on. The stagger makes the right operands meet at the right cell at the right moment, so a diagonal wavefront sweeps the grid and every cell ends holding one entry of C = A·B — each input read from memory once. Verified in node: bit-exact against the triple-loop matmul (400 matmuls, 0 mismatch), finishing in m+n+k−2 cycles. Step the clock and watch the wavefront.

More in Hardware