3.3.11 · D5Deep Learning Frameworks

Question bank — Distributed training overview

2,472 words11 min readBack to topic

This is a rapid-fire self-quiz for the parent topic. Every item is a question ::: answer reveal. Read the question, commit to an answer out loud with a reason, then reveal. Bare "yes/no" doesn't count — the whole point of these traps is the justification.

Before you start, a one-line refresher on the vocabulary we lean on:

Recall The three words every item below assumes

Data parallelism ::: every device holds a full copy of the model, but each chews on a different slice of data; gradients are averaged (all-reduced) so all copies stay identical. Model parallelism ::: the model itself is cut into pieces (a layer split = tensor parallel, a group-of-layers split = pipeline parallel); no single device holds all the weights. All-reduce ::: the collective operation that sums (then averages) a tensor across every device and hands the same result back to all of them.

If any of those felt shaky, revisit the parent note before continuing. These prerequisites also help: 3.1-Neural-network-basics, 3.9-Gradient-descent-optimizers, 4.2-GPU-acceleration, 5.1-Training-at-scale.


The two numbers behind every trap

Almost every trap below turns on a tug-of-war between time spent computing and time spent talking. Let's name the quantities in plain words before using them.

Where does the speedup formula come from? Split one training step into two phases and add the times:

  1. Compute phase. The devices divide the math evenly, so instead of each does in parallel — they all finish this phase together after seconds.
  2. Communication phase. Then they must sync, costing seconds that nobody can skip.

So one distributed step takes seconds. The single-device baseline takes . Dividing baseline by distributed gives:

Figure s01 — read this first. It shows four horizontal time-bars, one per device count . The lavender segment (compute, ) shrinks every time you double ; the coral segment (communication, ) is identical width in every row. The takeaway to carry away: your total step time can never drop below that fixed coral bar, no matter how many devices you add — that is the ceiling on speedup.

Figure — Distributed training overview

How does itself scale — and does appear in it? Yes. A realistic all-reduce cost is not just a fixed number; it depends on the message size and on the number of devices:

Reading the two pieces:

  • is the fixed per-hop hand-shake delay (seconds); a tree/ring all-reduce needs about communication rounds, so latency grows slowly with device count.
  • is the gradient size in bytes, is link bandwidth (bytes/second). The factor is the fraction of the data each device must send in an optimal ring all-reduce — it starts at for , climbs to at , and approaches as (never exceeding it). So the bandwidth cost rises with but saturates near .

Edge behaviour to notice: at the whole thing is (nothing to sync — the and ). As grows large, : the bandwidth part flattens out while the latency part keeps creeping up. A faster interconnect raises , shrinking the bandwidth term — this is exactly what NVLink and InfiniBand buy you.

Figure s02 — read this second. It plots speedup against device count . The dashed slate line is the ideal . The three coloured curves feed different values into the speedup formula: mint (fast link), butter (medium), coral (slow). The takeaway: a larger peels the curve away from the ideal line earlier and harder — with a slow link you stop gaining almost immediately, so bandwidth quality decides how far you can usefully scale. These are illustrative curves from the toy formula, not measured hardware numbers.

Figure — Distributed training overview

With the four symbols (, , , ), the speedup formula, and the scaling rule in hand, the traps below should read cleanly.


True or false — justify

Adding more GPUs to a data-parallel job always reduces wall-clock training time.
False. Compute per device shrinks like , but communication cost stays constant or grows (its latency term rises like ); past a point each extra GPU spends more time syncing than computing and total time can rise.
Data parallelism with devices at local batch is mathematically equivalent to single-device training at batch .
True — but only with a matching learning rate. Averaging gradients across sub-batches equals the full-batch gradient by linearity, yet the effective batch is , so you usually must scale by the linear scaling rule or the optimization dynamics differ.
In pure data parallelism, splitting a model that doesn't fit in one GPU is possible if you use enough GPUs.
False. Every device holds a full copy; if one copy doesn't fit, adding replicas doesn't help. You need model/tensor/pipeline parallelism to split the weights themselves.
Gradient accumulation lets you get the same optimizer update as a large batch without the memory cost.
True. Summing gradients over micro-batches then averaging equals the full-batch gradient; only memory-per-step drops, at the cost of more forward/backward passes per update.
Synchronous SGD produces a different model than single-device training.
False. With identical initial weights and averaged gradients, synchronous SGD is deterministically equivalent to single-device SGD on the concatenated batch — that's its main selling point.
Asynchronous SGD converges to exactly the same trajectory as synchronous SGD, just faster.
False. Async workers apply stale gradients (computed on old weights but applied to ), so the optimization path — and sometimes the final accuracy — genuinely differs.
Tensor parallelism and pipeline parallelism are two names for the same thing.
False. Tensor parallelism splits within a layer (a matrix cut into column/row blocks); pipeline parallelism splits across layers (an assembly line of layer groups). They combine, not coincide.
Scaling efficiency above 1 (super-linear) is always a measurement error.
False. It can be real: with more devices each holds a smaller slice, which may now fit in fast cache, giving a per-device speedup that beats the naive ideal.
Doubling the interconnect bandwidth doubles your training speedup.
False. Bandwidth only shrinks the part of ; if compute already dominates, halving barely moves .

