Data parallelism defined
It is the simplest way to train on more than one GPU. Each GPU, called a rank, holds the whole model. A global batch of 256 samples on 8 GPUs becomes 32 samples per GPU. Each rank runs forward and backward on its own 32 samples, then the ranks agree on one averaged gradient and step together.
Because each rank sees different data but applies identical updates, the copies stay in sync. PyTorch’s DDP notes describe the result plainly: after one optimizer step, all models on different processes should be exactly the same.
The catch is memory. Every GPU must fit the full model, its gradients and its optimizer state. Sharded variants fix that, and they are covered below.
References: PyTorch Distributed Data Parallel design notes
How DDP works, step by step
At start-up, rank 0 broadcasts its model state so every replica begins identical. During backward, autograd hooks mark each gradient as ready. DDP groups gradients into buckets, roughly in reverse parameter order, and as soon as a bucket is full it launches an asynchronous all-reduce on it. That overlaps communication with the rest of the backward pass, which is where DDP gets its speed.
The default bucket size is 25 MiB, set with bucket_cap_mb. All ranks must reduce buckets in the same order; the notes warn that mismatches can cause wrong results or a hang. The optimizer itself runs locally and needs no changes.
PyTorch’s API reference says DistributedDataParallel is proven to be significantly faster than the older torch.nn.DataParallel, which runs one process with several threads. Use DDP even on a single machine. Our planned guide to PyTorch DDP multi-GPU training shows the launch commands.
References: PyTorch Distributed Data Parallel design notes · PyTorch DistributedDataParallel API reference
Sharded variants: ZeRO and FSDP
Mixed-precision training with Adam needs about 16 bytes per parameter for model state, according to the ZeRO paper: 2 for FP16 weights, 2 for FP16 gradients and 12 for the FP32 master weights, momentum and variance. The paper’s example is a 1.5-billion-parameter GPT-2 that needs at least 24 GB before activations.
DeepSpeed ZeRO removes the duplication in stages. Stage 1 partitions optimizer states, so each rank updates only its share. Stage 2 also partitions gradients. Stage 3 also partitions the 16-bit weights and gathers them layer by layer during forward and backward. DeepSpeed says stage 3 memory savings scale linearly with the data-parallel degree. ZeRO-Offload and ZeRO-Infinity can push state to CPU memory or NVMe.
PyTorch FSDP does the same inside PyTorch. FULL_SHARD, the default, shards weights, gradients and optimizer state; it all-gathers weights before each layer runs and reduce-scatters gradients afterward. SHARD_GRAD_OP is the ZeRO-2 analogue, NO_SHARD behaves like DDP, and HYBRID_SHARD shards within a node and replicates across nodes. The newer fully_shard API (FSDP2) shards each parameter on dim-0 as a DTensor.
References: ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (arXiv) · DeepSpeed Zero Redundancy Optimizer tutorial · PyTorch FullyShardedDataParallel documentation · PyTorch fully_shard (FSDP2) documentation
Memory per GPU by data parallelism variant
The table applies the ZeRO paper’s accounting to a 7-billion-parameter model trained with mixed-precision Adam on 8 GPUs. Figures cover model state only; activations come on top and depend on batch size and sequence length. Plain replication needs 112 GB per GPU, which does not fit an 80 GB card. Full sharding brings it to 14 GB.
Communication rises as you shard more. The ZeRO paper reports that stages 1 and 2 keep the same communication volume as plain all-reduce, while full sharding adds about 50%, because weights must be gathered again in the backward pass.
| Variant | What is sharded | Model state per GPU (7B, 8 GPUs) | Communication |
|---|---|---|---|
| DDP / NO_SHARD | Nothing | ~112 GB | All-reduce of gradients |
| ZeRO-1 | Optimizer state | ~38.5 GB | Same volume as DDP |
| ZeRO-2 / SHARD_GRAD_OP | Optimizer state, gradients | ~26.3 GB | Same volume as DDP |
| ZeRO-3 / FULL_SHARD | Optimizer state, gradients, weights | ~14 GB | About 1.5x DDP |
| HYBRID_SHARD | Full shard within a node | ~14 GB on an 8-GPU node | All-gathers stay inside the node |
References: ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (arXiv) · PyTorch FullyShardedDataParallel documentation

