AI State of the Art
MLOps/Infrastructure & Compute/32 min
Section 182

TPU (Google): Architecture and Use Cases

Listen as a podcast →

The question you are actually asking: TPU or GPU?

Before the architecture, let's settle the practical question. You have a large transformer to train and you are wondering: TPU or NVIDIA GPU?

Short answer: on Google Cloud, for a large and regular training run, TPUs are a serious and often advantageous option. Anywhere else, or for exploratory work, the GPU remains the default, and the main reason is not hardware, it is software.

To see why, you need to know what a TPU is.

Who built the TPU, and why

Google built the TPU (Tensor Processing Unit) quietly, in-house. The paper that revealed it publicly dates from 2017 and states that the chip had been deployed in Google's data centres since 2015, running search, translation and speech recognition.

The founding paper, and its numbers

The 2017 paper describes the first-generation TPU and reports gains that made a lot of noise: on the workloads it targeted, the chip was on average 15 to 30 times faster than the GPUs and CPUs of its day, with 30 to 80 times better energy efficiency measured in operations per watt.

Two reading cautions. Those factors compare the TPU v1 against processors from 2015, not against today's GPUs: they describe a historical gap, not the current state of the market. And they concern inference on the networks Google was then running, not training, which the TPU v1 could not do at all.

In-Datacenter Performance Analysis of a Tensor Processing Unit (Jouppi et al., 2017)

Why the project existed

GPUs were originally designed for graphics, drawing pixels in video games. That technology was repurposed for machine learning. It is like using a Swiss army knife to cut bread every day: it works, but a bread knife would do better.

Google asked what a chip built solely for neural networks would look like. No graphics pipeline, no rasterisation, no texturing: matrix arithmetic and nothing else.

Annotated diagram of the abstract layout of a TPU TensorCore. Inside a frame, a Scalar Unit connected to a small Smem memory; below it a Vector Unit (VPU) connected to a Vector Memory (Vmem); below that a large Matrix Multiply Unit (MXU) block spanning the full width. To the right of the frame, a tall High Bandwidth Memory (HBM) column exchanges data with the Vector Memory through a wide red double-headed arrow. Annotations state that the Scalar Unit acts as a CPU dispatching instructions to the VPU and MXU, that the VPU handles element-wise operations such as activations and loads data into the MXU, that the MXU performs matrix multiplications and determines the chip's FLOP/s, that HBM stores weights, activations and optimizer states, and that HBM bandwidth determines exchange speed.
The layout of a TPU core. Almost all the useful area goes to the MXU, the multiplication array: a small scalar unit dispatches instructions, a vector unit handles element-wise operations, and that is it. No block dedicated to graphics, unlike a GPU.Source : How to Scale Your Model, Google DeepMind, How to Think About TPUs chapter

Three abbreviations recur on that diagram and throughout the TPU documentation:

  • the MXU (Matrix Multiply Unit): the large block at the bottom, which performs matrix products and single-handedly determines the chip's advertised TFLOPS;
  • the VPU (Vector Processing Unit): it handles element-wise operations (activations, normalizations) and feeds the MXU;
  • the HBM (High Bandwidth Memory): main memory, the same technology as on a GPU, described in GPU architecture.

The architecture: the systolic array

The GPU: the SIMT model

GPUs run in SIMT mode (Single Instruction, Multiple Threads): you issue one instruction and thousands of small processors execute it in parallel on different data. Very flexible, because each thread keeps its own state and can, if needed, take a different branch from its neighbours.

The TPU: the systolic array

The TPU takes a different route: the systolic array.

Picture a grid of small calculators wired directly to each other. Data "flows" through it like water through a network of channels: it enters at one edge, and each calculator multiplies, adds, and immediately passes the result to its neighbour, without going back to memory.

The word "systolic" comes from "systole", the contraction of the heart: data pulses through the grid rhythmically, one step per clock cycle.

Block diagram of a TPU's multiplication array. Top left, a red Control block feeds a stacked column of queues. Those queues enter from the left into a large light-blue square, in which horizontal arrows labelled Data run left to right and vertical arrows labelled Partial Sums descend. Below the square, a row of adders marked plus, each connected to an accumulation register, forms a chain ending in an output marked Done.
The systolic array of the first TPU. Data enters from the left through queues, crosses the grid horizontally, and the partial sums descend from one row to the next, accumulating down to the adders at the bottom. This is the point of the metaphor in the text: a value read once from memory serves a whole column of calculators instead of being re-read for every operation.Source : Google Cloud Blog, An in-depth look at Googles first Tensor Processing Unit (TPU)

The diagram is precise about what flows in which direction: data enters from the left and crosses horizontally, while partial sums descend vertically from one row to the next, accumulating down to the adders at the bottom.

Here is the gain, and it deserves to be stated plainly: a value read once from memory is reused by an entire row and an entire column of calculators. On a conventional processor, every multiplication would mean fetching both operands. Here the operands propagate from neighbour to neighbour. Fewer trips to memory, so less energy spent and less time waiting, and GPU architecture showed that waiting on memory, far more than arithmetic, is what limits these machines.

