Back to paths

TPU Topologies — the two networks & the shapes

The two networks (ICI vs DCN) and the shapes TPU chips form — 2D/3D torus, twisted torus, and Boardfly — across generations, and why the shape you rent changes throughput.

advanced~18 min#ml-systems#hardware#parallelism
100Foundational TPU architecture & provisioningLesson 4 of 8Show

Prerequisites: Why TPUs? Cloud TPUs & the TPU VM, TPU Evolution — Chasing the Bottleneck


The one-line summary

A TPU Pod wires chips into a torus over ICI (Inter-Chip Interconnect) — the grid wraps at its edges so there are no "ends," keeping any two chips a short hop apart. You rent a slice of that torus and choose its shape to match how you split your model. The shape varies by generation (a TPU v5p Pod is 8,960 chips in a 3D torus), and it's a real performance lever — because shape sets the network diameter, which sets how fast your collectives run.

The shapes, across generations

v{gen}{variant} names the chip, not the network: e = efficiency, p = performance (the 8th gen renamed these to t/i, training/inference). The topology spans generations, and each new shape broke a scaling wall:

  • 2D torus — v5e / v6e (Trillium): cheapest to wire, fine for smaller pods.
  • 3D torus — v4 / v5p / 8t: half the diameter of a 2D torus at the same chip count; v4 added OCS to reconfigure it and route around dead chips.
  • Boardfly — 8i: an optical hierarchy that cuts diameter ~56% (≈7 hops across 1,024 chips vs 16 on a 3D torus), for low-latency inference collectives.

Compare their network diameter (worst-case hops) at the same chip count:

Simulation: tpu-topology-explorer

One distinction infra engineers conflate

  • Single-host slice — one TPU VM (small slices fit on one host).
  • Multi-host slice — several TPU VMs whose chips are wired together by ICI (still inside one Pod).
  • — several slices joined over the slower DCN.

ICI is a physical chip-to-chip link; crossing slices drops you onto the DCN. Knowing which one your traffic rides is the whole game.

The hierarchy: chip → host → cube → slice → pod → Multislice

Scaling on a TPU isn't one jump from "a chip" to "a supercomputer" — it's a ladder, and each rung is bound by a different tier of network. Step through it:

Simulation: scale-hierarchy

The thing to notice: every rung up to a pod is still one ICI torus. Only crosses pods, and that hop runs over the slower — which is why where a boundary falls matters so much for performance.

The 3D torus, up close

Inside a slice, each chip has six links — ±X, ±Y, ±Z. At the edges the links wrap around to the opposite face, turning a 4×4×4 grid into a torus with no boundary. That wrap is what keeps the network diameter (worst-case hop count) low even as the slice grows.

Click a chip to light up its six neighbours, and toggle the wrap-around links to watch the edge chips close the loop:

Simulation: torus-3d

Slice shape is a real lever

Two slices with the same chip count can train at very different speeds. A 4×4×32 slice has one long axis — great for a ring all-reduce across a data-parallel group. An 8×8×8 slice is balanced — better when you need high bandwidth in every direction for tensor parallelism. Picking the shape is part of designing the run, not an afterthought.

Why this matters for ML

The three ways to split a model map onto the torus axes:

  • Data parallelism (DP) replicates the model and all-reduces gradients — it rides a torus ring happily, so it can stretch across a long axis.
  • Tensor parallelism (TP) splits a single matmul and is bandwidth-hungry, so it wants the tightest, highest-bandwidth ICI axis.
  • Pipeline parallelism (PP) splits layers into stages; its traffic is smaller and more tolerant, so it can span looser links — even across a Multislice DCN boundary in large runs.

Get the mapping right and the interconnect disappears into the background. Get it wrong — e.g. tensor-parallel traffic forced across the DCN — and the chips sit idle waiting on the network.

Inspect it in code

On a real v5p-128 slice, JAX reports all 64 chips and their coordinates in the ICI mesh — the same 4×4×4 torus the simulation draws. (v5p slice names count TensorCores, two per chip, so v5p-128 is 64 chips.)

inspect_topology.py
import jax
 
devices = jax.devices()
print(len(devices), "TPU chips")          # 64 on a v5p-128 slice
 
# Each device knows its (x, y, z) coordinate in the 3D-torus mesh.
for d in sorted(devices, key=lambda d: d.coords)[:4]:
    print(d.id, d.coords, "core", d.core_on_chip)

The coords are exactly the axes you clicked through above — wrap-around and all.

Put it together

Steps
  1. Trace one chip's six ICI neighbours

    In the 3D-torus simulation above, click a chip and confirm it has six neighbours — including the wrap-around links that close the torus at the edges.

  2. Walk the hierarchy from chip to Multislice

    Step through the scale hierarchy until you reach Multislice, and note exactly where ICI ends and the slower DCN takes over.

  3. Choose a slice shape for a data-parallel run

    Decide which axis you'd map a ring all-reduce onto, and why a long axis (e.g. 4×4×32) suits data parallelism better than a balanced 8×8×8.

Review

Flashcards1 / 4

ICI (Inter-Chip Interconnect)

Check yourself

Quick exam1 / 4 · 0 correct

How many ICI links does each TPU v5p chip have?

Go deeper

Prompt

Map a model onto a TPU slice

Given a transformer with 64 layers and a TPU v5p slice of shape 8x8x16, propose a sensible split across data, tensor, and pipeline parallelism. Say which torus axis you'd assign to each dimension and why, then estimate where the first bottleneck appears.

Link

TPU v5p documentation →

Official specs for ICI, slices, and Multislice.

Your notes on this lesson