One GPU is too slow for this run A training run on one GPU would take weeks. The plan is to spread it over 4 GPUs on 2 nodes and finish in roughly a quarter of the time.
Unlike serving, training repeats the same loop millions of times: forward pass, backward pass to get gradients, optimizer step. Every GPU must end each step with the same weights.
Data parallel: every GPU holds a full copy With data parallelism (PyTorch DDP), each GPU keeps a full copy of the model and the optimizer. Each rank reads a different shard of the batch (for example through DistributedSampler).
After the backward pass, every rank has different gradients, because it saw different data. Before the optimizer step, the gradients are averaged across all ranks. Then every copy applies the same update and stays identical.
Key idea The global batch is the per-GPU batch times the number of GPUs. Changing the GPU count changes the batch, so learning rate settings may need to follow.
NCCL collectives move the tensors between GPUs The averaging is an all-reduce: every rank contributes its gradients and every rank gets back the sum (divided by the world size). On NVIDIA GPUs the NCCL library runs it, over NVLink inside a node and the network between nodes.
Two more collectives matter for sharding. All-gather collects pieces from every rank so each has the whole tensor. Reduce-scatter sums the tensors and leaves each rank only its own piece of the result.
Ring and tree: how an all-reduce is wired In a ring all-reduce, the ranks form a loop and pass chunks to their neighbor. Each GPU sends about 2 × (N − 1) / N times the gradient size per all-reduce, close to twice the gradients no matter how many GPUs join. It uses bandwidth well, but its steps grow with N.
A tree all-reduce sums up a tree and sends the result back down, so it takes fewer hops and has lower latency at large scale. NCCL picks the algorithm by message size and topology on its own.
Key idea Set NCCL_DEBUG=INFO to see which transports (NVLink, InfiniBand, sockets) and rings or trees NCCL chose at startup.
Communication becomes the bottleneck A 1B-parameter model has about 2 GB of BF16 gradients. A ring all-reduce over 4 GPUs then sends about 3 GB per GPU, every step. Inside a node NVLink carries that quickly, but the hop between nodes is often far slower.
DDP overlaps the all-reduce with the backward pass by sending gradients in buckets as they are ready. When the network is too slow to hide behind compute, the GPUs sit idle waiting for each other, and adding GPUs stops helping.
Watch out Multi-node training wants a fast fabric (InfiniBand or RoCE, ideally with GPUDirect RDMA). On Kubernetes that often means an RDMA device plugin and a secondary network, for example with Multus.
A bigger model does not fit as a full copy Now the team wants a 7B model. With Adam in mixed precision, each parameter needs about 16 bytes: BF16 weights and gradients plus FP32 master weights and two optimizer moments. That is about 112 GB before activations.
A GPU here has 80 GB. DDP keeps all of it on every GPU, so adding more GPUs does not help at all. The copy itself does not fit.
Shard the states instead of copying them ZeRO (DeepSpeed) and FSDP (PyTorch) split the training state across the data parallel ranks. ZeRO stage 1 shards the optimizer state, stage 2 also the gradients, and stage 3 (like FSDP full sharding) also the parameters. With 4 ranks, each holds about a quarter: around 28 GB.
Before a layer runs, the ranks all-gather its parameters, use them, and free them again. After the backward pass, a reduce-scatter leaves each rank only the gradient shard it owns. Each rank still trains on its own data.
Key idea Full sharding costs about 1.5 times the communication of plain DDP. It trades network for memory, so the bandwidth from the last step matters even more.
Very large models also split layers, as in serving At the largest scale, sharding alone is not enough. Tensor parallelism splits each layer across the GPUs of one node, and pipeline parallelism splits the layer stack across nodes. Combined with data parallelism, this is often called 3D parallelism.
Training has extra costs over serving: backward passes double the traffic, activations must be kept for the backward pass, and pipelines need micro-batches to keep the bubble small. The splits work the same way as in Splitting a Model Across GPUs.
Key idea Keep tensor parallel inside a node on NVLink, and put data parallel or pipeline traffic on the network between nodes.
torchrun starts one worker per GPU, each with a rank Kubeflow Trainer (v2, which replaces the Training Operator and its PyTorchJob) takes a TrainJob that points at a runtime such as torch-distributed, with numNodes: 2 and resourcesPerNode of 2 GPUs. It creates the Pods through a JobSet.
In each Pod, torchrun starts one process per GPU and sets RANK, LOCAL_RANK, WORLD_SIZE, MASTER_ADDR and MASTER_PORT. All ranks meet at rank 0 to form the process group, then NCCL connects them.
Key idea All Pods must run at once, or the ones that started wait forever for the rest. Use gang scheduling, for example through Kueue or Volcano, so a job starts whole or not at all.
One worker dies and the whole job stops Node B loses a GPU and rank 3 crashes. The other ranks block in the next all-reduce, waiting for a peer that will never answer, until the collective times out. Every rank depends on every other rank each step.
torchrun stops all workers and restarts the whole group, up to --max-restarts. If the Pod or node is gone, the job controller recreates the group. Either way, everything since the last checkpoint is lost.
Watch out Checkpoint often to shared storage and make the code resume from the latest one. Distributed checkpointing lets each rank save its own shard in parallel. With torchrun --nnodes=MIN:MAX the job can also restart elastically on fewer nodes.
Copy or shard, then keep the network fast and the checkpoints fresh DDP gives each GPU a full copy and averages gradients with an all-reduce every step. FSDP or ZeRO shards the states when the copy does not fit. Tensor and pipeline parallelism split layers for the largest models.
Collectives make the network part of every step, and they tie all ranks together, so one failure stops all of them. Fast links and frequent checkpoints keep a large run moving.
Summary Watch GPU utilization next to network throughput. Low GPU use with a busy network means communication, not compute, is the limit.