DISTRIBUTED TRAINING AT FRONTIER SCALE

Scaling from 1 GPU to 1,000 GPUs

How to train a 405-Billion parameter foundation model across clusters without drowning in communication latency.

THE VRAM DEFICIT WALL

LLaMA-3 405B Training Memory

Model Weights (BF16): 810 GB
AdamW States (FP32): 3,240 GB
Gradients (BF16): 810 GB
Total VRAM Needed: 4,860 GB (4.8 TB!)
Single 8x H100 Server Capacity: 640 GB Max
⚠️ DEFICIT: -4,220 GB (Cannot Fit on One Machine!)
THE SOLUTION

The 3D Parallelism Coordinate System

X: TENSOR (TP) Slices matrices inside layers (Intra-Node // 900 GB/s NVLink)
Y: PIPELINE (PP) Slices layers vertically across nodes (Inter-Node // 800G IB)
Z: DATA (DP / ZeRO) Shards dataset & weights across entire datacenter spine
Total GPUs = TP × PP × DP e.g. 8 (TP) × 8 (PP) × 16 (DP) = 1,024 GPUs

Tensor Parallelism: Slicing the Layer Matrices

Pioneered by Megatron-LM. Splits individual GEMM matrix operations across GPUs inside the same server over NVLink.

INPUT MATRIX X (Activations)
[Batch × SeqLen × HiddenDim]
✖️ MULTIPLIED BY SLICED WEIGHTS ✖️
GPU 0
Weight Slice $W_1$
Output $Y_1$
GPU 1
Weight Slice $W_2$
Output $Y_2$
...
...
...
GPU 7
Weight Slice $W_8$
Output $Y_8$
⚡ ALL-REDUCE SYNC ACROSS 900 GB/s NVLINK ⚡

The Golden TP Rules

Always TP ≤ 8: Keep Tensor Parallelism within the single 8-GPU NVLink domain.
Zero Extra Activation Memory: Activations are partitioned across heads.
⚠️
Never Cross Network Cables: 2 All-Reduces per transformer layer will choke standard network switches!

Pipeline Parallelism: The Layer Assembly Line

When layers outgrow 8 GPUs, slice the 96 transformer layers vertically across different servers and tame the bubble with 1F1B.

STAGE 0 (Server 1)
Layers 1 – 24
Input Tokens → Hidden States
➔ 800G IB ➔
STAGE 1 (Server 2)
Layers 25 – 48
Attention & MLP Pass
➔ 800G IB ➔
STAGE 2 (Server 3)
Layers 49 – 72
Attention & MLP Pass
➔ 800G IB ➔
STAGE 3 (Server 4)
Layers 73 – 96
Logits & Loss Calculation

The 1F1B Schedule (One Forward, One Backward)

Pipeline Bubble Reduced to < 8%
Stage 3:
F1F2B1B2F3B3
Stage 0:
F1F2F3F4B1B2B3B4

Chopping training batches into tiny micro-batches and interleaving 1 Forward with 1 Backward keeps all servers computing concurrently.

3D Parallelism & Cluster VRAM Planner

Configure your model size, GPU count, and parallelism dimensions. Watch memory allocation and find the perfect training configuration!

TP = 8
Recommended: TP = 8 (Keep within 1 NVLink server).
PP = 4
Vertical layer slicing across servers.
PER-GPU VRAM ALLOCATION (80GB HBM CEILING) STATUS: SAFE // FITS IN VRAM
80GB LIMIT
Weights: 6.2 GB Optimizer: 18.5 GB Gradients: 6.2 GB Activations: 12.0 GB
Total VRAM Used per GPU
42.9 GB
53.6% of 80GB utilized
Data Parallel (DP) Degree
DP = 2
64 / (8 × 4) parallel workers
Pipeline Bubble Ratio
7.8%
Idle assembly line wait
Training Throughput (Estimated)
3,420 tok/s
Cluster-wide tokens/sec

DeepSpeed ZeRO & FSDP: Eliminating Redundancy

Traditional Data Parallelism clones the entire model on every GPU. ZeRO partitions memory in 3 progressive stages.

TRADITIONAL DP

100% Memory Duplication

Full Weights (16GB)
Full Gradients (16GB)
Full AdamW States (64GB)
Total: 96 GB per GPU (OOM on 80GB!)
ZeRO STAGE 1

Shard Optimizer States

Full Weights (16GB)
Full Gradients (16GB)
1/N Optimizer States (8GB)
4x Optimizer Reduction // Zero Extra Comm
ZeRO STAGE 2

Shard Gradients + Optimizer

Full Weights (16GB)
1/N Gradients (2GB)
1/N Optimizer States (8GB)
Gradients freed as soon as reduced
ZeRO STAGE 3 (FSDP)

Shard EVERYTHING!

1/N Weights (2GB)
1/N Gradients (2GB)
1/N Optimizer States (8GB)
Weights fetched just-in-time and discarded!

The Golden Rule: Mapping Math to Silicon

Mismatching parallelism dimensions to physical networks causes cluster failure. Always follow this 3-tier hierarchy.

TIER 1 (FASTEST // 900 GB/s)
Physical: Intra-Node NVLink & NVSwitch
➔ MAP TO: Tensor Parallelism (TP = 8)

Highest communication frequency (2 All-Reduces per layer). Must never cross PCIe or network cables.

TIER 2 (MEDIUM // 800 Gbps)
Physical: Inter-Node InfiniBand Leaf Switch
➔ MAP TO: Pipeline Parallelism (PP)

Only transfers activation boundaries between consecutive layers. Low volume point-to-point transfers.

TIER 3 (GLOBAL // DATACENTER SPINE)
Physical: Spine Switches & Rail-Optimized Fabric
➔ MAP TO: Data Parallelism (DP / ZeRO-3)

AllReduce gradient updates at the end of each training step. Overlapped with backward computation.

Three Core Rules of Distributed AI Training

The master principles for training foundation models at scale.

01

3D Parallelism is Mandatory

Models > 70B cannot fit on one server. You must combine Tensor Parallelism (TP), Pipeline Parallelism (PP), and Data Parallelism (DP).

TP × PP × DP = Total GPUs
02

ZeRO-3 Eliminates Waste

DeepSpeed ZeRO-3 and PyTorch FSDP shard weights, gradients, and optimizer states across workers, fetching weights just-in-time.

Zero Redundancy
03

Map Math to Silicon

Keep Tensor Parallelism inside NVLink. Run Pipeline Parallelism across adjacent leaf nodes. Run Data Parallelism across the datacenter spine.

Zero Choke Points
GRAND FINALE // CHAPTER 10

Building an AI Data Center: Compute, Network, Storage & Power

How do you supply 50 Megawatts to one building? Direct-to-chip liquid cooling, parallel filesystems, and Power Usage Effectiveness (PUE).

Series Grand Finale