Costs and trade-offs on rented GPUs
Plain DDP is the cheapest to run when the model fits: one all-reduce of gradients per step, overlapped with backward. Sharding lets the same job fit on fewer or smaller GPUs, but adds gathers that want fast links. On a single node with NVLink that cost is often small; across nodes on a slow network it can dominate, which is why HYBRID_SHARD keeps the heavy traffic local.
Illustrative example with assumed numbers: full fine-tuning of a 7B model. With full sharding, 8 GPUs at an assumed $2 per GPU-hour cost $16 an hour, and a 6-hour run costs $96. If you instead switch to LoRA, which trains a small adapter, the job may fit on one GPU; LoRA fine-tuning cost works through that budget.
Scaling out also changes the global batch. Doubling GPUs at the same per-GPU batch doubles the global batch, which can require learning-rate changes. And more ranks only help if each is busy: check low GPU utilization before adding GPUs.
References: PyTorch FullyShardedDataParallel documentation
Common misconceptions
FSDP is model parallelism. It splits storage, not computation: each rank still runs every layer on its own data, after gathering that layer’s weights. That makes it a sharded form of data parallelism.
DataParallel and DDP are the same. They are not. DataParallel is single-process and multithreaded; DDP uses one process per GPU and is the version PyTorch recommends.
More GPUs always cut time linearly. The all-reduce grows with model size, and small per-GPU batches leave GPUs waiting. Measure samples per second at 1, 2 and 8 GPUs.
References: PyTorch DistributedDataParallel API reference · PyTorch FullyShardedDataParallel documentation
Related terms
Tensor parallelism splits each layer across GPUs, and pipeline parallelism splits the model into stages of layers; both combine with data-parallel replicas in large runs. Gradient accumulation simulates a larger batch on fewer GPUs. NCCL is the library that performs the all-reduce, all-gather and reduce-scatter collectives.
References: NVIDIA NCCL user guide overview
Checklist and next step
Use DDP when the model, gradients and optimizer state fit on one GPU. Switch to ZeRO-2 or SHARD_GRAD_OP when optimizer state is the problem, and to full sharding when weights are. Keep sharding inside NVLink nodes where you can. Log samples per second per GPU as you scale.
When the plan is set, rent the nodes: NeuraMesh lets you choose GPU, plan, count, hours and region on rent GPUs, and sends a confirmed quotation before any payment. For 8-GPU NVLink nodes, start at H100 rental, or ask the compute advisor.
NeuraMesh prices for these GPUs
| GPU | Memory | Data center | Value |
|---|---|---|---|
| RTX 4090 | 24 GB | $0.46 | $0.40 |
| L40S | 48 GB | $1.26 | $0.54 |
| A100 | 80 GB | $1.56 | $0.98 |
| H100 | 80 GB | $2.88 | $2.00 |
Every order is confirmed in a quotation before you pay. See all GPU prices.
Questions readers ask
What is data parallelism in machine learning?
Each GPU holds a full copy of the model and processes a different slice of each batch. The GPUs average gradients with an all-reduce and apply the same update, so the copies stay identical.
What is the difference between DDP and FSDP?
DDP replicates weights, gradients and optimizer state on every GPU. FSDP shards them across GPUs and gathers each layer’s weights only when needed, trading extra communication for much lower memory per GPU.
Which ZeRO stage should I use?
Start with stage 2 when optimizer state is what overflows; it shards optimizer state and gradients at the same communication volume as DDP. Move to stage 3 when the weights themselves do not fit.
Does data parallelism speed up inference?
In serving, the equivalent is running several independent replicas behind a load balancer, which raises throughput but not single-request latency. vLLM also offers a data-parallel mode for this.
How many GPUs do I need for DDP?
As many as you want for throughput, but each one must fit the whole model state plus activations. If one GPU cannot, use sharding or LoRA rather than more replicas.
Sources and editorial notes
- PyTorch Distributed Data Parallel design notes
- PyTorch DistributedDataParallel API reference
- ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (arXiv)
- DeepSpeed Zero Redundancy Optimizer tutorial
- PyTorch FullyShardedDataParallel documentation
- PyTorch fully_shard (FSDP2) documentation
- NVIDIA NCCL user guide overview
Primary documentation reviewed November 24, 2026. Provider descriptions reflect published documentation. Recommendations are our analysis; worked figures are illustrative unless explicitly stated otherwise. No independent provider benchmark or uptime ranking is claimed.
Need this GPU? Rent it from NeuraMesh: choose a GPU and plan, get a confirmed quotation, and pay only when you approve. See pricing.