Spot the error

"We use 4 GPUs data-parallel, local batch 32, so we keep the same learning rate as our batch-32 single-GPU run."
Error: the effective batch is now 128, not 32. The gradient is a much smoother estimate; keeping the old typically underfits or slows convergence — apply the linear scaling rule (and warm it up).
"Our model is too big for one GPU, so we switched to data parallelism across 8 GPUs."
Error: data parallelism replicates, not splits. A too-big model still won't fit any single replica. The fix is model/tensor/pipeline parallelism (or sharded optimizer states).
"Asynchronous SGD is strictly better because no device ever waits."
Error: it trades waiting for staleness. Removing straggler waits improves hardware utilization but injects stale gradients that can slow or destabilize convergence — "better" is workload-dependent.
"We got 4× speedup on 4 GPUs, so efficiency is over 100%."
Error: 4× on 4 devices is efficiency , i.e. exactly 100%. Efficiency is ; it would only exceed 100% if .
"Pipeline parallelism keeps every GPU busy 100% of the time since it's an assembly line."
Error: pipeline bubbles. At the start and end of a batch's journey, downstream stages sit idle waiting for upstream output; without micro-batching these bubbles waste a large fraction of device time.
"All-reduce sends gradients to a central server, which is why it's a bottleneck."
Error: that describes a parameter server, not all-reduce. All-reduce is peer-to-peer (e.g. ring all-reduce) with no central node; its cost grows with data size and device count, not because of one server.
"Since gradient accumulation gives the same update as a big batch, our training finishes just as fast."
Error: same update, not same speed. You still run sequential forward/backward passes per step, so wall-clock time per update is roughly longer — you traded memory for time.

Why questions

Why does averaging the per-device gradients (rather than summing them) give the correct large-batch gradient?
Because the full-batch gradient is itself an average over all samples; each device already averages within its sub-batch, so averaging the sub-averages (equal sub-batch sizes) reconstructs the mean over the whole batch by linearity.
Why does scaling efficiency drop as you add more devices?
Compute per device falls as , but the synchronization cost is constant or grows (latency , bandwidth term climbing toward ) — so communication becomes a larger fraction of each step.
Why do we synchronize gradients every step in data parallelism instead of occasionally?
To keep all model copies identical; if replicas skipped syncs they would drift into different models, and averaging divergent weights no longer approximates the true update.
Why is high-bandwidth interconnect (NVLink, InfiniBand) worth the cost for large models?
Big models have huge gradient/activation tensors ( large), so slow links make the bandwidth term of dominate; raising bandwidth shrinks it and recovers most of the lost speedup. The parent note's BERT-Large example (1.3× on 10 Gb Ethernet vs 3.3× on 100 Gb InfiniBand) is a real measured instance of this effect; Figure s02 shows the shape of the same relationship on toy numbers, not those exact measurements.
Why does model parallelism introduce device-to-device transfers that data parallelism (mostly) avoids per layer?
In model parallelism the activations must flow from the device holding one layer to the device holding the next during every forward/backward pass; data parallelism only communicates once per step (the gradient all-reduce).
Why can a straggler cripple synchronous SGD but not asynchronous SGD?
Synchronous SGD is lockstep — everyone waits for the all-reduce, so the slowest device sets the pace; asynchronous workers push updates independently and never block on a slow peer.

Edge cases

What happens to the "effective batch equals " claim if the sub-batches are unequal sizes?
The simple mean of gradients is now slightly wrong; you must take a weighted average by sample count, otherwise small sub-batches get over-weighted relative to their data.
What is the speedup when communication time exactly equals the reduced compute time, ?
, i.e. only 50% efficiency — half your devices' potential is lost to syncing.
With device, what does the speedup formula give?
With no peers there's nothing to sync, so (both the and terms vanish) and — exactly the single-device baseline, as it must.
How does the all-reduce bandwidth factor behave as grows without bound?
It rises monotonically from (at ) toward but never reaches it, so the bandwidth cost saturates near — the latency term is what keeps growing after that.
What is the effect of gradient accumulation over micro-batches when ?
It degenerates to ordinary single-batch training — the "sum then divide by 1" is a no-op, so there's no memory saving and no slowdown.
If a model just barely fits on one GPU, is pipeline parallelism across 2 GPUs guaranteed to speed it up?
Not guaranteed — you gain parallel compute but pay activation-transfer cost and pipeline-bubble idle time; for a small model these overheads can outweigh the benefit, giving little or negative speedup.
In tensor parallelism splitting into column blocks , what must happen before the next layer if that layer needs the full output?
The partial outputs must be gathered/concatenated (or all-reduced, depending on the split) across devices, adding a communication step between layers.
What limits the maximum useful number of data-parallel replicas for a fixed dataset?
Once each replica's local batch shrinks toward 1 (or the effective batch grows so large it hurts generalization), adding replicas stops helping — you run out of data per step and communication dominates.