The size of the grid has changed across generations: the 2015 TPU v1 carried a 256 × 256 grid of multiply-accumulate units, 65,536 in total; modern MXUs are 128 × 128, but there are several per core.

The trade-off: the TPU is less flexible. It excels at regularly shaped matrix products, but anything irregular (branching, variable sizes, shapes that change from step to step) suits it badly. A systolic array whose dimensions do not divide evenly runs partly empty.

Systolic versus SIMT: a trade-off, not a ranking

The GPU favours flexibility and pays a little more energy per operation. The TPU favours energy efficiency and gives up flexibility.

Google could make that bet because it knew exactly which calculations it would need: matrix products, over and over, on models it designed itself. NVIDIA sells to the whole research community, and nobody knows what that community will need in two years. Both were right in their own context, and recent history bears it out: the architectures that have emerged since, such as mixture-of-experts models, introduce precisely the kind of irregularity that gives a systolic array trouble.

The generations

TPUs advance by generation. Every figure below comes from Google Cloud's documentation, and they are peak rates per chip, the same caveats as for GPUs apply: a peak is not a sustained rate.

GenerationPeak BF16 computeHBM memoryHBM bandwidthPod size
v4 (2021)275 TFLOPS32 GiB1,200 GB/s4,096 chips
v5e (2023), economy197 TFLOPS16 GB800 GiB/s256 chips
v5p (2023), performance459 TFLOPS95 GiB2,765 GB/s8,960 chips
v6e (2024), Trillium918 TFLOPS32 GB1,638 GB/s256 chips
v7 (2026), Ironwood2,307 TFLOPS192 GB7,380 GB/s9,216 chips

A few pointers for reading that table:

  • the e and p suffixes mark two product lines: e is optimized for cost and aimed mainly at inference, p targets training performance. Comparing a v5e to a v5p is therefore misleading; they are not the same machine;
  • the v6e delivers 918 ÷ 197 ≈ 4.7 times the compute of the v5e, which matches exactly the factor Google highlighted at announcement;
  • v7 Ironwood, available since April 2026, is the first TPU whose spec sheet explicitly advertises an FP8 rate: 4,614 TFLOPS per chip, double its BF16 figure;
  • a v5p pod reaches 8,960 × 459 TFLOPS ≈ 4.1 EFLOPS in BF16, and a v7 pod 9,216 × 4,614 ≈ 42.5 EFLOPS in FP8. An exaFLOPS is a billion billion operations per second.

On power, Google publishes measurements rather than a theoretical envelope for the v4: 90 W minimum, 170 W mean, 192 W maximum. That is an honest and unusual disclosure, most vendors quote only a maximum.

BF16, a Google invention that became the standard

Google designed BFloat16 (Brain Floating Point, after the Google Brain team), shortened to BF16. The idea: keep FP32's 8 exponent bits (hence exactly the same range of representable values, from very small to very large) but keep only 7 mantissa bits instead of 23, meaning far less fineness in the decimals.

Why that is the right trade: what breaks a 16-bit training run is a gradient going too small and flushing to zero, or a value going too large and overflowing. Those are problems of range, not of fineness. Classic FP16 has only 5 exponent bits and suffers exactly this; BF16 keeps FP32's range and sacrifices decimal precision, which networks largely do not care about.

The format worked so well that NVIDIA built it into its Tensor Cores as early as the A100 in 2020, and it is now the default format for training. See Mixed precision.

ICI: the network between chips

Once you train across thousands of chips, the limiting factor is no longer compute but communication between chips. TPUs use a proprietary network for this, the ICI (Inter-Chip Interconnect).

A textbook case of the bits-versus-bytes trap

Google documents the v7's ICI at 1,200 GB/s per chip, both directions summed. Elsewhere, for the same chip, you read "9.6 Tb/s". Those are the same number: 1,200 × 8 = 9,600 gigabits, that is 9.6 terabits. One is in bytes, the other in bits.

This is exactly the error described in Bits and bytes, and it is especially treacherous here because both values are published by the same vendor in different documents. Before comparing an ICI figure to an NVLink figure, check the unit and check whether the number counts one direction or two.

The torus: why that shape

Chips are not wired to a central switch but to their immediate neighbours, on a grid. Each v4 chip has six links, connecting it to six neighbours: up, down, left, right, front, back.

The word torus comes from the edges wrapping around to the opposite edges, like Pac-Man leaving one side of the screen and reappearing on the other. The consequence: no chip is "at the end" of the network, and the maximum distance between any two chips stays short.

The topology varies by generation, and the detail matters: v4 and v7 are three-dimensional, v6e is two-dimensional. A 3D topology grows the chip count far faster than the distance between chips, which is why the very large pods (4,096 and 9,216 chips) are found on the 3D generations.

