Systems & Infrastructure
Training & Fine-Tuning
IntermediateTraining builds a model and fine-tuning adapts it. Both are limited by the same four resources: data, compute, memory and time. This page starts at the next-token objective and works up through the C = 6ND scaling law, the memory bill, distributed training, and the fine-tuning recipes that fit on a single GPU.
What training actually is
At its core, training is one objective repeated trillions of times: predict the next token. You feed the model a sequence and it produces a probability distribution over the next token (the forward pass). Comparing that with the real next token gives a loss. The backward pass works out how each weight should nudge to reduce that loss, and the optimizer step applies the nudge. Do that over trillions of tokens and broad capability emerges from one simple game.
One loop, repeated trillions of times
Every training step runs the same four stations. Play the loop or tap a station.
The rest of this page is about feeding that loop. It draws on four resources:
What the loop consumes
Every run is limited by four resources. Each tile shows where that cost comes from.
Data
Trillions of tokens of curated text, scored and deduplicated.
Compute
C = 6 × N × D FLOPs, the biggest cost and one you can't avoid.
Memory
~16 bytes/param of training state, plus activations.
Time
Wall-clock weeks, gated by fleet size, MFU, and failures.
The memory bill: where VRAM goes
Serving a model stores only its weights. Training stores far more. With Adam and mixed precision, each parameter costs roughly 16 bytes: 2 ( weights) + 2 (BF16 gradients) + 4 (FP32 master copy) + 4 (FP32 momentum) + 4 (FP32 variance). On top of that come activations, the intermediate tensors the backward pass needs. They grow with batch, sequence length and depth.
Where the VRAM goes during training
Each column is one data-parallel GPU. Inference only stores weights. Training also keeps gradients, an FP32 master copy and the optimizer's momentum & variance, about 16 bytes/param before a single activation. ZeRO stages slice that state across the GPUs.
Per-GPU total
106 GB per GPU · 1.3× an 80 GB GPU: shard harder, recompute or add GPUs
Switch Adam → 8-bit Adam to halve the moment bytes, or SGD to drop variance entirely. At ZeRO-3, params, grads and optimizer state divide by your GPU count. That is how a 70B trains on a node that could never hold its full 16 B/param state on one card. ZeRO doesn't shard activations; recompute is what shrinks them. The activation estimate is a rough rule of thumb.
The architecture being trained
What you're training is a stack of transformer decoder blocks. Each block has a self-attention sublayer (which relates tokens to each other) followed by an (where most of the parameters live). Gradients flow back through every block on every step.
Dense vs. Mixture of Experts: what one token touches
Pick a token in the sentence. The dense block uses all of its MLP for every token. The MoE block's router sends each token to a few experts.
Dense decoder block
MLP: every weight used
Attention + MLP, every parameter active for every token. Compute and memory both scale with the full parameter count.
Mixture of Experts (MoE)
Token The goes to experts 2 and 6.
Many expert MLPs, and a router sends each token to a few of them. DeepSeek-V3 is 671B total but only 37B active per token. That cuts FLOPs per token and adds expert-parallel routing.
DeepSeek-V3 parameters, one scale
Eight experts with top-2 routing keeps the picture simple. Real MoE models have many more experts.
Worth remembering: compute scales with active params. Memory and checkpoint size scale with total params. So an is cheap to run per token and heavy to store.
The stages of building a model
A shipped model comes out of several training runs in sequence. Pretraining builds raw capability. Later stages teach it to follow instructions, align with preferences and reason. Each stage has its own dataset, GPU budget and output artifact.
Five stages from raw text to a reasoning model
Tap a stage for its objective, budget and output. The charts below put every stage's GPU count and duration on the same log scales.
Pretraining
- Objective
- Next-token prediction on web-scale corpus
- Outcome
- Base model, broad knowledge
- Compute / GPUs
- 1000s–16K+ GPUs · 1e24–1e25 FLOPs
- Dataset size
- 1–15T+ tokens
- Output artifact
- Base weights (405B → ~810 GB BF16)
- Typical duration
- Weeks–months
Example: Llama 3 405B: 16K H100, 15.6T tok, ~3.8e25 FLOPs
GPUs per run
Wall-clock duration
Bars are an order-of-magnitude reading of each stage's range (e.g. “100s-1000s” of GPUs); the open dot is SFT on a single GPU with LoRA.
For how the reinforcement learning stages run at scale (rollouts, async training, environments and on-policy distillation), see RL & Post-Training Infrastructure.
The C = 6ND formula & Chinchilla scaling
Training compute has a famously simple form: C = 6 × N × D FLOPs, where N is parameters and D is training tokens. The 6 is 2 FLOPs for the forward pass plus 4 for the backward pass per parameter per token.
Tokens per parameter: optimal vs. over-trained
One log ruler of training tokens per model parameter. Tap a marker to read it.
training tokens per parameter (log scale)
Read the gap as compute: with C = 6ND and N fixed, training cost grows with D. So ~1875 tokens/param is ~94× the training compute Chinchilla would pick for an 8B model. You pay it once, and every later token is cheaper to serve.
Distributing across GPUs (the training angle)
No single GPU can hold a frontier model's training state, so the run is split several ways at once. The splits nest into 3D/4D parallelism: TP stays intra-node on , PP spans nodes, DP scales the global batch, and shards the replicated state.
Six ways to cut one training job
Left: the work, which is a model (layers × width), a batch of sequences and one long sequence of tokens. Right: what each of four GPUs holds after the cut, and the traffic the cut creates.
The work, cut by DP
What each GPU holds, and who talks to whom
Gradients all-reduced each step
Data Parallel (DP)
What is split: The batch. Every GPU holds a full copy of the model and its training state.
Copy the model to every GPU and split the batch. Throughput scales, and gradients are all-reduced each step. ZeRO/FSDP shards the replicated state.
Schematic: four GPUs and an 8 × 8 model grid stand in for real sizes. Real runs nest these cuts: TP inside a node, PP across nodes, DP over the global batch.
The interactive parallelism visualizer is on the Model Sizing page. This section covers what each split costs in resources and throughput: every extra dimension buys capacity and spends interconnect bandwidth.
Model Sizing & Parallelism visualizer →How long does it take?
Now put it together. C = 6ND fixes the compute. Wall-clock time is that compute divided by what your fleet actually delivers (GPU count × peak FLOPS × MFU). The defaults are the real Llama 3 405B configuration.
How long does a training run take?
Pick a model size, a GPU fleet and precision, then a token budget. The run obeys C = 6 × N × D FLOPs, divided by what your fleet actually delivers (peak × MFU). The default is the Llama 3 405B config: 405B params, 15.6T tokens, ~3.8e25 FLOPs on 16K H100s. You get the ideal compute time. Real runs take longer (see below).
1 · Compute: C = 6 × N × D
3.79e25 FLOPs
Dashed diagonals are equal-compute lines (FLOPs); the dot is your run, the box its N × D. Violet = Chinchilla-optimal D ≈ 20N.
2 · ÷ What the fleet delivers
6.5 EFLOP/s
16,384 × H100 BF16 989 TFLOPS = 16.2 EFLOP/s peak
3 · = Ideal wall-clock time
67.7 days
Log time axis. Faded tail: real runs land later (interruptions, restarts).
GPU-hours
26.62M
fleet-independent compute cost
Dataset
15.60T tok
≈ 62.40 TB on disk (~4 B/tok)
Training-state memory
6.48 TB
16 B/param: 2+2 wts/grads, 4 master, 4+4 Adam
Checkpoint size
6.48 TB
full state · 810.0 GB weights-only
Ideal vs. real: 54 days of the Llama 3 405B run
466 interruptions · about one every ~3 h
During a 54-day window of Meta's 405B pretraining the job was interrupted 466 times and still kept >90% effective training time through fast checkpoint/restart. Plan for real wall-clock to come in above the ideal estimate. (Ticks evenly spaced for illustration.)
On the GB200 preset at FP8, the same run drops from weeks to days because per-GPU throughput jumps ~5×. You only get that throughput if storage and the interconnect keep the GPUs fed. A stalled GPU wastes its peak FLOPS.
Checkpoints & async checkpointing
A checkpoint saves what a run needs to resume (BF16 weights, the FP32 master copy and the Adam moments) at ~14 bytes/param. Gradients get recomputed after a restart, so they aren't saved. That comes to ~0.98 TB for a 70B and ~5.7 TB for a 405B, written every few hundred steps. Only one data-parallel replica has to write it, because the others hold identical copies. Done naively, the whole job pauses until the write lands.
Synchronous vs asynchronous checkpoints on the same clock
Two checkpoints in the same window. Watch what the GPUs do while each one is written. Durations are in illustrative units.
At time 0: synchronous has stalled the GPUs for 0 units; asynchronous has paused them for 0.
Synchronous checkpoint
The naive approach: the job pauses while the training state is written out and only resumes once it has landed on storage.
Asynchronous checkpoint
Async / non-blocking checkpointing: copy the state to CPU memory quickly, then write it to storage in the background while training continues. The I/O overlaps with compute, so the GPUs barely pause. A VAST study of more than 85,000 checkpoints from 40 production runs found async checkpoints draining to global storage at 50-200 GB/s, checkpoints taking under 10% of training time in almost every run, and even trillion-parameter models training efficiently with well under 1 TB/s of checkpoint bandwidth.
466 interruptions in 54 days: what each one costs
Llama 3's 405B run averaged a failure every ~3 hours, and each one rolls the job back to its last checkpoint. Pick a checkpoint cadence and the strip shows how much work gets thrown away.
The whole run · 54 days
Zoom: one day of the run (illustrative)
Work thrown away over 54 days
~117 h
≈ 9.0% of the run's wall-clock, redone by every GPU in the job
Without frequent, fast checkpoints, each crash would throw away hours of a multi-million-dollar run. Frequent checkpoints only pay off if each write is cheap, and async checkpointing and fast parallel storage make it cheap.
Rough estimate: each failure loses half a checkpoint interval on average (466 × interval ÷ 2); restart time and the checkpoint writes themselves are not counted.
With multi-TB writes landing every few hundred steps during a live run, training is as much a storage problem as a compute one. It needs high-throughput parallel storage feeding a fast streaming data pipeline, the kind VAST is built for.
See it in action: Feeding the GPUs & MFU →What a run costs in storage
The memory bill above is per-GPU VRAM during a step. The storage bill is everything the run parks on disk: the dataset it streams from, the weights it ships, and the rolling checkpoints it writes for safety. All three scale linearly with the parameter count, so as models grow from millions to trillions of parameters the footprint goes from gigabytes to petabytes.
Storage footprint across model scale
VRAM is the bottleneck during a step. Storage is the bottleneck across the run. As parameters climb from millions to trillions, the dataset, the shipped weights and the rolling checkpoints all grow linearly with the model, and the total ends up in petabytes. All figures are bytes on disk (GPU memory is covered above).
Storage across model scale (log-log)
drag on the chart to move the model size
At 7.0B params · share of the total
140.0B tokens × 4 B (uint32 shards)
7.0B params × 2 B, what you ship
7.0B params × 14 B (weights + master copy + optimizer) (already counted in the retained set)
rolling safety net against the next crash
A 7.0B-param run at 20× tokens needs 560.0 GB of training data and writes 98.0 GB every checkpoint. Keeping 5 of them alone is 490.0 GB.
Retained ≠ written. A run writes a checkpoint every few hundred steps (hundreds to thousands over a multi-week run), then garbage-collects old ones and keeps a rolling window plus a few permanent milestones. What you retain sets the capacity you need. How often you save sets the write bandwidth (the async-checkpoint problem above).
The dataset dominates once you over-train. Chinchilla-optimal is ≈ 20 tokens/param, but Llama 3 8B saw ~15T tokens (≈ 1875×). For reference, HuggingFace's FineWeb is 15T tokens ≈ 44 TB on disk as text; the same count stored as uint32 ids is ~60 TB. Near a trillion parameters the total crosses into petabytes, so frontier training needs a decision about high-throughput parallel storage as well as GPUs.
Fine-tuning in depth
Fine-tuning adapts an existing base instead of training from scratch. A full fine-tune updates every weight (a 7B costs ~100–120 GB of state). freezes the base and trains a small low-rank adapter (~15–23 GB for a 7B, ~0.1–1% of params, recovering ~90–95% of full quality). 4-bit-quantizes the frozen base (<10 GB for a 7B), which is enough to fine-tune a 65B on a single 48 GB GPU. Adapters can be swapped or merged per task.
Full fine-tune vs. LoRA vs. QLoRA
A full fine-tune carries the entire 16 B/param training state. LoRA freezes the base and trains a tiny low-rank adapter (~0.1–1% of params). QLoRA also 4-bit-quantizes the frozen base, so you can fine-tune a 65B model on a single 48 GB GPU.
Does it fit on one GPU?
What LoRA actually trains
per module: 2 × d × r = 2 × 4,096 × 16 = 131K
× 4 modules × 32 layers = 16.8M trainable (0.24%)
Not to scale: r is drawn far wider than life (r = 16 vs d = 4,096) so the adapter stays visible.
| Method | Trainable | VRAM | Quality recovery | Runs on |
|---|---|---|---|---|
| Full FT | 100% | 104.3 GB | 100% (reference) | Multi-GPU (>80 GB) |
| LoRA | 0.24% | 13.3 GB | ~90–95% of full | Consumer 24 GB (RTX 4090) |
| QLoRA | 0.24% | 3.5 GB | ~90–95% of full | Consumer 24 GB (RTX 4090) |
LoRA trains 16.8M params (0.24% of the model) yet recovers ~90–95% of full-FT quality. QLoRA's 4-bit base is what moves a 70B from a multi-GPU job to a single 48 GB card (the same technique covered under Quantization & Precision). Columns count model state only. Activations come on top.
Audit, logging & reproducibility
A training run that can't be reproduced or evaluated is a liability. The same discipline that catches a diverging loss curve also proves a model's quality and provenance.
Four practices, each guarding part of the run
The run flows top to bottom; each lane shows the stretch a practice covers. Tap a lane or a name to read it.
- Raw corpus
- Filters & dedup
- Training batches
- Training run
- Checkpoints
- Evaluation
- Quality claim
Data lineage
covers raw corpus → training batches
Track which corpus, filters, and dedup produced each batch. Provenance matters for licensing, contamination, and debugging.
The tooling stack
Nobody writes a training loop from scratch at this scale. Mature frameworks handle parallelism, sharding, adapters and RL rollouts, and they sit on top of the interconnect and storage that keep the GPUs busy.
The training stack, layer by layer
Adaptation tools sit on frameworks that train at scale, which sit on the infrastructure that keeps GPUs busy. Tap a block for details.
Adapt & align
adapters, preference tuning, RL rollouts
Train at scale
parallelism and sharding
Infrastructure
what keeps the GPUs fed
NVIDIA NeMo
End-to-end framework for pretraining and customizing LLMs at scale.
Training feeds everything
Planning a run means sizing the fleet, choosing the hardware and keeping the GPUs fed. These pages go deeper on each.
Vendor TFLOPS figures vary by sparsity (the dense peaks used here are ~2× lower than sparse marketing numbers) and by precision convention (FP4 vs FP8). Published "training cost" figures usually count only the final run, excluding R&D, failed runs, and prior experiments.