Systems & Infrastructure

Training & Fine-Tuning

Intermediate

Training 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.

1/4
probabilitieslossgradientsnext batchstep 1 of 4× trillions of tokensForward pass→ logitsLossvs. true tokenBackward pass→ gradientsOptimizer stepapply the nudge

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.

Model
Optimizer
Micro-batch1
Sequence length4K
Data-parallel GPUsno sharding active8
Sharding stage
1/4Nothing sharded. Every GPU holds the full replicated state.
050100GB per GPUGPU 0GPU 1GPU 2GPU 3GPU 4GPU 5GPU 6GPU 780 GB HBM per GPU106 GB

Per-GPU total

106 GB per GPU · 1.3× an 80 GB GPU: shard harder, recompute or add GPUs

Params (BF16)13 GB
Gradients (BF16)13 GB
Optimizer (FP32)78 GB
Activations1.6 GB

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

token "The"
Self-attention

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"
Self-attention
Router - picks 2 of 8 experts
E1E2E3E4E5E6E7E8

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

total 671Bwhat memory and checkpoints must hold
active per token 37Bwhat compute pays for

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.

01-02 build raw capability03-05 post-training: follow instructions, align, reasonR1-style runs loop SFT ⇄ GRPO

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

1101001K10K

Wall-clock duration

hourdayweekmonth

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.

Chinchilla ~20Llama 3 8B ~1875
1101001K10K

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.

1/6Play to tour all six

The work, cut by DP

hidden width →layers ↓full copy on every GPUbatchstatePGO×4 copiesone long sequence →

What each GPU holds, and who talks to whom

GPU 0full model · batch 0GPU 1full model · batch 1GPU 2full model · batch 2GPU 3full model · batch 3

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.

GPU 0GPU 1GPU 2GPU 3full copy on every GPUheld by another GPU

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).

Parameters
Compute precision
GPU countlog scale, 8 → 32,76816,384
MFU (model FLOPs utilization)real fleets hit 0.35–0.50; Llama 3 405B ≈ 0.4240%
Token budget
Tokens (override)39 tok/param15.60T tok

1 · Compute: C = 6 × N × D

3.79e25 FLOPs

10M1B100B10T1e81e101e121e141e16N · parameters (active) →D · tokens →1e191e211e231e25 frontier1e27D = 20N

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

40% MFU
solid: deliveredhatched: peak the fleet does not reach

3 · = Ideal wall-clock time

67.7 days

1 h1 day1 wk1 mo1 yr10 yr

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

day 0day 54

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.

1/25t = 0 of 24 (illustrative units)

At time 0: synchronous has stalled the GPUs for 0 units; asynchronous has paused them for 0.

Synchronous checkpoint

GPUs
training job
Storage
checkpoint writes
GPU time spent training0.0 / 0 · 0.0 idle

The naive approach: the job pauses while the training state is written out and only resumes once it has landed on storage.

Asynchronous checkpoint

GPUs
training job
Storage
checkpoint writes
GPU time spent training0.0 / 0 · 0.0 idle

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.

GPUs trainingGPUs idle (stall)snapshot to CPU/GPU memoryblocking write to storagebackground flush

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

day 0each red line is one interruptionday 54
Checkpoint every

Zoom: one day of the run (illustrative)

00:0024:00
checkpoint failurework lost and redone after the restart

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).

Model size (log scale)7.0B params
Weights precision
Token id width
Tokens / param (log)Chinchilla-optimal ≈ 20; frontier models over-train far past it20×
Checkpoints retainedrolling window kept on disk (older ones deleted)5

Storage across model scale (log-log)

drag on the chart to move the model size

1 MB1 GB1 TB1 PB1M10M100M1B10B100B1T10Tmodel size (parameters) →FineWeb ≈ 44 TB7.0Btotal 1.06 TBdataset 560.0 GBretained ckpts 490.0 GB1 checkpoint 98.0 GBweights 14.0 GB
datasetweights1 checkpointretained ckptstotal footprint1 TB · 1 PB

At 7.0B params · share of the total

Training dataset560.0 GB

140.0B tokens × 4 B (uint32 shards)

Final model weights (BF16)14.0 GB

7.0B params × 2 B, what you ship

One full checkpoint98.0 GB

7.0B params × 14 B (weights + master copy + optimizer) (already counted in the retained set)

Checkpoints retained (×5)490.0 GB

rolling safety net against the next crash

Total run footprint1.06 TB

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.

Base model
LoRA rank (r)higher r = more capacity & params16
Target modules / layere.g. q,k,v,o projections4

Does it fit on one GPU?

GB02040608010024 GB · RTX 409048 GB · A6000 / L40S80 GB · H100104.3 GB ↑Full FT16 B/param13.3 GBLoRABF16 base + A,B3.5 GBQLoRA4-bit base + A,B
frozen base (no grads, no optimizer)trainable stateone card's memory

What LoRA actually trains

output = W·x + B·A·xWd × d · frozen+Bd × r·A r × dtrainable · r = 16d = 4,096

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.

MethodTrainableVRAMRuns on
Full FT100%104.3 GBMulti-GPU (>80 GB)
LoRA0.24%13.3 GBConsumer 24 GB (RTX 4090)
QLoRA0.24%3.5 GBConsumer 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.

  1. Raw corpus
  2. Filters & dedup
  3. Training batches
  4. Training run
  5. Checkpoints
  6. Evaluation
  7. 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.

NVIDIA open sharding engines Hugging Face stack and wrappers inference engine

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.