Two-part figure. On the left, a photograph of four cabled TPU server racks, with the text Each rack corresponds to 4x4x4 TPUv4s and These can be configured into arbitrary 4i x 4j x 4k toruses via optical interconnects. On the right, four cubes made of stacked small green blocks, each cube representing a rack of 4 by 4 by 4 chips. Wide grey arrows connect the cubes pairwise horizontally and vertically, and further dashed arrows leave the cubes towards the outside of the image.
How a pod is built. A TPU v4 rack is a cube of 4x4x4 chips, so 64 chips, and cubes are joined by optical links to form a larger torus. The dashed arrows leaving one side are the wrap-around links: they come back in through the opposite face, which is exactly the Pac-Man effect described above.Source : How to Scale Your Model, Google DeepMind, How to Think About TPUs chapter

What the shape buys you

The central operation of distributed training is the all-reduce: each chip holds a piece of the gradients computed on its own batch, and all of them must end up holding the sum of every piece. It is the operation described in Data parallelism, and it repeats at every training step.

A ring is the ideal shape for an all-reduce: each chip passes its partial result to its neighbour, which adds its own, and after one full lap everyone has everything. A torus contains rings in every dimension, which lets the operation run dimension by dimension. That is the reason for this topology, not aesthetics.

Google publishes for the v4 pod an all-reduce bandwidth of 1.1 PB/s, an aggregate across 4,096 chips, not a link rate. The distinction between an aggregate and a point-to-point rate is developed in Networking for distributed training.

TPU versus GPU: the comparison

AspectTPUNVIDIA GPU
Compute unitSystolic arraySIMT, Tensor Cores
FlexibilityOptimized for regular shapesGeneral purpose
InterconnectICI, 2D or 3D torusNVLink and NVSwitch
Preferred softwareJAX, TensorFlowCUDA, PyTorch
AvailabilityGoogle Cloud onlyEverywhere, cloud and on-premises
FormatsBF16, INT8, FP8 (v7)FP64 down to FP4
The software ecosystem: the real brake

TPUs are technically remarkable. But the vast majority of machine learning work happens in PyTorch on CUDA: tutorials, libraries, published models, diagnostic tools, forum answers, it is all on that side. The surveys that circulate on relative framework usage vary a lot by method, but they all point the same way.

On the TPU side there is JAX: powerful and elegant, but a minority choice. For someone coming from PyTorch, moving to JAX means changing how you think, you write pure functions and transform them, rather than a sequence of statements mutating state. The PyTorch/XLA bridge exists and works, but it adds a layer to debug.

This is the main obstacle to TPU adoption, and it is not a hardware one. The same mechanism, seen from the other side, is the subject of The CUDA ecosystem.

Programming for TPUs

In practice you program a TPU with JAX, Google's framework, or with PyTorch/XLA, a bridge between PyTorch and Google's compiler. Either way, the real work is done by XLA (Accelerated Linear Algebra), the compiler that turns the program into machine instructions for the TPU, and which, along the way, fuses operations, exactly like the kernel fusion described in GPU architecture.

JAX: transforming functions rather than executing statements

What makes JAX distinctive is that you do not write the parallel computation directly. You write a simple function that handles a single example, then apply transformations that build another function out of it:

import jax
import jax.numpy as jnp

# An ordinary function, written for a single vector.
def loss(params, x):
    return jnp.sum((params * x) ** 2)

# jax.grad builds the function that computes the gradient of loss.
gradient = jax.grad(loss)

# jax.vmap builds the version that handles a whole batch at once,
# without a single loop being written.
batched_gradient = jax.vmap(gradient, in_axes=(None, 0))

# jax.jit compiles the whole thing to machine code for the TPU
# ("just-in-time": compilation happens on the first call).
compiled_gradient = jax.jit(batched_gradient)

Three transformations appear here, and they compose in any order:

  • jax.grad takes a function and returns the function that computes its gradient, automatically;
  • jax.vmap (vectorized map) takes a function written for one example and returns the one that handles a whole batch, in parallel;
  • jax.jit compiles the result for the target machine.

That composability is what makes the tool powerful, and also what makes it feel strange at first: the code describes the shape of the computation, not its unfolding. Distribution across chips and the resulting ICI communication are then worked out by the compiler from sharding annotations, without the bodies of the functions changing.

Why this matters

TPUs show that there is no single way to build an AI accelerator. NVIDIA chose flexibility; Google chose efficiency on a compute profile known in advance. Both bets were sound, and both continue to coexist.

But the most useful lesson on this page lies elsewhere. On paper the TPU has been highly competitive for a decade, and it has not displaced NVIDIA. What holds it back is not a weakness in the silicon: it is that an accelerator is worth only as much as the software stack that knows how to drive it, and the number of people who know how to drive that stack. Which is exactly the subject of the next lesson.

Check your understanding0 / 5

1. What does a systolic array buy you compared with a conventional processor?

2. Google documents a chip's ICI at 1,200 GB/s, while another Google page quotes 9.6 Tb/s for the same chip. What should you conclude?

3. A mixture-of-experts model routes each token to a different sub-network, with batch shapes that change from step to step. Why is that an unfavourable case for a TPU?

4. TPUs have looked competitive on paper for a decade. Why have they not displaced NVIDIA?

5. BF16 keeps the 8 exponent bits of FP32 and retains only 7 mantissa bits instead of 23. Why does that trade work so well?