Topology Graphs — Why the Cluster's Shape Sets the Speed
The interconnect that the all-reduce rides is just a graph — devices are nodes, links are edges. Two graph metrics decide how fast a collective runs on it — network diameter (worst-case hops, your latency bound) and bisection bandwidth (the links you'd cut to split it in half, your cross-section throughput). Reshape the graph and those numbers move — wrap a mesh into a torus and the diameter halves; square up the grid and the bisection rises. Same device count, faster network. Vendor-neutral, no proofs.
200Math of Learning (gradient descent)Lesson 4 of 4ShowHide
Chapter 2 of 2 in Math for ML/AI Workloads
- Topology Graphs — Why the Cluster's Shape Sets the SpeedYou're here
Prerequisites: Gradients & Bandwidth — The Communication Wall
The one-line summary
The previous lesson left the gradient all-reduce riding "the interconnect" — but what is that? Just a graph. Devices are nodes, links are edges, and the speed of a collective on it comes down to two graph numbers you already reason about under other names: the (the worst-case hop count — your latency bound) and the (the links you'd cut to split it in half — your cross-section throughput). Change the shape of the graph and those numbers move — which is why two clusters with the same number of devices can train at very different speeds.
Two metrics that cap a collective
- — the longest of all the shortest paths: the most any message ever needs. It bounds worst-case latency.
- — slice the network into two equal halves; the number of links you must cut, times their bandwidth, is the throughput across the middle. It bounds all-reduce / all-to-all (the pattern where every node exchanges with every other) traffic, which by definition crosses the whole network.
Reshape the grid below and toggle wrap-around. Watch the amber diameter path (worst-case hops) and the red bisection cut (links to split it in half) — and the numbers move with the shape:
Shape is the lever — same devices, faster network
Two moves, both visible in the sim, change the metrics without adding a single device:
- Wrap-around (mesh → torus). Closing each row and column into a ring gives every node a second way around, so the worst-case path — the diameter — roughly halves. (It also doubles the bisection, since now there are two cut points across each ring, not one.)
- Square up the grid. A long, thin
4×16mesh has a tiny bisection (few links span its narrow waist) and a big diameter (far corners). A square8×8of the same 64 nodes has a wider bisection and a shorter diameter. Shape, for free.
Fat-tree vs torus — the cost/throughput call
The shape most large GPU and datacenter clusters use is the (a Clos / spine-leaf): a switched tree engineered for full, non-blocking bisection — any node can talk to any node at line rate. The price is more switches and links. A torus is the other end: cheap (every node is just wired to its neighbors, no big switch tier) but blocking — its bisection is limited, so the biggest collectives can congest it. Same trade you already make choosing a non-blocking spine vs an oversubscribed one: throughput vs cost.
It's the all-reduce's speed limit
Tie it back: the gradient all-reduce from the last lesson is a workload that hammers the whole network every step. So its time is governed by exactly these two metrics — diameter (how long the slowest leg takes) and bisection (whether the cross-network traffic congests). That's why, past raw bandwidth, two levers matter most:
- Cluster shape — a well-connected topology (fat-tree, or a squarer/wrapped torus) finishes collectives faster.
- Job placement — packing a job onto a compact, well-connected sub-graph (rather than scattering it across a sparse slice) keeps its diameter small and its links off the congested middle. The knob is topology-aware placement in the scheduler — an affinity rule or placement group that keeps the job on adjacent, well-connected nodes instead of wherever capacity happens to be free.
Why this matters
- You can read any fabric the same way. Ring, torus, fat-tree, spine-leaf — all graphs; diameter and bisection tell you the latency and throughput story without vendor specifics.
- Topology is a first-class capacity decision, not an afterthought — it sets the ceiling on how well your gradient sync (and thus your training throughput) scales.
- Placement is an operator lever. "Why is this run slow?" can be "it got scattered across a high-diameter slice," and the fix is packing it tighter — no new hardware.
Put it together
Square it up
In the sim, start at
4×16and reshape to8×8(same nodes). Report what happened to diameter and bisection, and say which collective behaviour each number predicts.Wrap it
Turn wrap-around on. Explain, in network terms, why the diameter dropped — and what the second cut line means for bisection.
Pick a fabric
A team needs the biggest possible all-reduce throughput and has budget for switches. Fat-tree or torus? Justify it in diameter/bisection terms.
Review
A cluster interconnect is a graph. What are the nodes and edges, and what are the common shapes?
Check yourself
What does closing a line of nodes into a ring (wrap-around) do to the network diameter?