Papers · 2024 · Reading: 31 min, plus 11 in closed details.
Paper · technical report · arXiv 2407.21783

The Llama 3 Herd of Models (Llama 3)

Llama Team, AI @ Meta (Aaron Grattafiori, Abhimanyu Dubey, Abhinav Jauhri and about 550 more; the full list is the paper's appendix)
Meta · July 2024 (dated 23 July 2024; arXiv v1 31 July 2024, v3 23 November 2024)

In one line: Meta's full playbook for a GPT-4-class open model: 405B dense on 15.6T tokens (50/25/17/8 data mix, 3-stage recipe with 128K long-context extension and annealing), six rounds of RM + rejection sampling + SFT + DPO, on 16K H100s at 38-43% MFU with 419 unexpected interruptions in 54 days (78% hardware) yet >90% effective training time.

3.8 × 1025 FLOPs
to train the dense 405B on 15.6T tokens
about 45 times Llama 2 70B; sized by a scaling law that reproduces from the paper's own figure · §3.2.1
38 to 43% BF16 MFU
on 8,192 to 16,384 H100s
4D parallelism, ordered tensor, context, pipeline, data · Table 4
419 unexpected stops
in a 54-day snapshot, one every 3.1 hours
yet more than 90% effective training time; 3 needed a human · Table 5

Verdict: Believe the engineering record: the cluster, the parallelism layout, the failure log and the recipe are the most detailed public account of a frontier-scale run, and its scaling-law forecast reproduces from its own figures. Read the benchmark claims as approximate: rivals' scores mix self-run and reported numbers, many gaps sit inside the noise, and the paper's own human evaluation has the 405B behind GPT-4o rather than level with it. How much of this to believe

The idea in one sentence: a plain dense Transformer, Llama 2's with four small changes, reaches GPT-4-class quality because of what surrounds it: 15.6T cleaner tokens, a size picked by a scaling law aimed at benchmark accuracy, engineering that keeps 16,384 H100s training through an unexpected stop every three hours, and a post-training loop (reward model, rejection sampling, SFT, DPO) simple enough to repeat six times.

You need: the parallelism forms (data and FSDP, tensor, pipeline, context) from Distributed training, scaling laws and IsoFLOPs curves from Pretraining (section 3), and SFT, reward models and DPO from Alignment. This page says what Llama 3 did with each.

New terms

  • Two-stage forecast: training FLOPs to the loss on a benchmark's correct answers, then that loss to accuracy with a sigmoid.
  • Annealing: the last stretch of pre-training, learning rate falling to zero on upsampled high-quality data; also Meta's cheap test of a dataset.
  • 4D parallelism: tensor, context, pipeline and data (FSDP) parallelism composed on one device mesh, ordered by how much bandwidth each needs.
  • Effective training time: useful training time over elapsed time.
  • Rejection sampling, here: sample 10 to 30 responses per prompt and keep the reward model's favourite as SFT data.
No box is a new architecture. The blue ones are what the report adds: a size chosen by a forecast of benchmark accuracy, a 16K-GPU job kept alive, and a post-training loop without PPO; the grey ones are scale and cleaner data. Drawn from §3 to §5 and Table 2; each number is sourced in its section below.

Problem

§1 Introduction

In mid-2024 the best open-weight models trailed GPT-4-class closed models by a wide margin, and no open release explained how to build one end to end: the data curation, how to size the model for a compute budget, the infrastructure that keeps 16,000 GPUs busy, and a post-training recipe that scales. Llama 3 is Meta's answer on both counts: a dense 405-billion-parameter model that it says "delivers comparable quality to leading language models such as GPT-4 on a plethora of tasks", released with its weights, and a 92-page report of how it was made (abstract, §1; 92 pages in the v3 PDF).

The report names three levers (§1):

  • Data. About 15T multilingual tokens for pre-training against 1.8T for Llama 2, with stricter curation and filtering before and after training.
  • Scale. 3.8 × 1025 FLOPs for the flagship, "almost 50×" the largest Llama 2 (by 6ND, Llama 2 70B on 2T tokens took 8.4 × 1023, a ratio of 45). The 405B is about compute-optimal for that budget; the 8B and 70B are trained "much longer than is compute-optimal" because they then beat compute-optimal models at the same inference cost.
  • Managing complexity. A standard dense Transformer rather than a mixture of experts, "to maximize training stability", and supervised finetuning, rejection sampling and DPO rather than "more complex reinforcement learning algorithms" such as PPO, which "tend to be less stable and harder to scale".

The question: can an open team reach GPT-4 quality with nothing exotic, only more and cleaner data, a budget sized by a scaling law, and engineering that keeps the run alive?

The herd and its architecture

§3.2, Tables 1 and 3

The herd is three sizes, each as a pre-trained and an instruction-tuned model. Llama 3 8B and 70B came out in April 2024; Llama 3.1 in July 2024 added the 405B, eight-language multilingual support, a 128K-token context and tool use at every size. Every result in the paper is for the 3.1 models, which it calls Llama 3 (Table 1). The April 8B and 70B "were pre-trained on multilingual data but were intended for use in English at the time" (footnote 1).

The architecture is Llama 2's with four changes; the paper credits its gains "primarily" to data and scale, not architecture (§3.2):

  • Grouped-query attention with 8 key-value heads at every size, for faster inference and a smaller KV cache (Attention variants owns GQA). For the 405B that is 2 × 126 layers × 8 heads × 128 dimensions × 2 bytes = 504 KiB of BF16 cache per token, 16 times less than with one key-value head per query head (derived from Table 3).
  • A document mask: tokens cannot attend across document boundaries inside a packed sequence. It "had limited impact" in standard pre-training but mattered for continued pre-training on very long sequences.
  • A 128K-token vocabulary: 100K tokens from tiktoken plus 28K for non-English languages. English compression improves from 3.17 to 3.94 characters per token, so each token of compute reads 24% more text.
  • RoPE base frequency 500,000 (from 10,000), after Xiong et al. showed it works for contexts up to 32,768 (RoFormer has the rotary embedding; Positional encodings owns the base and the RoPE scaling the 3.1 release added).

The design lineage (Llama 1 to 4, the licence, why Meta stayed dense until Llama 4) is on the Meta lab page; this page keeps to what the report itself adds.

Table 3: three sizes, one shape
8B70B405B

Rows from Table 3; all three use SwiGLU, RoPE with θ = 500,000 and a 128,000-token vocabulary as printed (the released config.json says 128,256). The parameter row is recounted here from those shapes: attention, SwiGLU feed-forward, two RMSNorm vectors per layer, untied input and output embeddings. The 405B comes out at , the 70B at and the 8B at ; the tables tab shows the breakdown.

Pre-training data

§3.1

The corpus has knowledge up to the end of 2023 and is mostly web text, cleaned in seven stages (§3.1.1): safety and PII filtering, a custom HTML parser that strips markdown, de-duplication by URL, document and line (the methods are on Deduplication), heuristic filters, model-based quality classifiers, separate code and maths pipelines, and per-language multilingual processing.

The seven cleaning stages in detail
  1. PII and safety filtering: drop domains likely to hold unsafe content or much personal data, domains Meta's safety standards rank as harmful, and known adult domains.
  2. Text extraction: a custom HTML parser tuned for precision in boilerplate removal and recall of content, judged better than third-party article parsers by human raters. Maths and code pages keep their structure, and image alt text is kept because maths is often rendered as images with the formula in alt. Markdown markers are stripped: markdown "is harmful to the performance of a model that is primarily trained on web data compared to plain text".
  3. De-duplication at three levels: by URL (keep the newest version of each page), by document (global MinHash for near duplicates), and by line, ccNet-style, removing lines that appear more than 6 times in each bucket of 30M documents. The line pass also removes some frequent high-quality text, but "our empirical evaluations showed strong improvements".
  4. Heuristic filters: duplicated n-gram coverage ratio for long repeated lines such as logs, "dirty word" counts for adult sites the block lists miss, and a token-distribution Kullback-Leibler divergence to drop documents full of outlier tokens.
  5. Model-based quality filters: a fasttext classifier for "would this be referenced by Wikipedia", and DistilRoberta classifiers trained on Llama 2's judgements of whether documents meet stated quality requirements.
  6. Separate code and maths pipelines (after DeepSeek), with DistilRoberta classifiers trained on Llama 2 annotations and prompt-tuned for maths deduction, STEM reasoning and code interleaved with prose, plus their own HTML extraction and heuristics.
  7. Multilingual: a fasttext language identifier over 176 languages, de-duplication within each language, language-specific heuristic and model filters, and ranking by a multilingual Llama 2 classifier. How many multilingual tokens to use was set experimentally against English and multilingual benchmarks.

The mix was chosen with a knowledge classifier (to downsample categories over-represented on the web, such as arts and entertainment) and scaling-law experiments on candidate mixes: train small models on a mix, predict a large model's performance, repeat, then train a larger model on the winner (§3.1.2). The final mix is the bar beside this section: about half general knowledge, a quarter maths and reasoning.

The mix also moved during the run: more non-English data, upsampled maths, more recent web data late on to advance the knowledge cut-off, and less of subsets later judged low quality (§3.4.1).

Annealing as a data lever. Annealing on small amounts of high-quality code and maths lifts benchmark scores; no benchmark training sets go into the annealing data, so few-shot scores stay honest. In a test that did use them, annealing a pre-trained 8B on the GSM8K and MATH training sets raised its validation scores by 24.0% and 6.4%, while the gains for the 405B were "negligible" (§3.1.3). Annealing is also Meta's cheap test of a new dataset: take an 8B trained to 50%, anneal its learning rate linearly to 0 over 40B tokens with 30% weight on the new data and 70% on the default mix, and measure. That costs far less than a scaling-law study per dataset.

The scaling law that sized the 405B

§3.2.1, Figures 2 to 4

Ordinary scaling laws predict next-token loss, not benchmark scores, and laws fitted on small runs can be unreliable (Pretraining owns scaling laws and compute-optimal allocation). Meta's answer is a two-stage method (§3.2.1):

  1. Relate the compute-optimal model's negative log-likelihood (NLL) on a benchmark's correct answers to training FLOPs.
  2. Relate that NLL to the benchmark's accuracy with a sigmoid, fitted on the scaling-law models plus the older, larger Llama 2 models.

Fig. 1, step by step: from 133 small runs to the size of the flagship

  1. One budget, twelve runs. At 1021 FLOPs Meta trained 12 models on 16.9B to 185B tokens (the smaller the model, the more tokens the same budget buys). Validation loss runs from 0.736 to 0.756 and is lowest in the middle (Figure 2).
  2. A parabola finds the valley. A second-degree polynomial in log tokens through those 12 points has its minimum at 54.6B tokens and loss 0.736, where the paper draws its diamond: the compute-optimal model for 1021 FLOPs, C / 6D = 3.05B parameters.
  3. Ten budgets, 133 runs. Each budget from 6 × 1018 to 1022 FLOPs gets its own parabola in its own plane. The valleys move to more tokens and lower loss as the budget grows, from 4.41B tokens at loss 0.900 to 238B at 0.693.
  4. The valleys flatten. The curvature (the coefficient on (log10 tokens)2) is 0.092 at 6 × 1018 FLOPs but 0.051 and 0.064 at the two largest budgets: the bigger the budget, the less it costs to be a few percent off the optimal size.
  5. The minima lie on one line. Dropped to the floor, the ten minima fall on a straight line in log-log, D⋆ = 0.2995 C0.5368 (refitted here; the figure's legend prints 0.299 and 0.537, the text 0.29 and 0.53).
  6. Extrapolate 3.6 orders of magnitude. Extended to 4.0 × 1025 FLOPs the line gives 16.55T tokens and 402.8B parameters, the paper's "402B on 16.55T"; at the stated 3.8 × 1025 it gives 16.1T and 393B. The run itself used 15.6T tokens on the 405B.

Fig. 1 rebuilds the paper's Figures 2 and 3 in 3D: the 133 points are read from the vector PDF in the arXiv source, the parabolas and the power law are refitted by this page's recompute.py (the forecast tab has them in 2D, with residuals), and loss is drawn to scale above 0.67. Scaling laws and compute-optimal allocation in general are taught on Pretraining.

The runs span budgets from 6 × 1018 to 1022 FLOPs and models from 40M to 16B parameters. At each budget a parabola is fitted to validation loss against training tokens (Figure 2); its minimum is that budget's compute-optimal model. A power law through the ten minima gives the optimal number of training tokens:

The scaling-law runs' hyperparameters

Cosine learning rate with 2,000 warm-up steps, peak between 2 × 10−4 and 4 × 10−4 by size, decay to 0.1 of peak, weight decay 0.1 times the learning rate, and a fixed batch of 250K to 4M tokens per budget (§3.2.1).

N⋆(C) = A Cα, with (α, A) = (0.53, 0.29)
Equation 1 (§3.2.1). C is the compute budget in FLOPs; N⋆ is a number of tokens, not parameters. The paper then states that extrapolating to 3.8 × 1025 FLOPs "suggests training a 402B parameter model on 16.55T tokens".
Put the printed constants into the printed formula at the printed budget, 0.29 × (3.8 × 1025)0.53. How many tokens come out?

So the printed constants are rounded too hard to reproduce the printed forecast: they give 10.5T tokens. The figure itself carries the fuller values in its legend, α = 0.537 and A = 0.299, and a refit of its ten points gives α = and A = . With the refit, the paper's 16.55T comes out at a budget of FLOPs, where C / 6D gives parameters: the paper's "402B on 16.55T" reproduces exactly at 4.0 × 1025, not at the 3.8 × 1025 it names (derived here; the paper does not say which budget it plugged in). At 3.8 × 1025 the same law gives tokens and parameters. The Meta lab page flagged this gap as unconfirmed; the legend and the refit close it.

The run that followed used 15.6T tokens, and 6 × × 15.6T = FLOPs reproduces the stated 3.8 × 1025. Meta chose 405B because the IsoFLOPs curves "become flatter around the minimum as the compute budget increases", so being a few percent off the optimal size costs little loss. The curvature of the fitted parabolas falls from about 0.09 per decade squared at the small budgets to 0.05 to 0.06 at the largest two (recomputed in the forecast tab).

The benchmark forecast. For ARC Challenge, stage 1 fits a line through seven scaling-law models (6 × 1019 to 1022 FLOPs) and extrapolates 3.6 orders of magnitude to the flagship; stage 2 maps the predicted NLL to accuracy. The paper calls the result "quite accurate: it only slightly underestimates the final performance" (Figure 4). Read from the figure: predicted NLL 1.201 against an actual 1.190, and predicted accuracy 95.8% against 96.0% (the pre-trained 405B scores 96.1 ± 1.1 in Table 12). The forecast tab refits both stages and shows what the forecast leans on: the scaling-law models all score 27% to 34%, near the 25% chance level, so the sigmoid's shape comes from four Llama 2 models and from fixing its ceiling at 100%.

Training on 16K GPUs

§3.3, Tables 4 and 5, Figures 5 and 6

The cluster in one line (§3.3.1): up to 16K H100s, eight per server on NVLink, 400 Gbps RoCE between servers in a three-layer Clos network whose pods of 3,072 GPUs are joined at 1:7 oversubscription, so traffic that crosses pods is seven times scarcer and the layout below keeps the chatty groups inside servers and pods (Interconnects and scaling owns RoCE, Clos fabrics and collectives).

The cluster, storage and network in detail

The cluster (§3.3.1). Llama 1 and 2 trained on Meta's AI Research SuperCluster; Llama 3 moved to Meta's production clusters for "production-grade reliability". The 405B used up to 16K H100 GPUs (700 W, 80 GB HBM3) in Grand Teton servers of eight GPUs and two CPUs, NVLink inside each server, scheduled by MAST, Meta's global training scheduler. Storage is Tectonic, Meta's distributed file system: 240 PB on 7,500 SSD servers, 2 TB/s sustained and 7 TB/s peak, sized for bursty checkpoint writes of 1 MB to 4 GB per GPU.

The network. The 405B ran on RDMA over Converged Ethernet (RoCE) with Arista 7800 and Minipack2 switches; the smaller models used Nvidia Quantum2 InfiniBand; both at 400 Gbps between GPUs, tuned to equal performance. The RoCE cluster is a three-layer Clos network of 24K GPUs (Llama 3 used up to 16K): 16 GPUs per rack under one top-of-rack switch, 192 racks per pod of 3,072 GPUs at full bisection bandwidth, and eight pods joined by aggregation switches at 1:7 oversubscription. So traffic that crosses pods is seven times scarcer, and the parallelism layout and the scheduler are topology-aware. Two fixes replace classic congestion control: the collective library opens 16 flows between each GPU pair, which Enhanced-ECMP hashes across paths, and deep-buffer spine switches absorb bursts. The cluster runs without DCQCN.

4D parallelism (§3.3.2, Figure 5). Four ways of splitting the job compose on one device mesh, ordered from the most to the least bandwidth-hungry; what each form splits and sends is taught on Distributed training, and here is where Llama 3 put each:

1 · Tensor (TP = 8)

Communicates inside every layer, so it stays inside one 8-GPU NVLink server (Megatron-LM).

2 · Context (CP = 1 or 16)

Only in the long-context stage. Each rank holds 2 of 2×CP chunks (the i-th and the (2×CP − 1 − i)-th) to balance the causal mask.

3 · Pipeline (PP = 16)

The 126 layers in 16 stages; only point-to-point traffic between neighbouring stages.

4 · Data, as FSDP (DP = 8 to 128)

Optimiser state and gradients sharded (ZeRO). Weights are not resharded after the forward pass, saving an all-gather in the backward. Outermost because prefetching weights and reducing gradients asynchronously hides long latencies.

The three configurations of the run reach 38% to 43% BF16 model FLOPs utilisation (Table 4):

GPUsTPCPPPDPSeq. len.Batch/DPTokens/batchTFLOPs/GPUMFU

Every row multiplies out: TP × CP × PP × DP is the GPU count and DP × batch × sequence length is 16.8M tokens (224); the middle row's printed 41% MFU recomputes as 40.4%, and v1's DP = 4 in the 128K row was corrected to 8 in v3 (the tables tab has the check). MFU dropped from 43% to 41% going from 8K to 16K GPUs because keeping 16M tokens per batch halves the batch per data-parallel group.

Engineering details that made it work:

  • A tunable pipeline schedule (Figure 6). Existing schedules forced the micro-batch count per GPU to divide by the number of stages: depth-first needs N = PP contiguous micro-batches per stage, breadth-first needs N = M, all of them. Meta made N a free knob between the two, to run fewer micro-batches than stages when batch size is capped at scale, or more to hide communication. It uses an interleaved schedule with V stages per rank, so the bubble is (PP − 1) / (V × M) (interleaved 1F1B, explained on Distributed training). Result: 8K-token pre-training without activation checkpointing.
    The other schedule changes
    One Transformer layer is removed from the first and last stages to balance the embedding and the output-and-loss work; point-to-point traffic is sent asynchronously; tensors are freed as soon as profiling shows they are dead.
    The 16K-GPU tab animates the schedules.
  • Context parallelism by all-gather, not the usual ring that overlaps communication with compute: gather all keys and values, then compute attention for the local queries. The gather sits on the critical path but is cheap, because with 8 key-value heads against 128 query heads K and V are 1/16 the size of Q, and attention costs O(S2) against the gather's O(S). It also handles the document mask easily.
  • Topology-aware placement: the order [TP, CP, PP, DP] keeps the chattiest groups within a server and only FSDP across the multi-hop network. A memory estimator and a performance-projection tool chose the configurations.
Numerics and NCCLX
  • Numerics: comparing training loss across parallelism setups exposed several numerical issues; gradients are accumulated over micro-batches in FP32 and reduce-scattered across data-parallel workers in FP32, as are gradients of tensors reused in the forward pass (such as vision encoder outputs).
  • NCCLX (§3.3.3), Meta's fork of Nvidia's NCCL, retuned chunking and data transfer for latencies of tens of microseconds across the cluster and lets small control messages jump the queue in deep-buffer switches.

The device mesh, rank by rank, and where each group lands in the racks and pods is in the 16K-GPU tab; the Meta lab page shows the three Table 4 meshes at a glance, and Distributed PyTorch covers FSDP and DTensor in general.

Keeping it running

§3.3.4, Table 5

Synchronous training is fragile: one failed GPU can stop the whole job. Over a 54-day snapshot of 405B pre-training there were 466 interruptions: 47 planned (automated firmware and kernel upgrades, operator changes to configuration or data) and 419 unexpected. About 78% of the unexpected ones were confirmed or suspected hardware: GPU or host failures, silent data corruption, unplanned host maintenance. Which rows of Table 5 make up that 78% is not stated: GPU, host and unplanned maintenance alone give 76.6% of the 419, adding the network switches and cables gives 85.0%, so the grouping is unconfirmed; GPUs alone, 268 of 419 (64.0%), are the largest single source. Automated maintenance alone caused at least one interruption a day. Yet the job kept "higher than 90% effective training time" (useful training time over elapsed time), and only three incidents needed significant manual intervention (§3.3.4).

419 unexpected interruptions in 54 days: how often did the 405B job stop on its own?
The tooling that kept effective time above 90%: start-up, flight recorder, NCCLX, stragglers

The tooling that kept effective time above 90%:

  • Faster job start-up and checkpointing, and tools for quick diagnosis.
  • PyTorch's NCCL flight recorder, which keeps collective metadata and stack traces in a ring buffer and dumps it on watchdog or heartbeat timeouts; heavier tracing can be switched on live through online configuration changes, without a code release or a restart.
  • NCCLX co-designed with PyTorch so failures are detected and localised fast. NVLink failures show up as stalled loads and stores inside CUDA kernels with no error code; the library watches its own state, times out on a stall, and snapshots finished and pending transfers across ranks.
  • Straggler detection: a still-working but slow GPU can slow thousands of others; ranking suspicious communications in selected process groups usually found it among a few top suspects.

Two physical effects: throughput varied 1% to 2% with the time of day, because midday heat changes the GPUs' dynamic voltage and frequency scaling; and tens of thousands of GPUs idling or resuming together (waiting on a checkpoint or a collective, or the job starting or stopping) swing the data centre's power draw by tens of megawatts, "stretching the limits of the power grid" (Power, cooling and reliability owns power swings and fleet failure rates).

Bars are the counts printed in Table 5. The counts add up to 419 but the percentages to 94.9%: the "Faulty GPU" row prints 148 interruptions and 30.1%, and 148 of 419 is 35.3%, so by count GPUs caused 268 of 419 unexpected stops, 64.0%, not the text's "58.7%" (the tables tab checks every row).

The 405B recipe

§3.4

Three stages; the 8B and 70B used similar recipes (§3.4):

  1. Initial pre-training: AdamW, peak learning rate 8 × 10−5, 8,000 warm-up steps, cosine decay to 8 × 10−7 over 1,200,000 steps. The batch starts small for stability and grows for efficiency: 4M tokens of 4,096-token sequences, doubled to 8M tokens of 8,192-token sequences after 252M tokens, doubled again to 16M after 2.87T tokens. "Very stable": few loss spikes and no interventions for divergence.
  2. Long-context pre-training: not earlier, because self-attention cost grows quadratically with length. Context grows from 8K to 128K in six stages over about 800B tokens, each stage ending only when short-context evaluations have fully recovered and needle-in-a-haystack retrieval is perfect up to that length.
  3. Annealing: over the final 40M tokens the learning rate falls linearly to 0 at 128K context, with very high-quality sources upsampled; the released base model is the Polyak average of checkpoints taken during annealing.
Steps and whole-run utilisation, derived

Steps come from dividing each phase's tokens by its batch (taking M as 220, which makes Table 4's 16M exactly 224): 60, then 342,101, then 758,767, about 1.10 million steps for 15.6T tokens, so the cosine's 1.2 million-step horizon is slightly longer than the run and the learning rate never reaches 8 × 10−7 before annealing takes over (derived; the paper gives no step count for the end of the run, nor how the long-context and annealing tokens sit inside the 15.6T). The model card puts the 405B at 30.84M H100 hours: 3.8 × 1025 FLOPs over that time is TFLOP/s per GPU, of peak; restarts, checkpoints, the long-context stage and any work not in the final run all count (model card; MFU accounting is on Performance math). On 16,384 GPUs those hours are days.

The 405B run: learning rate and batch size against tokens seen

Drawn from the numbers above; the shaded band is the last 800B tokens of long-context training, and the final 40M tokens of annealing are too short to see on this scale. Over the whole run the 405B averaged of peak, below Table 4's 38% to 43%, because restarts, checkpoints and the long-context stage all count.

Post-training: six rounds of reward model, rejection sampling, SFT and DPO

§4.1, Figure 7

Each round trains on top of the pre-trained checkpoint (§4.1). Fig. 2 runs one prompt through a round, and through the PPO-based pipeline Llama 3 moved away from; the difference is where generation happens and how many networks are held while the weights change.

Fig. 2, step by step: one prompt, one round

  1. A prompt from human annotation. Each round starts from prompts collected during human annotation (§4.2.1). The same prompts feed rejection sampling for SFT and, with pairs of responses from two different models, the preference data.
  2. Sample K responses offline. For each human-annotation prompt, sample K = 10 to 30 responses from the best recent checkpoint (or the best for a capability); 20 are drawn here. This is batch inference outside any training loop: PagedAttention shares the prompt's KV cache pages across all K outputs and admits a request only when memory for a maximum output length is free (avoiding swap-outs): together, over 2× the throughput (§4.2.2).
  3. The reward model scores every response. The reward model is trained on all human preference data so far, using Llama 2's objective without its margin term (the gains faded as data grew); annotators rank edited > chosen > rejected responses (§4.1.2). The bar heights are illustrative draws, not the paper's data.
  4. Keep only the best: rejection sampling. The response the reward model scores highest is kept and the other K − 1 are discarded. Later rounds add system prompts to steer tone, style and format.
  5. Supervised finetuning on the rejection-sampled responses plus synthetic and a little human-curated data (the column is Table 7's mix of SFT examples): cross-entropy on target tokens with prompt tokens masked, learning rate 10−5 for 8.5K to 9K steps for the largest models (§4.1.3).
  6. Direct Preference Optimization (DPO; the loss and its family are on Alignment) on the latest preference batches only (the column is Table 6's mix of comparisons), collected with the previous round's best models, so the data is close to the policy being trained; learning rate 10−5, β = 0.1. Two changes: special formatting tokens (headers, end-of-turn) are masked out of the loss in both responses, since they caused tail repetition and abrupt termination; and a negative log-likelihood term with coefficient 0.2 on the chosen response keeps formatting and stops its probability falling. Meta "explored on-policy algorithms such as PPO, but found that DPO required less compute for large-scale models and performed better, especially on instruction following benchmarks like IFEval" (§4.1.4).
  7. Model averaging of runs with different data or hyperparameters at each of the RM, SFT and DPO stages (§4.1.5).
  8. Round done. Then a new round: fresh preference annotations and SFT data, sampled from the latest models, six times in all (§4.1.6). The averaged model samples the next round's responses and is one of the models annotators compare.

The Llama 3 steps follow §4.1 and §4.2; the PPO steps follow InstructGPT (Llama 2 combined rejection sampling with PPO in later rounds; Llama 2, §3.2.3). Counters are per prompt and illustrative of structure, not measured costs: "networks held" counts the networks resident while weights change. How a reward model learns from a ranking, and one PPO step model by model, are drawn on Alignment (sections 3 and 4).

How the preference data is collected
Annotators compare two responses from two different models (trained with different data mixes and recipes, for diversity), rate the strength of preference on four levels, then may edit the chosen response or prompt the model to improve it, giving rankings of edited > chosen > rejected. Only "significantly better" and "better" pairs are used. Two or three ranked responses share one training row, shuffled, which trains faster with no loss of accuracy.

A new multi-message chat format with header and termination tokens marks each message's source and destination (user, ipython) so one assistant turn can contain several messages, such as a tool call and the answer after it (§4.1.1).

Why would an end-of-turn token present in both the chosen and the rejected response hurt DPO?

Post-training data

The data (§4.2, Tables 6 and 7). Preference data and SFT data cover overlapping domains but are curated differently. Compared with Llama 2, prompts and responses got longer, and prompts got harder each round where the model lagged. The bars beside this section show both mixes, by examples and by tokens. Mostly model-generated, the SFT data is heavily cleaned:

Five quality-control passes: cleaning, topics, quality, difficulty, semantic de-duplication
  • Rule-based cleaning of patterns that crept in early, such as excessive emojis or exclamation marks, and rebalancing of over-apologetic phrases ("I'm sorry", "I apologize").
  • Topic classification by a finetuned Llama 3 8B into coarse buckets ("mathematical reasoning") and fine ones ("geometry and trigonometry").
  • Quality scoring two ways: top quartile of reward-model scores, or the maximum on a Llama 3 rating (three points for general English: accuracy, instruction following, tone; two for code: bug identification, user intention). The two disagree often; keeping examples that either marks as high quality gave the best recall.
  • Difficulty scoring by Instag intention tagging with Llama 3 70B (more intentions, more complex) and a three-point Llama 3 difficulty rating.
  • Semantic de-duplication: cluster dialogs with RoBERTa, sort each cluster by quality × difficulty, and greedily keep an example only if its cosine similarity to those already kept stays under a threshold.

Capabilities, one recipe each

§4.3

Each capability got its own data machinery (§4.3); open any for the recipe.

Code: a code expert, and 2.7M synthetic examples checked by execution (§4.3.1)
A code expert: the main run branched and continued on 1T tokens of over 85% code (CodeLlama-style), long-context finetuned to 16K on repository-level data, then post-trained for code; it collected human annotations and did rejection sampling for coding prompts. Over 2.7M synthetic SFT examples from three methods. (1) Execution feedback, about 1M dialogs: generate problems from random code snippets, solve them with comments explaining the reasoning, check with parser, linter and model-written unit tests in containers, and feed errors back for revision; only dialogs passing every check are kept, and about 20% of solutions were wrong at first and self-corrected. Training the 405B on its own unchecked outputs did not help and could hurt. (2) Translation from common to rare languages (Python to PHP, say), checked by parsing, compiling and running; it improves MultiPL-E markedly. (3) Backtranslation, about 1.2M dialogs for explanation and documentation: generate docs from code, regenerate code from the docs, and keep the most faithful. Ten priority languages, from Python, Java and JavaScript to Rust, SQL and shell. Code-specific system prompts during rejection sampling improve readability and comments, and a two-point model-as-judge (correctness, style) filters rejection-sampled code, with the hardest examples revised rather than dropped, since dropping them hurt benchmarks.
Multilingual: a multilingual expert, and almost no machine translation (§4.3.2)
A multilingual expert branched from pre-training and continued on 90% multilingual tokens, used to collect better non-English annotations until pre-training finished. SFT data for German, French, Italian, Portuguese, Hindi, Spanish and Thai: 2.4% human annotations, 44.2% other NLP tasks rewritten as dialogs (exams-qa, Conic10k, GlobalVoices and Wikimedia parallel text, filtered by language ID and Blaser 2.0), 18.8% rejection-sampled, 34.6% translated reasoning data. Temperature for multilingual rejection sampling was drawn from 0.2 to 1 early and fixed at 0.6 in the last round, to limit code-switching; responses must match the prompt's script (romanised Hindi gets romanised Hindi). Machine translation is otherwise avoided, to prevent translationese and name, gender and cultural bias; the exception, translated synthetic maths, gave strong MGSM gains.
Maths and reasoning: stepwise reward models and tree search to filter reasoning traces (§4.3.3)
Five problems (too few hard prompts, no ground-truth chains of thought, wrong intermediate steps, no tool use, training unlike inference) and five fixes: maths pre-training data turned into question-answer pairs plus human prompts for weak skills from a skill taxonomy; step-by-step solutions generated, filtered by correct final answer and self-verified; outcome and stepwise reward models to drop traces with bad steps, and Monte Carlo Tree Search with a stepwise reward model for the hardest prompts; interleaved text and Python with execution as a check; and corrected versions of wrong attempts as training data.
Long context: 0.1% synthetic long data keeps 128K working (§4.3.4)
SFT with only short data caused "significant regressions" at long context, and humans cannot practically annotate 128K-token examples, so the data is synthetic: QA on 8K chunks of long documents with the whole document as context, hierarchical summaries of 8K chunks with global questions about them, and code reasoning in which a file that at least five others import is removed and must be rebuilt. Mixing 0.1% of such data with the short data was best for both (Table 7: 0.11% of examples, but at about 38,000 tokens each, 5.0% of SFT tokens; derived). Short-only DPO did not hurt long context, probably because DPO takes fewer optimizer steps than SFT.
Tool use: search, Python and Wolfram Alpha, annotated message by message (§4.3.5)
Three built-in tools, Brave Search, a Python interpreter and the Wolfram Alpha API, plus zero-shot calls to unseen functions defined in context. Tools are Python objects; calls run in the interpreter, enabled in the system prompt. Human annotation is per message: annotators pick between two assistant messages in the same context or edit one, then the dialog continues; tool outputs are not ranked. No rejection sampling (no gains on tool benchmarks). Data grows from synthetic single-step trajectories (about 30% filtered out as unexecutable) to multi-step ReAct-style plans and file uploads (.txt to .jsonl), then human annotation of harder multi-turn cases. Zero-shot data mines real functions from The Stack and uses multi-agent synthetic dialogs; easy queries with tools enabled teach the model not to call them.
Factuality: probe what the model knows, train refusals for the rest (§4.3.6)
"Know what it knows": take a snippet of pre-training data, have Llama 3 write a question about it, sample answers, judge correctness against the snippet and informativeness with Llama 3, and for questions answered informatively but wrongly every time, generate a refusal to train on. A small labelled set covers sensitive topics where the pre-training data itself is often wrong.
Steerability: system-prompt adherence as preference data (§4.3.7)
Annotators write system prompts (length, format, tone, persona; the paper's example is a meal planner for a family of seven) and judge whether the model keeps to them across a conversation; the preferences feed the reward model, rejection sampling, SFT and DPO.

Results

§5, Table 2, Figure 17

The headline (Table 2). The instruction-tuned 405B scores MMLU 87.3 (5-shot) and 88.6 (0-shot with chain of thought), MMLU-Pro 73.3, IFEval 88.6, HumanEval 89.0, GSM8K 96.8, MATH 73.8, ARC Challenge 96.9, GPQA 51.1, MGSM 91.6, BFCL 88.5 and Nexus 58.7: level with GPT-4 (0125), and close to GPT-4o and Claude 3.5 Sonnet, behind them on GPQA (59.4 for Claude), MMLU-Pro and some coding. The 70B (MMLU 86.0 with CoT, HumanEval 80.5, GSM8K 95.1) and 8B lead their size classes against Gemma 2 9B, Mistral 7B, Mixtral 8x22B and GPT-3.5 Turbo on most rows. The tables tab adds 95% confidence intervals: many of the gaps at the top are smaller than the noise.

How the comparisons were made. For other models Meta reports "the best score across results that are publicly reported or (where possible) that we reproduced ourselves", choosing the reported number when its settings are comparable or more conservative (§5.1, §5.2). Pre-trained results carry 95% confidence intervals, CI = 1.96 √(S(1 − S)/N), which the paper notes are a lower bound on the real variation (§5.1.1). The pre-trained 405B "substantially outperforms prior open-source models" and is competitive with GPT-4 where comparable numbers exist (ARC-C 96.1 against 96.3, GSM8K 89.0 against 92.0; Table 12).

Robustness and contamination (§5.1.2 to §5.1.4)

Robustness and contamination. Pre-trained models barely move under changes to multiple-choice labels, few-shot label patterns, answer order and prompt wording on MMLU, the 405B least (§5.1.2). Adversarial versions of SQuAD and GSM8K score well below the originals, while paraphrase detection (PAWS) does not suffer (§5.1.3). An 8-gram overlap analysis estimates contamination and its effect per benchmark: high for PiQA and HellaSwag (55% and 85% contaminated, about 8 and 15 points of estimated gain), while Natural Questions' 52% contamination seems to change nothing; for MBPP, HumanEval, MMLU and MMLU-Pro the method flags so much that no gain can be estimated (Table 15, rebuilt in the tables tab).

Other evaluations: exams, long context, tool use

Other evaluations. Proficiency exams (LSAT, SAT, GMAT, GRE, AP): the 405B is "very similar" to Claude 3.5 Sonnet and GPT-4o (Table 17). Long context: perfect single-needle retrieval at all depths and lengths, near-perfect multi-needle, and the best InfiniteBench En.QA and En.MC scores among the models compared, though Meta's own 70B beats the 405B on En.QA, 36.7 against 30.5 (§5.2.6, Table 21). Tool use: best on Nexus, behind Claude 3.5 Sonnet on API-Bank by "only 0.6%" in the text (Table 22 prints 92.3 against 92.6, 0.3), and in human evaluations ahead of GPT-4o on code execution and plots but behind on file uploads (§5.2.7).

Human evaluations (§5.3). About 7,000 prompts over six single-turn capabilities (English, reasoning, coding, Hindi, Spanish, Portuguese) and three multi-turn ones, 10% easy, 30% medium, 60% hard, kept from the modelling teams. Annotators compare two responses on a 7-point scale; "better" or "much better" counts as a win. The paper's summary: on par with GPT-4 (0125), "mixed results" against GPT-4o and Claude 3.5 Sonnet, and "the best-performing openly available model".

Meta's own human evaluation pits the 405B against GPT-4o on seven capabilities. On how many does it win more often than it loses, with 95% intervals that do not overlap?
Inference: two servers in BF16, one with FP8 (§6)

Inference (§6). In BF16 the 405B does not fit on one 8-GPU H100 server, so it runs on two: tensor parallel inside each, pipeline parallel across, with micro-batching improving the throughput-latency trade-off. FP8 (released) quantises most feed-forward weights and activations, about 50% of inference compute, but not self-attention or the first and last layers; it uses row-wise scaling, caps dynamic scale factors at 1200 because high-perplexity tokens such as dates otherwise cause underflows and corrupted answers, and was validated on the distribution of reward-model scores over 100,000 responses because benchmarks hid the damage. FP8 gains up to 50% pre-fill throughput.

Safety: violation against false refusal, Llama Guard 3, uplift studies (§5.4)

Safety (§5.4). Internal benchmarks of over 4,000 prompts per capability or language measure violation rate against false refusal rate. Safety data is mostly human-written, with adversarial and borderline prompts; smaller models need a larger share of safety data. Verbatim memorisation of training data by the 405B averages 1.13% for 50-gram and 3.91% for 1,000-gram prompts. Llama Guard 3 is released as an input and output classifier. Uplift studies with volunteers found "insignificant uplift" for cyberattacks and "no significant uplift" for chemical and biological weapons planning over web access alone (§5.4.5), and long-context mitigations hold up to 256-shot jailbreaks. The competitor numbers are internal and anonymised, so not reproducible.

Images, video and speech: composed adapters, not released with the paper (§7, §8)

Images, video and speech (§7, §8). Composed onto the language model rather than trained jointly: an image encoder joined by cross-attention adapter layers trained on image-text pairs with the language model frozen, a video adapter on top, and a speech encoder (pre-trained on about 15M hours) with an adapter that emits token representations, plus a streaming text-to-speech system. The paper calls them competitive with the state of the art and "not yet being broadly released". Beyond the paper: two months later Meta released the vision models as Llama 3.2 11B and 90B, built the same way, with adapter weights of cross-attention layers (Llama 3.2 announcement, 25 September 2024).

Why it matters (beyond the paper)

It was the first open-weights model credibly at GPT-4 level, and the report is still among the most detailed public accounts of a frontier-scale run: the failure taxonomy of a 16K-GPU job, the MFU per configuration, the 4D layout, the batch and context schedules, the annealing recipe. The Meta lab page calls it "the field's most complete public account of how a frontier model is trained".

  • Post-training. SFT followed by DPO rather than PPO was, in Raschka's words that summer, "the most popular preference tuning strategy at the moment due to the ease of use"; his comparison sets Llama 3.1's iterated rejection sampling, SFT and DPO beside the Qwen 2, Gemma 2 and Apple recipes (Raschka, August 2024).
  • Annealing as a final quality step and as a cheap test of a dataset's value, and scaling laws aimed at downstream accuracy rather than loss.
  • "Managing complexity" defined one pole of the design space. DeepSeek-V3, five months later, took the other: mixture of experts, FP8 training and multi-token prediction (DeepSeek-V3 paper, DeepSeek lab page).
Later, as of 25 October 2026
  • Training stacks. PyTorch's torchtitan trains Llama 3.1 8B, 70B and 405B with FSDP2, tensor, pipeline and context parallelism (torchtitan).
  • Meta itself moved to mixture of experts with Llama 4 in April 2025 (Meta lab page).

Connections

How much of this to believe

What holds up.

  • The engineering record is specific enough to check, and it checks: every Table 4 row multiplies out to its GPU count and to 224 tokens per batch, the recounted architecture gives 405.85B parameters, and 6ND reproduces the 3.8 × 1025 FLOPs. The model card's 30.84M GPU hours imply 34.6% of peak over the whole run, consistent with 38% to 43% MFU while running and the reported downtime.
  • The scaling-law forecast reproduces from the paper's own figures: refitting the IsoFLOPs parabolas recovers the drawn minima within 0.25%, and the refit power law gives 16.55T tokens and 403B parameters at 4.0 × 1025 FLOPs. The ARC forecast's two stages refit to the drawn lines, and the 405B landed where predicted (96.0% against 95.8%).
  • The models are public. Weights for all six models are downloadable, so anyone can re-run the benchmarks, and the paper releases its evaluation outputs on Hugging Face (§5.1). Pre-trained results come with confidence intervals, a contamination analysis and robustness tests, more than most model reports offer.
  • The authors state limits themselves, which counts in their favour: the CIs are lower bounds; 8-gram contamination detection fails on HumanEval, MBPP and MMLU; benchmarks hid FP8 damage that reward-model score distributions exposed; human evaluation can reflect annotator bias; and the internal safety numbers are not reproducible externally.

What to discount.

  • Not like for like. Competitors' scores are "the best score across results that are publicly reported or (where possible) that we reproduced ourselves", while Llama's are Meta's own runs; Table 2 also mixes settings (Gemma 2's MMLU CoT entry is 5-shot without CoT, Nemotron's and Claude's GSM8K are zero-shot) (§5.1, Table 2 notes).
  • Gaps inside the noise. HumanEval has 164 problems, so 89.0 carries ±4.8 points (Table 18): the 405B, GPT-4o (90.2) and Claude 3.5 Sonnet (92.0) are indistinguishable. ZeroSCROLLS/QuALITY's ±9.1 at 95.2 implies about 21 questions. MMLU's 14,042 questions, by contrast, separate gaps of a point. The tables tab marks every Table 2 gap against its interval.
  • The summary of the human evaluation is kinder than its figure. Against GPT-4o the 405B wins none of the seven capabilities, ties single-turn English and loses six with separated intervals, including multi-turn English; "mixed results (some wins and some losses)" overstates it (Figure 17). Against GPT-4 (0125) it is roughly level, as claimed: one clear win (multi-turn coding), four ties, two losses (reasoning and multilingual).
  • Single runs, internal benchmarks. No result has seeds; DPO-over-PPO, the 0.1% long-context mix and the annealing gains are reported as findings without the ablation numbers. Safety comparisons use internal benchmarks and anonymised rivals.
  • Not described: the released 3.1 configs use a "llama3" RoPE scaling (factor 8 from an original 8,192 positions) that the paper does not mention (config.json in the Hugging Face release); the training code is not released.
Six small inconsistencies, none large
  • Small inconsistencies, none large: the text's (α, A) = (0.53, 0.29) are rounded so far that they give 10.5T, not 16.55T; the forecast reproduces at 4.0 × 1025, not the 3.8 × 1025 named; Table 5's faulty-GPU row is 148 interruptions but 30.1% (148/419 is 35.3%), so "GPU issues 58.7%" should be 64.0%; v1's Table 4 had DP = 4 in the 128K row (fixed in v3); the 41% MFU row recomputes as 40.4%; the text puts the API-Bank gap to Claude at 0.6 points where Table 22 shows 0.3.

Verdict. Believe the engineering: the infrastructure numbers, the failure log, the recipe and the scaling-law method are internally consistent, reproducible from the paper's own figures, and unmatched in detail. Believe that the 405B was the first open model in GPT-4's class. Treat the head-to-head rankings against GPT-4o and Claude 3.5 Sonnet as approximate: the benchmark gaps are often inside the noise, comparisons mix self-run and reported numbers, and Meta's own human evaluation puts the 405B behind GPT-4o.

What it takes to use this

  • Weights and licence. All six models are downloadable under the Llama 3.1 Community License: commercial use is allowed, including using outputs to improve other models, but a licensee whose products had over 700 million monthly active users on the release date must ask Meta for a licence (licence). Eight languages are supported; the image, video and speech models of the paper were not released with it.
  • Serving the 405B. BF16 weights alone are 812 GB (405.85B × 2 bytes; derived), more than one 8 × 80 GB H100 server holds, hence the paper's two-server setup; FP8 on the feed-forward layers brings it to one server (§6). At 128K context the BF16 KV cache adds about 63 GiB per sequence (504 KiB per token, derived). The 70B fits a single server in BF16; the 8B fits one GPU.
  • Reproducing the recipe. The training code is not public; torchtitan is the closest open stack. The 405B took 30.84M H100 hours and the whole family 39.3M (model card). The post-training loop needs a reward model, a fast sampler (vLLM-style paged KV cache) and DPO; it is within reach at small scale with open libraries, and the expensive part is the six rounds of human preference data.
  • When the lessons pay off. Annealing as a data test, IsoFLOPs sizing and the NLL-to-accuracy forecast work at any budget. The 4D layout and the reliability tooling matter only from thousands of GPUs, where interruptions every few hours make checkpointing and restart time the dominant cost.