Compare ring and tree all-reduce with a latency-bandwidth model
Why it matters Collective libraries pick ring or tree algorithms per message size with exactly this kind of model, and it explains why small all-reduces scale poorly.
All-reduce cost has a fixed per-message latency alpha and a per-byte time 1 / bandwidth. Ring all-reduce sends many small messages but moves little data per GPU; tree all-reduce sends few messages but each carries the whole buffer.
Write allreduce_cost(n_bytes, p, alpha, bw). Ring time = 2 (p - 1) alpha + 2 (p - 1) / p * n_bytes / bw. Tree time (reduce then broadcast over a binary tree) = 2 ceil(log2 p) (alpha + n_bytes / bw). Return (ring, tree, faster) where faster is "ring" or "tree" (ring on ties). For p = 1 both times are 0.
def allreduce_cost(n_bytes, p, alpha, bw)Example
n_bytes 1e9, p 8, alpha 1e-5, bw 1e11 gives ring 0.01764, tree 0.06006 and "ring".
Understand the idea
Think of passing notes around a classroom. In a ring, each student passes a small piece to the next, many times, so there are many hand-offs but each is light. In a tree, notes go up to a leader and back down, so there are only a few hand-offs but each carries the full stack. Each hand-off has a fixed delay (alpha) plus time proportional to its size. Worked example: 1 GB on 8 GPUs at 100 GB/s with alpha 10 microseconds. Ring: 14 x 10 us + 2 x 7/8 x 0.01 s = 0.01764 s. Tree: 6 x (10 us + 0.01 s) = 0.06006 s. Rule: ring = 2(p-1) alpha + 2(p-1)/p n / B; tree = 2 ceil(log2 p)(alpha + n / B). For gradients the ring usually wins; for small control messages on thousands of GPUs, trees win.