Skip to main content
← PROBLEMS / ARCHITECTURE
An end-to-end domain learning journey

Design a 1,024-GPU Distributed LLM Training
Fabric with Tensor & Pipeline Parallelism.

Combine TP=8 inside each 8-GPU NVLink node, PP=8 across InfiniBand with 1F1B microbatching, and DP=16 with ZeRO-1 optimizer sharding + asynchronous NVMe-to-S3 checkpointing.
Start the journey5 stages· Last modified Nov 26, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When designing a 1,024-GPU training fabric, match TP=8 to NVLink, use 1F1B to bound activation memory to O(PP), and shard optimizer states with ZeRO-1.

TL;DR30-second simplified summary
▾

Mapping TP=8 inside 900 GB/s NVLink, PP=8 with 1F1B scheduling (9.86% bubble at M=64), and DP=16 with ZeRO-1 drops static per-GPU memory to ~2.7 GB while overlapping gradient AllReduce and async NVMe-to-S3 checkpoints.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Ring AllReduce & Tensor Parallelism
Understand 2*(N-1)/N collective bandwidth bounds and why Megatron column-then-row TP belongs inside NVLink.
Mixed-Precision AdamW Memory Footprint
Know why BF16 weights + BF16 gradients + FP32 master weights + m/v moments total ~16–18 bytes per parameter.
Full walkthrough · 5 stages
01
L4 · FUNDAMENTALS

R & E · Requirements, Memory Math & 3D Topology Sizing.

Before picking parallelism dimensions, do the memory math: 70B parameters in BF16 weights (2B) + BF16 gradients (2B) + FP32 master weights (4B) + AdamW m & v (8B) = 16 bytes/parameter = 1.12 TB of static state before a single token's activations are stored.

With 1,024 GPUs (128 nodes x 8 GPUs), map TP=8 to the 8 GPUs inside each NVLink node. That gives 640 GB HBM per TP group. Adding PP=8 creates a 64-GPU model replica (80 layers / 8 = 10 layers per stage), leaving DP = 1024 / (8 * 8) = 16 data-parallel replicas. With ZeRO-1, each GPU holds 1/64 of weights/grads (1.09 GB each) and 1/(64*16) of optimizer states (~0.55 GB)—leaving >70 GB of HBM per GPU for activations and large microbatches.

Memory & Bubble Sizing

Unsharded 1.12 TB State vs. TP=8 · PP=8 · DP=16 + ZeRO-1

Before · Naive DP-Only / Unsharded
  • 1.12 TB static state > 80 GB HBM
  • Immediate OOM on step 0
  • Cross-node TP stalls on IB
After · 3D Parallelism (8 x 8 x 16)
  • ~2.7 GB static state per GPU
  • 9.86% pipeline bubble at M=64
  • TP stays 100% inside NVLink
02
L4 · FUNDAMENTALS

S · Storage & Asynchronous Two-Tier Checkpointing.

At 1,024 GPUs, a GPU or NIC fails roughly once every 12–24 hours. If you pause all 1,024 GPUs to stream 1.12 TB directly to S3 every 30 minutes, you burn ~15% of cluster GPU-hours on storage I/O.

Use a two-tier asynchronous checkpoint pipeline: (1) Copy sharded weights/optimizer tensors from GPU HBM to pinned host DRAM (~1.5s over PCIe Gen5), then resume training immediately; (2) A background CPU thread flushes host DRAM to local PCIe Gen4/5 NVMe (~3s) and streams shards to global S3/Ceph object storage in parallel.

Checkpoint Tiers

HBM Snapshot -> Pinned DRAM -> Local NVMe -> Async S3

03
L5 · APPLIED DESIGN

H & A · High-Level Fabric & 1F1B Pipeline Schedule.

In naive GPipe, all M=64 forward microbatches run before any backward pass starts, forcing Stage 0 to store 64x activations in HBM and causing OOM.

A 1F1B (One-Forward-One-Backward) schedule runs PP warmup forward passes, then alternates 1 forward and 1 backward microbatch per stage. Stage 0 never holds more than PP=8 in-flight microbatch activations in HBM—cutting peak activation memory by 8x while keeping the exact same 9.86% bubble ratio.

3D Cluster Fabric

NVLink TP=8 Rings + IB PP=8 Stages + IB DP=16 Gradient Rings

TP=8 NVLink DomainingressPP=8 1F1B StagescomputeDP=16 ZeRO-1 RingstorageAsync NVMe -> S3control16 MB P2P boundarybucketed grads1.6 GB/GPU snapshot
04
L5 · APPLIED DESIGN

D · Detailed Design: Gradient Bucketing & Fault Recovery.

Waiting until the entire backward pass finishes before starting the DP=16 AllReduce leaves all GPUs idle during network transfer.

Register autograd backward hooks that group gradients into 25 MB–50 MB contiguous buckets. As soon as the last microbatch finishes computing gradients for Stage 7's layers, NCCL launches an asynchronous DP AllReduce on that bucket while backward compute continues on earlier layers.

1F1B Overlap

1F1B Pipeline & Overlapped DP Gradient Bucketing

PP Stage 0PP Stage 1DP Ring (IB)Async NVMe1. 1F1B: Forward microbatch F_k2. 1F1B: Backward microbatchB_{k-7}3. Bucketed grad AllReduce(overlapped)4. Async snapshot every 100 steps
Engineering Decision Framework
Problem
How to minimize pipeline bubbles and checkpoint stalls across 1,024 GPUs.
Naive Solution
Use GPipe (all forwards then all backwards) and synchronous S3 checkpointing.
Why It Fails
GPipe holds O(M) activations in HBM (OOM), and synchronous S3 writes freeze 1,024 GPUs for 10+ minutes.
Alternatives
GPipe vs. 1F1B vs. Interleaved 1F1B; ZeRO-1 vs. ZeRO-3.
Engineering Decision
Use 1F1B (or Interleaved 1F1B for even smaller bubbles) + ZeRO-1 + async pinned-DRAM -> NVMe -> S3 checkpointing.
Trade-Offs
Interleaved 1F1B shrinks pipeline bubbles by ~v-fold in exchange for v-fold more point-to-point activation sends.
Decision Exercise · Make the Call

Your 1,024-GPU training run (TP=8, PP=8, DP=16) shows 38% MFU instead of >50%. Profiling reveals Stage 0 is running out of memory with M=64 microbatches under GPipe, forcing m_bs=1 and M=16. What change recovers >50% MFU?

05
L6 · SCALE & TRADE-OFFS

E & D · Evaluation, Assumptions, Limitations & Glossary.

Every distributed training number depends on cluster fabric symmetry: non-blocking fat-tree InfiniBand, healthy NVLink bridges, and balanced microbatch lengths.

Assumptions & Limitations: Calculations assume a 70B dense Transformer (80 layers, h=8192) on 1,024x 80 GB H100s with 900 GB/s NVLink and 400 Gbps InfiniBand per GPU, homogeneous BF16 mixed precision, and non-blocking fat-tree rail-optimized routing. Variable-length unpadded batches can introduce stragglers across DP ranks unless sequence packing is used.

Cluster Resilience

Training -> Node Fault -> Hot-Spare Swap -> Ckpt Resume (<5 min)

hardware errororchestrator evictrestore < 5 minTraining (>50%MFU)Xid / Link FlapCordon + SpareNodeLoad S3/NVMe Ckpt
Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

In a 1,024-GPU cluster (128 nodes x 8 GPUs) configured with TP=8, PP=8, DP=16 and M=64 microbatches per step, what is the approximate pipeline bubble fraction?

Recommended Learning Flow