Meta trained Llama 3 405B across 16,384 H100 GPUs at 400 TFLOPs per GPU on 8K sequences and 380 TFLOPs per GPU on 131K sequences by ordering four-dimensional parallelism as [TP, CP, PP, DP] and co-designing pipeline stages and attention sharding with the cluster network.

  • Fixed 16M-token global batch forced 3D then 4D parallelism: Under a 16M-token budget, pure 2D parallelism (FSDP ZeRO-3 + TP) falls below hardware compute-to-network balance (8,192 vs. 19,780 FLOPs/byte on 50 GB/s RoCE), pushing Meta to 3D (TP=8, PP=16, DP=128) for 8K context and 4D (TP=8, CP=16, PP=16, DP=8) for 131K context.
  • Layer co-design raised throughput 6.5% and cut peak memory by 5 GB: Removing one Transformer layer each from the first and last pipeline ranks (128 down to 126 layers) eliminated embedding and output-head imbalance; disabling activation recomputation boosted scaled-down throughput by 17.5%.
  • All-gather context parallelism beat ring attention by up to 13.53%: At cp=4 on 4K and 8K sequences, all-gathering compact grouped-query K/V tensors outperformed Transformer Engine’s ring overlap by avoiding kernel fragmentation while natively handling irregular document masks.
  • Replicating the vision encoder cut multimodal overhead from 33% to 8%: Duplicating the ViT encoder across pipeline ranks instead of running it sequentially before the text pipeline recovered throughput when image resolution rose from 448x448 to 672x672.
  • Stragglers drove 65.75% of long-context CP latency: On 8K GPUs at 128K sequence length, CP collectives took 7.64% of step time, but document-mask imbalance (1.44x slowest-to-fastest rank compute) capped the theoretical gain from ring communication overlap at 2.62%.
Network-aware ordering of Llama 3’s 4D parallelism on 16,384 GPUs
Innermost: TP = 8
Intra-node NVLink
4 exposed collectives per Transformer layer (all-gather and reduce-scatter in attention and FFN). Bounded to 8 GPUs per server so critical-path latency stays on NVLink.
Sequence: CP = 1 or 16
Multi-rank collective
All-gathers GQA K/V tensors once per layer across 16 ranks at 131K context. Placed inside PP because multi-rank synchronization is slower than two-rank P2P.
Layers: PP = 16
Async P2P across stages
Interleaved virtual stages with tunable consecutive micro-batches nc. Bubble ratio stays 5% at bs = 2 * pp and 12% at bs = pp.
Outermost: DP = 128 or 8
Cluster-wide FSDP
ZeRO-1 (when bs >= 2 * pp) or ZeRO-2 reduces FP32 gradients once per step, hiding latency by overlapping all-gather and reduce-scatter with compute.

Source: Chu et al. (ISCA 2025), Sections 3 through 5 and Table 2.

Ordering parallelism to fit cluster bandwidth

Training Llama 3 405B is a capability computing problem: the global batch is capped at 16M tokens, leaving limited data-parallel slack across 16,384 GPUs. Using 2D parallelism (FSDP ZeRO-3 + TP=8) gives only one sequence per data-parallel group (bs=1) at 8K length. In BF16, each parameter requires 2 bytes of weight communication for 2 * 8K FLOPs per token, an arithmetic intensity of 8,192 FLOPs per byte against an H100’s 19,780 FLOPs-per-byte ratio on 50 GB/s RoCE.

Replacing ZeRO-3 with 16-way pipeline parallelism keeps TP inside one 8-GPU NVLink node and relies on FSDP ZeRO-1 or ZeRO-2 only once per step. To keep pipeline bubbles small as batch sizes change across pretraining phases, Meta modified interleaved 1F1B so the number of consecutive micro-batches per virtual stage (nc) is tunable rather than locked to pp. Setting nc above pp hides exposed point-to-point transfers at the cost of extra warm-up activation memory; setting nc below pp smoothly degrades to all-forward-all-backward.

Meta paired this schedule with two fixes. First, shrinking the model from 128 to 126 layers (removing one layer from rank 0 and rank 15) offset the 128K-vocabulary embedding and output-head overhead. Second, custom autograd hooks freed pipeline output tensors immediately after forward sends instead of waiting on PyTorch reference counts, eliminating activation recomputation at 8K context.

Why all-gather context parallelism beat ring attention

Extending sequence length from 8K to 131K shrinks the global batch from 2,048 to 128 sequences. Keeping TP=8 and PP=16 drops bs to 1 and stalls the pipeline unless sequence parallelism absorbs the slack, so Meta traded DP (128 down to 8) for 16-way context parallelism (CP=16).

Instead of overlapping K/V block transfers with RingAttention, Meta all-gathered K and V before computing local Q attention. Two realities favored all-gather:

  • Compact K/V tensors under GQA: Because Llama 3 uses far fewer KV heads than query heads, K/V communication scales as O(seq) while attention scales as O(seq^2), shrinking exposed transfer overhead past 64K tokens (over 95% single-GPU FlashAttention-2 HFU).
  • Irregular document masks: Llama 3 packs multiple documents per sequence and masks attention across eos_id boundaries. Static 2 * CP symmetric chunking (assigning chunk i and 2*cp - i - 1 to rank i) balances full causal masks, while all-gather gives every rank full K/V tensors and avoids ring-kernel fragmentation (achieving up to 3.89x attention speedup on 4 GPUs and 13.53% higher HFU than Transformer Engine at cp=4 on 4K–8K inputs).

For multimodal training, Meta applied the same co-design lens: wrapping four frozen self-attention layers with one cross-attention layer per virtual stage balanced memory and compute, while replicating the ViT encoder across all PP ranks cut its step-time share from 33% to 8%.

Measured scaling bottlenecks and co-design gains (higher throughput, lower waste)
3D text pretraining (8K seq, TP=8, PP=16, DP=128)400 TFLOPs/GPU
4D long-context pretraining (131K seq, CP=16, DP=8)380 TFLOPs/GPU
PP bubble ratio
5% vs. 12%
At bs = 2*pp vs. bs = pp
Document-mask skew
1.44x gap
Slowest vs. fastest rank at 128K
Ring-overlap ceiling
2.62% max
65.75% of CP wait is straggler sync

Source: Chu et al. (ISCA 2025), Section 7.3.

Debugging slow ranks and numerical drift

When one GPU stalls inside a 4D mesh, the slowdown propagates across collectives, hiding which rank caused it. Meta debugs traces top-down from [DP -> PP -> CP -> TP]: find the slowest DP group first, then step inward until the root-cause rank and kernel appear. For numerical bugs, the team emulates the exact PP micro-batch accumulation order inside a 2D baseline to check bit-wise equivalence, and keeps BF16 for forward/backward compute while forcing FP32 gradient accumulation in PP micro-batches, DP reduce-scatter, and multimodal cross-attention tokens.

Caveats and builder takeaway

These numbers reflect Meta’s Grand Teton cluster (80 GB H100s, NVLink, 400 Gbps RoCE Clos) and a dense 405B GQA model; clusters with higher HBM capacity can trade PP stages for smaller TP (Meta saw ~10% higher throughput reducing TP=8 to TP=4 on 2K GPUs), while non-GQA or sparse MoE architectures shift the all-gather vs. ring balance. For teams scaling past a single node, match collective frequency to link bandwidth first, use top-down trace attribution for stragglers, and enforce FP32 gradient reduction before chasing optimizer instabilities.