Paper notes

The Llama 3 Herd of Models: data, scale and the engineering recipe of a 405B dense model

Meta's Llama 3 paper (2024) gives the full recipe for three dense Transformers (8B, 70B, 405B): 15T tokens of pre-training, 128K context, 4D parallelism on 16K H100s, and six rounds of SFT, rejection sampling and DPO. This post recomputes its tables and flags numbers that do not add up.

Published Updated 50 min read

On this page
  1. Why this paper is worth reading
  2. Background: from Llama 2 to Llama 3.1
  3. Core idea: three levers and “don’t get fancy”
  4. Method
  5. Architecture: almost the same as Llama 2
  6. Pre-training data: cleaning, deduplication and mixing
  7. Scaling laws: how 405B was chosen
  8. Infrastructure and parallelism: how to cut 16K GPUs
  9. Reliability: 466 interruptions in 54 days
  10. Training recipe: three stages
  11. Post-training: six rounds of SFT and DPO
  12. Inference: two machines, or FP8
  13. Safety and multimodality: two side lines
  14. Experiments and conclusions
  15. Hands-on check: parameter counts, parallel configs, scaling-law extrapolation, KV cache and failure statistics
  16. Parameter counts: Table 3 reproduces all three model sizes exactly
  17. Parallel configs: Table 4 is self-consistent, and 41% is a rounding effect
  18. Scaling law: the extrapolation is extremely sensitive to the third decimal of the exponent
  19. KV cache: GQA makes 128K feasible, but single-machine concurrency is limited
  20. GPU hours: the model card and the paper roughly agree
  21. Failure statistics: the first row of Table 5 does not add up, and “about 78%” cannot be reproduced
  22. Tables 6 and 7: the weighted averages match, and the extra 1.0 is rounding
  23. RoPE frequency scaling: in the released code, not in the paper
  24. An order-of-magnitude comparison with DeepSeek-V3
  25. Limitations and what came after
  26. What to take away from this paper
  27. Further reading
  28. FAQ

The Llama 3 paper (The Llama 3 Herd of Models, Meta) describes in unusual detail how one open-weights flagship model goes from data to deployment: three dense Transformers of 8B, 70B and 405B parameters, a pre-training corpus of about 15T tokens, and a context of up to 128K. The 405B model was trained with 3.8×10253.8\times10^{25} FLOPs on up to 16,384 H100s, and post-training is six rounds of SFT, rejection sampling and DPO. The paper credits three levers, data, scale and “managing complexity”, and wherever it could, it chose the conservative option: dense rather than mixture of experts (MoE), DPO rather than PPO.

The paper is dated July 23, 2024, and was first submitted to arXiv on July 31, 2024. This post follows the text of v3 (November 23, 2024), and all its results are for the Llama 3.1 models. I recomputed every number in it that can be recomputed: parameter counts, parallel configs, the scaling-law extrapolation, the KV cache, failure statistics and the data tables. Several numbers in the paper disagree with each other, and they are collected in the “Hands-on check” section. The external numbers quoted here (parameter totals on Hugging Face, GPU hours in the Llama 3.1 model card) were read in November 2026.

Why this paper is worth reading

  • It writes up a dense flagship recipe in great detail. Data cleaning, scaling laws, 4D parallelism, failure statistics, every step of post-training and the inference optimizations come with concrete numbers, not a one-line “we used high-quality data”.
  • It shows an engineering philosophy of “don’t get fancy”. Dense instead of MoE and DPO instead of PPO buy stability: in 54 days there were 419 unexpected interruptions and only three needed significant manual intervention.
  • It turns “data and scale matter more than architecture” into a fact. The architecture is almost the same as Llama 2’s; the paper says the gains come mainly from data quality and diversity and from training scale.
  • It rewards reading with a calculator. Most numbers in its tables can be derived from other numbers (parameter counts, MFU, failure shares, weighted averages); doing the arithmetic deepens understanding and also exposes a few that do not match.

Background: from Llama 2 to Llama 3.1

For how Llama 1 and Llama 2 worked, see this site’s Llama explainer. The Llama 3 paper says Llama 2’s corpus was 1.8T tokens (the Llama 2 paper itself says 2T, and the check below computes both), Llama 3’s is about 15T, and the flagship’s training compute is “almost 50×” that of the largest Llama 2. The release came in two steps: 8B and 70B in April 2024, then Llama 3.1 in July, which added the 405B; all three sizes support a 128K context and multiple languages, and the instruction-tuned versions also support tool use (Table 1 of the paper). All the results in the paper are for the 3.1 versions.

One warning on how to read it: the paper has 92 pages, the first 54 are about the text models, and sections 7 and 8 are “compositional” experiments with images, video and speech, which the paper says are still under development and not broadly released. This post covers only the text models.

Core idea: three levers and “don’t get fancy”

The paper boils the development of a high-quality foundation model down to three levers: data (the pre-training corpus grows from 1.8T to about 15T tokens, with better cleaning and quality control of post-training data), scale (3.8×10²⁵ FLOPs, 405B parameters) and managing complexity (choosing the simplest scalable option). At each key point it took the side that is less likely to go wrong:

DecisionThe paper’s choiceNot chosenReason given
ArchitectureDense Transformer, small changesMoEMaximize training stability
AlignmentSFT, rejection sampling, DPOPPO and other online RLThe latter “tend to be less stable and harder to scale”; DPO is cheaper for large models and follows instructions better
Flagship size405BOther sizesRoughly the compute-optimal point of the scaling law; IsoFLOPs curves are flat near the optimum
Small modelsFar more tokens than compute-optimalCompute-optimalBetter at the same inference budget; the flagship also improves them in post-training
AttentionGQA (8 KV heads) plus a document maskMulti-head attentionInference speed and KV cache; the document mask matters for continued pre-training on very long sequences

Method

Architecture: almost the same as Llama 2

Item8B70B405B
Layers3280126
Model dimension4,0968,19216,384
FFN dimension14,33628,67253,248
Attention / KV heads32 / 864 / 8128 / 8
Peak learning rate3×10⁻⁴1.5×10⁻⁴8×10⁻⁵

All three sizes use SwiGLU, a vocabulary of about 128K and a RoPE base frequency of θ=500,000\theta=500{,}000 (Table 3); by the configuration on Hugging Face the normalization is still RMSNorm. The changes relative to Llama 2 are few:

  • GQA with 8 KV heads, to speed up inference and shrink the KV cache at decoding time (see the GQA explainer for the idea).
  • A document mask: when several documents are packed into one training sequence, self-attention between different documents is blocked. The paper says this has limited impact in standard pre-training but is important in continued pre-training on very long sequences.
  • A 128K vocabulary: 100K tokens from tiktoken plus 28K tokens added for non-English languages. On a sample of English text the compression rate improves from 3.17 characters per token with the Llama 2 tokenizer to 3.94, so the same training compute “reads” more text; the extra 28K tokens did not affect English tokenization.
  • The RoPE base raised to 500,000, to support longer contexts; the paper cites the result of Xiong et al. that this value works for contexts of up to 32,768 (see the RoFormer explainer for how RoPE works).

In the paper’s own words, the performance gains come mainly from data quality and diversity and from training scale, not from the architecture.

Pre-training data: cleaning, deduplication and mixing

The corpus comes from many sources with knowledge up to the end of 2023, and before pre-training, domains with large amounts of personally identifiable information (PII) and known adult content are removed. Web data goes through four steps:

  • Text extraction: a custom HTML parser tuned for removing boilerplate while keeping content, which preserves the structure of math and code pages and the alt text of images (math often appears as an image with alt text). Experiments showed markdown markers hurt a model trained mainly on web data, so all markdown markers were removed.
  • Three levels of deduplication: URL level (keep the most recent version of each URL), document level (global MinHash to remove near-duplicates) and line level (as in ccNet; in each bucket of 30M documents, lines that appear more than 6 times are removed). The paper admits that manual inspection shows line-level deduplication also removes frequent high-quality text, but the empirical evaluation showed strong improvements.
  • Heuristic filtering: duplicated n-gram coverage (to drop repetitive content such as logs and error messages), “dirty word” counting (to filter adult sites the domain block lists miss) and the KL divergence of the token distribution (to drop documents with many outlier tokens).
  • Model-based quality filtering: a fastText classifier (does the text look like something Wikipedia would cite) and a DistilRoBERTa classifier trained on Llama 2 annotations; code and math-reasoning pages have their own pipelines, and multilingual data uses fastText to identify 176 languages, with per-language deduplication and filtering.

For the mix, the paper uses two tools: a knowledge classifier (to downsample categories over-represented on the web, such as arts and entertainment) and “scaling-law experiments” (train a batch of small models on a mix, predict how a large model would do on it, repeat to choose a candidate mix, then train a larger model on it to check). The final mix is roughly 50% general knowledge, 25% math and reasoning, 17% code and 8% multilingual tokens.

Annealing data is another interesting point: at the end of training, high-quality code and math data are upsampled. The paper annealed on the GSM8K and MATH training sets, which improved the 8B model by 24.0% and 6.4% on the validation sets of the two, while the gain for the 405B was negligible; the paper’s explanation is that the flagship has strong in-context learning and reasoning and needs no in-domain training samples. It also uses annealing as a cheap way to judge the value of small datasets: for a half-trained 8B model, anneal the learning rate linearly to 0 on 40B tokens with 30% weight on the new dataset and 70% on the default mix, which is cheaper than running scaling-law experiments for every small dataset.

Scaling laws: how 405B was chosen

The paper uses a two-step method, which both fixes the best size and predicts downstream benchmark scores. The first step is IsoFLOPs experiments: for compute budgets from 6×10186\times10^{18} to 102210^{22} FLOPs, it trains a batch of models of 40M to 16B parameters at each budget, fits the validation loss at each budget with a quadratic polynomial, and takes the minimum of the parabola as the compute-optimal model at that budget. The second step assumes a power law between the optimal number of training tokens and compute:

D⋆(C)=A Cα,(α,A)=(0.53, 0.29)D^\star(C) = A\,C^{\alpha},\qquad (\alpha, A) = (0.53,\ 0.29)

Here CC is the training compute (FLOPs) and D⋆D^\star is the compute-optimal number of training tokens (the paper writes it N⋆(C)N^\star(C); I write D⋆D^\star here to avoid confusion with the parameter count). The paper says that extrapolating this law to 3.8×10253.8\times10^{25} FLOPs suggests a 402B-parameter model on 16.55T tokens. It also observes that the IsoFLOPs curves flatten around the minimum as compute grows, so the flagship’s performance is fairly insensitive to the exact trade-off between model size and tokens, and it settled on 405B. I discuss how far the extrapolation can be trusted in the hands-on check: it is extremely sensitive to the rounding of the coefficients.

The downstream prediction also has two steps: first a linear relation between the normalized negative log-likelihood of the correct answer for compute-optimal models and the training FLOPs, then a sigmoidal relation from negative log-likelihood to accuracy, using the scaling-law models together with the Llama 2 family (trained with more compute). Taking ARC Challenge as the example, the paper says this two-step extrapolation over four orders of magnitude is quite accurate and only slightly underestimates the flagship’s final score.

The paper also notes that the small models are trained far beyond compute-optimal (tokens per parameter for 8B and 70B are in the check below), so that they do better at the same inference budget, which is the “inference budget” view in this site’s scaling laws page.

Infrastructure and parallelism: how to cut 16K GPUs

The 405B used up to 16,384 H100s (700W TDP, 80GB HBM3 each) in Meta’s Grand Teton servers, eight GPUs per server connected by NVLink, with 400 Gbps links between servers. The network is a RoCE-based 24K-GPU cluster (only 16K of which were used): 16 GPUs in a rack share one switch, 192 racks form a pod of 3,072 GPUs with full bisection bandwidth, and eight pods are joined through an aggregation layer with a 1:7 oversubscription ratio, so both the parallelism scheme and the scheduler are topology-aware and try to minimize traffic across pods. For load balancing, the collective library creates 16 network flows between two GPUs and uses an enhanced ECMP hash to spread them over different paths; they did not use traditional congestion control such as DCQCN.

The model is sharded with 4D parallelism: tensor parallelism (TP), context parallelism (CP), pipeline parallelism (PP) and data parallelism (DP, in practice FSDP). The dimensions are ordered [TP, CP, PP, DP], with the one needing the most bandwidth and the lowest latency innermost (confined to one server) and DP outermost, because it can tolerate long network latencies by prefetching weights and reducing gradients asynchronously. The paper gives three configurations (Table 4):

GPUsTP×CP×PP×DPSequence lengthBatch per groupTFLOPs/GPUMFU
8,1928×1×16×648,1923243043%
16,3848×1×16×1288,1921640041%
16,3848×16×16×8131,0721638038%

All three rows have “16M” tokens per batch. A few engineering changes stand out:

  • Pipeline parallelism: existing implementations need the batch to be divisible by the number of pipeline stages, put more memory on the first stage, and make the last stage a bottleneck because it computes the output and loss. The paper makes the number of consecutive micro-batches NN tunable (5 in its example), puts one fewer Transformer layer on each of the first and last stages (the first chunk holds only the embedding, the last only the output projection and loss), and uses an interleaved schedule with asynchronous point-to-point communication. The bubble ratio is (PP−1)/(V⋅M)(PP-1)/(V\cdot M), where VV is the number of virtual stages on one pipeline rank and MM is the total number of micro-batches. With these optimizations, training on 8K sequences needs no activation checkpointing.
  • Context parallelism: the sequence is cut into 2×CP2\times CP chunks, and rank ii takes chunks ii and 2×CP−1−i2\times CP-1-i so that the causal-attention load is balanced. Instead of overlapping communication in a ring, it first all-gathers K and V and then computes attention for the local Q: this supports document masks more flexibly, and because GQA makes K and V much smaller than Q, the exposed all-gather latency is small.
  • Numerical stability: gradient accumulation over micro-batches is in FP32, and so is the reduce-scatter across data-parallel workers in FSDP.
  • The NCCLX communication library: a fork of NCCL that tunes chunking and data transfer for high-latency networks and lets small control messages through with priority.

Reliability: 466 interruptions in 54 days

Over a 54-day snapshot of pre-training the paper counts 466 job interruptions, 47 of them planned (automated maintenance such as firmware upgrades, or operator-initiated configuration and dataset updates) and 419 unexpected. It says about 78% of the unexpected interruptions are attributed to confirmed or suspected hardware issues, with GPU problems the largest category (58.7%), yet significant manual intervention was needed only three times in the period, the rest being handled by automation, and effective training time stayed above 90%. To get there they cut job startup and checkpoint times, built fast diagnosis tools (PyTorch’s built-in NCCL flight recorder records every communication event and its duration), and hunted for stragglers, hardware that still works but slowly: a single straggler can slow thousands of other GPUs. Two environmental effects are worth noting: throughput varied by 1% to 2% over the day (hotter mid-day temperatures affect GPU dynamic frequency scaling), and when tens of thousands of GPUs raise or lower power together, the whole data center’s draw can swing by tens of megawatts instantly. The breakdown of Table 5 and two numbers in it that do not match are in the hands-on check.

Training recipe: three stages

The Llama 3 recipe: three pre-training stages and six post-training rounds Left, pre-training of the 405B model on about 15.6T tokens in three stages: initial pre-training with the sequence length growing from 4K to 8K and the batch size from 4M to 8M to 16M tokens, AdamW and a peak learning rate of 8×10⁻⁵; long-context pre-training in 6 stages that raise the context from 8K to 128K on about 800B tokens; and annealing on the last 40M tokens, with the learning rate decayed linearly to 0 and the checkpoints averaged. Right, post-training: each round runs a reward model, rejection sampling, supervised fine-tuning, DPO and model averaging, for 6 rounds, with preference and SFT data collected anew each round. Pre-training: 405B model, ~15.6T tokens Post-training: five steps per round, 6 rounds 1 Initial pre-training sequence 4K → 8K, batch 4M → 8M → 16M tokens AdamW, peak lr 8×10⁻⁵, cosine to 8×10⁻⁷ 2 Long-context pre-training 6 stages, context 8K → 128K, about 800B tokens advance only when short-context quality has recovered and needle-in-a-haystack is solved 3 Annealing last 40M tokens at 128K, lr decayed linearly to 0 upsample high-quality data, average checkpoints Reward model (RM) ranking edited > chosen > rejected, no margin term Rejection sampling (RS) K = 10–30 samples per prompt, the RM picks the best Supervised fine-tuning (SFT) RS + synthetic + human data, lr 10⁻⁵, 8.5K–9K steps DPO β=0.1, format tokens masked, +0.2×NLL on chosen Model averaging average runs with different data or hyperparameters ×6
Figure: the Llama 3 training pipeline. Left: the three pre-training stages of the 405B model (numbers from Section 3.4 of the paper). Right: the five steps of each post-training round, six rounds in all (Section 4.1 of the paper).
  • Initial pre-training: AdamW with a peak learning rate of 8×10−58\times10^{-5}, 8,000 steps of linear warm-up and cosine decay to 8×10−78\times10^{-7} over 1,200,000 steps. The batch grows from small to large for stability: it starts at 4M tokens (sequence length 4,096), doubles to 8M (sequence 8,192) after 252M tokens, and doubles again to 16M after 2.87T tokens. The paper says the recipe was very stable, with few loss spikes and no interventions to correct divergence. The data mix was also adjusted during training: more non-English data, upsampled math data, more recent web data to advance the knowledge cut-off, and downsampled subsets found later to be of lower quality.
  • Long-context pre-training: in the final stage of pre-training the context is raised from 8K to 128K in six steps, on about 800B tokens in all. Each step trains until the model has adapted: short-context evaluations have fully recovered, and needle-in-a-haystack tasks at that length are solved perfectly. Long sequences are left to the end because self-attention compute grows quadratically with sequence length.
  • Annealing: on the last 40M tokens the learning rate is decayed linearly to 0 at a 128K context, the mix is shifted to upsample high-quality sources, and the checkpoints from the annealing phase are averaged (Polyak averaging) to give the pre-trained model.

Post-training: six rounds of SFT and DPO

The backbone of post-training is a reward model and a language model, and each round goes through the following steps:

  • Chat format: to support tool use, a new multi-message protocol with special header and termination tokens marks the source and destination of each message, so one dialog turn can produce several messages sent to different places (for example the user and ipython).
  • Reward model: trained on top of the pre-trained checkpoint with the same objective as Llama 2 but without the margin term (its benefit diminishes with more data). Besides the (chosen, rejected) pair, annotators produce a third, “edited” response for some prompts, so a sample has two or three responses ranked edited > chosen > rejected. In training, the prompt and several responses go into one row (with the responses randomly shuffled), which the paper’s ablations say is more efficient with no loss in accuracy.
  • Rejection sampling and SFT: for each human-annotated prompt, KK answers (usually 10 to 30) are sampled from the latest chat model and the reward model picks the best; together with synthetic data and a little human-curated data this goes into SFT: standard cross-entropy with the loss on the prompt masked, at a learning rate of 10−510^{-5} for 8,500 to 9,000 steps for the largest models. To make rejection sampling efficient they used PagedAttention (see the vLLM explainer), sharing the prompt’s KV pages across all its outputs and fixing a maximum output length to avoid swap-out, which raised throughput by more than 2×.
  • DPO: it mainly uses the most recent preference data collected with the best models from previous rounds, so the data distribution is closer to the policy being optimized. With β=0.1\beta=0.1 and a learning rate of 10−510^{-5}, it makes two changes: formatting tokens such as headers and terminators are masked out of the loss (otherwise tail repetition or abruptly emitted terminators appear; the paper’s guess is that tokens common to chosen and rejected responses give conflicting goals under the contrastive loss), and an NLL term with coefficient 0.2 is added on the chosen response to keep the generation format and stop the log-probability of chosen answers from falling. The paper says it also tried PPO, but DPO was cheaper for large models and better at instruction following (for example IFEval).
  • Model averaging: at each RM, SFT or DPO stage, the models from experiments with different data versions or hyperparameters are averaged in weight space.
  • Iteration: the methods above are run for six rounds, each collecting fresh preference annotations and SFT data and sampling synthetic data from the latest models.

The preference annotation follows Llama 2: for each prompt, one response is taken from each of two different models, annotators grade the strength of their preference on four levels (significantly better, better, slightly better, marginally better), and there is an extra editing step. For the reward model and DPO, only the samples where the chosen response is “significantly better” or “better” are used, and samples with similar responses are dropped.

The composition of the SFT data (Table 7, the “helpfulness” part) is:

CategoryShare of examplesAvg. turnsTokens per exampleResponse tokens
General English52.66%6.3974.0317.1
Code14.89%2.7753.3374.5
Multilingual3.01%2.7520.5289.7
Exam-like8.14%2.3297.8173.4
Reasoning and tools21.19%3.1661.6301.9
Long context0.11%6.738,135.6740.5
Total100%4.7846.1310.4

Because most of the training data is model-generated, the paper spends a lot of effort on quality control: rule-based removal of bad patterns first (too many emojis and exclamation marks, excessive apologizing, with the proportion of frequent phrases such as “I’m sorry” adjusted); then model-based topic classification (Llama 3 8B fine-tuned as a classifier), quality scoring (a reward-model score in the top quartile, or a perfect Llama-based score; the two disagree a lot, and taking the union gave the best recall) and difficulty scoring (InsTag and Llama-based); finally semantic deduplication (cluster with RoBERTa, sort each cluster by quality score × difficulty score, and greedily keep samples whose maximum cosine similarity to those already kept is below a threshold).

Code is one of the capabilities that received the most effort. They branched the main pre-training run and continued pre-training on 1T tokens of a mix that is more than 85% code to get a code expert, which then collects high-quality code annotations and does rejection sampling for code prompts. The synthetic data totals more than 2.7M examples. About one million dialogs come from “execution feedback”: generate problems, generate solutions, check them with static analysis (a parser and a linter) and automatically generated unit tests, hand the feedback back to the model on failure, and keep only those that pass everything. A finding worth remembering is that training the 405B on its own generated data does not help and can even hurt, so execution feedback is needed as a source of ground truth; about 20% of solutions were initially wrong and were then self-corrected. There are also programming-language translation (turning data in common languages into less common ones) and backtranslation (about 1.2M dialogs).

Inference: two machines, or FP8

BF16 405B does not fit on one 8-GPU machine, so the paper first uses a BF16 setup on 16 GPUs across two machines, with tensor parallelism within a machine and pipeline parallelism across them. Inference has no backward pass and so no pipeline flush problem, hence micro-batching raises throughput; latency goes up slightly but the overall throughput-latency trade-off is better. The second route is FP8: quantize most parameters and activations in the feed-forward layers (about 50% of inference compute time) but not the parameters of the attention layers, nor the first and the last layer, with dynamic scaling factors and row-wise quantization. The paper also found that high-perplexity tokens such as dates produce very large activations, which make dynamic scaling factors large and cause underflow and decoding errors, so the scaling factors are capped at 1200. It reports up to 50% higher throughput in the prefill stage and a clearly better throughput-latency trade-off in decoding.

This section has a very practical lesson: the paper found that on standard benchmarks FP8 and BF16 look equal, yet when the scaling factors were not capped the model occasionally produced corrupted responses even though benchmark scores stayed strong. So they instead compare the distribution of reward-model scores over 100,000 responses under FP8 and BF16 to measure the effect of quantization.

Safety and multimodality: two side lines

On safety, the paper released Llama Guard 3 for input and output filtering along with Llama 3, and tunes the safety data mix against two metrics that pull against each other, the violation rate and the false refusal rate. On multimodality, it describes a compositional approach that attaches an image encoder to the language model through cross-attention and then adds video and speech, and states that these models are “still under development and not yet ready for release”.

Experiments and conclusions

Table 2 of the paper compares the 405B, 70B and 8B with open and closed models of similar scale. Here is a subset of the benchmarks (post-trained models, Llama 3.1 results; the GPT-4o and Claude 3.5 Sonnet numbers also come from this table):

Benchmark8B70B405BGPT-4oClaude 3.5 Sonnet
MMLU (5-shot)69.483.687.389.189.9
MMLU-Pro (5-shot, CoT)48.366.473.374.077.0
IFEval80.487.588.685.688.0
HumanEval (0-shot)72.680.589.090.292.0
GSM8K (8-shot, CoT)84.595.196.896.196.4
MATH (0-shot, CoT)51.968.073.876.671.1
GPQA (0-shot, CoT)32.846.751.153.659.4
BFCL76.184.888.580.590.2
MGSM (0-shot, CoT)68.986.991.690.591.6

The GSM8K number for Claude 3.5 Sonnet is 0-shot in the paper; the others follow the column heads.

  • The 405B trades wins and losses with the two closed models. Over these 9 rows it wins 4 and loses 5 against GPT-4o, with the losses within 2.8 points (MATH); against Claude 3.5 Sonnet it wins 3, ties 1 and loses 5, the biggest loss being GPQA (8.3 points), the others 1.7 to 3.7 points. The paper’s conclusion is “comparable to leading closed models and close to the state of the art”, which holds up against these numbers but should not be read as across-the-board parity.
  • The small models are interesting too. The paper says the 8B and 70B do best among models of their size; in Table 2 the 70B scores 83.6 on MMLU, only 3.7 points below the 405B’s 87.3. The paper also notes that the small models are trained on far more tokens than compute-optimal (tokens per parameter are in the check below).
  • Human evaluation agrees with the benchmarks. The paper uses pairwise comparisons on a 7-point scale and concludes that the 405B is roughly on par with GPT-4 (0125 API version) and trades wins and losses with GPT-4o and Claude 3.5 Sonnet: on par with GPT-4o on English prompts, on par with Claude 3.5 Sonnet on multilingual prompts, ahead of Claude 3.5 Sonnet on single-turn and multi-turn English prompts, but behind on coding and reasoning. It adds that human-evaluation results are strongly influenced by tone, response structure and verbosity.
  • The comparison protocol is not harsh on the competitors. For non-Llama models the paper reports the best score among publicly reported results and ones it could reproduce itself.

Hands-on check: parameter counts, parallel configs, scaling-law extrapolation, KV cache and failure statistics

Many of the paper’s numbers can be checked directly. The script below does nine things: (1) it counts the parameters of the 8B, 70B and 405B models exactly from the hyperparameters in Table 3 and compares them with the totals Hugging Face reports for the same models; (2) it checks that the parallelism products, batch sizes and MFU in Table 4 are self-consistent; (3) it redoes the scaling-law extrapolation to see whether 402B and 16.55T come out, and computes tokens per parameter for each model; (4) it computes KV-cache sizes and whether 405B fits on one 8-GPU machine; (5) it backs out hardware utilization from the GPU hours in the Llama 3.1 model card; (6) it recomputes the shares and groupings in Table 5; (7) it checks the weighted averages in Tables 6 and 7; (8) it reproduces the RoPE frequency scaling that is in the released code but not in the paper, and compares it with the transformers implementation; (9) it compares the order of magnitude with DeepSeek-V3.

Environment: Apple M2 Max, Python 3.14.3, numpy 2.4.2, transformers 5.3.0 (only its RoPE initialization function is called; no model is loaded). Everything is deterministic arithmetic with no randomness; it runs in under 2 seconds and the output should be identical in any environment. The numbers in Tables 3 to 7 are my transcriptions from the paper’s PDF, checked against the page layout afterwards; the first row of Table 5 really is printed as 148 and 30.1% in the PDF. The 989 TFLOPS (dense BF16 peak of the H100 SXM) comes from NVIDIA’s spec sheet, not from the paper, and a different peak would change every utilization figure. The parameter totals come from the Hugging Face API metadata of the official repos meta-llama/Llama-3.1-8B, meta-llama/Llama-3.1-70B and meta-llama/Llama-3.1-405B (the safetensors totals), and the GPU hours from the Llama 3.1 model card, both read in November 2026.

"""Llama 3 paper: recompute sizes, parallelism, scaling law, cache, faults."""
import numpy as np
from transformers import LlamaConfig
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS

PEAK = 989e12   # H100 SXM dense BF16 peak (NVIDIA spec sheet, not in the paper)

# ====== 1. Do Table 3 hyperparameters give 8B / 70B / 405B ======
print("== 1. parameters from Table 3 ==")
CFG = {   # layers, hidden size, FFN size, attention heads, KV heads
    "8B": (32, 4096, 14336, 32, 8),
    "70B": (80, 8192, 28672, 64, 8),
    "405B": (126, 16384, 53248, 128, 8),
}
VOCAB = 128_000 + 256     # 128K base tokens plus 256 special tokens
HF_TOTAL = {              # official repos' totals (Hugging Face API)
    "8B": 8_030_261_248,
    "70B": 70_553_706_496,
    "405B": 405_853_388_800,
}


def parts(L, d, f, h, kv):
    hd = d // h                              # 128 dims per head
    attn = 2 * d * d + 2 * d * kv * hd       # Q, O: d*d each; K, V: d*kv*hd
    ffn = 3 * d * f                          # SwiGLU has three matrices
    return attn, ffn, 2 * d                  # plus two RMSNorm weight vectors


for name, cfg in CFG.items():
    L, d = cfg[0], cfg[1]
    attn, ffn, norm = parts(*cfg)
    emb = VOCAB * d                          # input/output embeddings untied
    total = L * (attn + ffn + norm) + 2 * emb + d
    print(f"{name:>4}: {total:,} match HF: {total == HF_TOTAL[name]}")
    print(f"      ffn {L * ffn / total:.1%}  attn {L * attn / total:.1%}"
          f"  embeddings {2 * emb / total:.1%}")

# ====== 2. Table 4: are parallelism, batch and MFU consistent ======
print("== 2. Table 4 ==")
ROWS = [   # GPUs, TP, CP, PP, DP, seq len, batch per DP group, TFLOPs, MFU
    (8192, 8, 1, 16, 64, 8192, 32, 430, 43),
    (16384, 8, 1, 16, 128, 8192, 16, 400, 41),
    (16384, 8, 16, 16, 8, 131072, 16, 380, 38),
]
for g, tp, cp, pp, dp, seq, bs, tf, mfu in ROWS:
    print(f"gpus {g:>5}: tp*cp*pp*dp={tp * cp * pp * dp:>5}, "
          f"tokens/batch={dp * bs * seq:,}, "
          f"mfu={tf * 1e12 / PEAK:.1%} (table {mfu}%)")
print(f"405 TFLOPs would be {405e12 / PEAK:.2%}")

# ====== 3. Scaling law: can we reproduce 402B / 16.55T ======
print("== 3. scaling law extrapolation ==")
C = 3.8e25
fit = {}
for label, a, A in (("text", 0.53, 0.29), ("figure", 0.537, 0.299)):
    D = A * C ** a                           # optimal training tokens A * C^a
    fit[label] = D
    print(f"{label:>6} (a={a}, A={A}): D*={D / 1e12:5.2f}T, "
          f"N=C/6D={C / (6 * D) / 1e9:4.0f}B")
print(f"below 16.55T: text {1 - fit['text'] / 16.55e12:.1%}, "
      f"figure {1 - fit['figure'] / 16.55e12:.1%}")
lnc = np.log(C)
print(f"ln C = {lnc:.2f}: exponent gap 0.007 -> x{np.exp(0.007 * lnc):.2f}, "
      f"coefficient gap -> x{0.299 / 0.29:.3f}")
for label, n, d in (("paper fit", 402e9, 16.55e12),
                    ("trained", 405e9, 15.6e12)):
    print(f"{label:>9}: N={n / 1e9:.0f}B D={d / 1e12:.2f}T "
          f"6ND={6 * n * d:.3e} ({6 * n * d / C - 1:+.1%} vs C)")
l2 = 6 * 70e9 * 1.8e12                       # Llama 2 70B, intro's 1.8T tokens
print(f"vs Llama 2 70B: {C / l2:.1f}x (1.8T tokens), "
      f"{C / (6 * 70e9 * 2e12):.1f}x (2T tokens)")
for name, d in (("8B", 15e12), ("70B", 15e12), ("405B", 15.6e12)):
    n = HF_TOTAL[name]
    c = 6 * n * d
    d_opt = 0.299 * c ** 0.537               # Fig. 3 fit, beyond fitted range
    print(f"{name:>4}: {d / n:5.0f} tokens/param, C={c:.2e} "
          f"({c / 1e22:.0f}x of 1e22), "
          f"fit: D*={d_opt / 1e12:4.1f}T N={c / (6 * d_opt) / 1e9:3.0f}B")

# ====== 4. KV cache, and does it fit on one machine ======
print("== 4. KV cache and memory ==")
CTX = 131072
for name, (L, d, f, h, kv) in CFG.items():
    hd = d // h
    per_tok = L * 2 * kv * hd * 2            # K and V, 2 bytes per BF16 number
    mha = L * 2 * h * hd * 2                 # if every head had its own K and V
    print(f"{name:>4}: {per_tok:>7,} B/token, 128K = "
          f"{per_tok * CTX / 2**30:5.1f} GiB, MHA {mha // per_tok}x = "
          f"{mha * CTX / 2**30:6.1f} GiB")
L, d, f, h, kv = CFG["405B"]
attn, ffn, norm = parts(*CFG["405B"])
hbm = 8 * 80e9                               # one machine: 8 x H100 80 GB
bf16 = HF_TOTAL["405B"] * 2
fp8 = bf16 - (L - 2) * ffn                   # FFN only, not first/last layer
per_tok = L * 2 * kv * (d // h) * 2
print(f"BF16 weights {bf16 / 1e9:.0f} GB vs HBM {hbm / 1e9:.0f} GB: "
      f"fits={bf16 < hbm}")
print(f"FP8 FFN weights {fp8 / 1e9:.0f} GB, left {(hbm - fp8) / 1e9:.0f} GB")
for ctx in (8192, 131072):
    print(f"  ctx {ctx:>6}: {(hbm - fp8) / (per_tok * ctx):5.1f} sequences")

# ====== 5. Utilization implied by the model card GPU hours ======
print("== 5. GPU hours (model card) vs 6ND ==")
HOURS = {"8B": 1.46e6, "70B": 7.0e6, "405B": 30.84e6}   # Llama 3.1 model card
TOK = {"8B": 15e12, "70B": 15e12, "405B": 15.6e12}      # model card says 15T+
for name in CFG:
    flops = 6 * HF_TOTAL[name] * TOK[name]
    util = flops / (HOURS[name] * 3600 * PEAK)
    print(f"{name:>4}: 6ND={flops:.2e}, {HOURS[name] / 1e6:5.2f}M GPU-h "
          f"-> {util:.1%} of peak")
lo, hi = 380e12 / PEAK * 0.9, 430e12 / PEAK * 0.9
print(f"Table 4 MFU x 90% uptime: {lo:.1%} to {hi:.1%}")
print(f"405B wall-clock on 16,384 GPUs: {HOURS['405B'] / 16384 / 24:.0f} days")

# ====== 6. Table 5: interruption statistics ======
print("== 6. Table 5 ==")
T5 = [   # component, category, count, printed share (%)
    ("Faulty GPU", "GPU", 148, 30.1),
    ("GPU HBM3 Memory", "GPU", 72, 17.2),
    ("Software Bug", "Dependency", 54, 12.9),
    ("Network Switch/Cable", "Network", 35, 8.4),
    ("Host Maintenance", "Maintenance", 32, 7.6),
    ("GPU SRAM Memory", "GPU", 19, 4.5),
    ("GPU System Processor", "GPU", 17, 4.1),
    ("NIC", "Host", 7, 1.7),
    ("NCCL Watchdog Timeouts", "Unknown", 7, 1.7),
    ("Silent Data Corruption", "GPU", 6, 1.4),
    ("GPU Thermal Interface + Sensor", "GPU", 6, 1.4),
    ("SSD", "Host", 3, 0.7),
    ("Power Supply", "Host", 3, 0.7),
    ("Server Chassis", "Host", 2, 0.5),
    ("IO Expansion Board", "Host", 2, 0.5),
    ("Dependency", "Dependency", 2, 0.5),
    ("CPU", "Host", 2, 0.5),
    ("System Memory", "Host", 2, 0.5),
]
total = sum(r[2] for r in T5)
print(f"sum of counts {total}, sum of printed percentages "
      f"{sum(r[3] for r in T5):.1f}")
for name, cat, n, pct in T5:
    calc = 100 * n / total
    if abs(calc - pct) > 0.06:
        print(f"row differs: {name} count {n}, paper {pct}%, "
              f"count/total {calc:.1f}%")
        fixed = sum(r[3] for r in T5) - pct + calc
        implied = round(pct * total / 100)
        print(f"  percentages sum to {fixed:.1f}% if the percentage is the "
              f"typo;\n  counts sum to {total - n + implied} if the count "
              f"is (implied count {implied})")


def by_cat(cat):
    rows = [r for r in T5 if r[1] == cat]
    return sum(r[2] for r in rows), sum(r[3] for r in rows)


gpu, gpu_pct = by_cat("GPU")
net, net_pct = by_cat("Network")
host, host_pct = by_cat("Host")
maint, maint_pct = by_cat("Maintenance")
print(f"GPU rows: {gpu}/{total} = {gpu / total:.1%} by count, "
      f"{gpu_pct:.1f}% by printed percentages")
print(f"GPU+network+host: {(gpu + net + host) / total:.1%} by count, "
      f"{gpu_pct + net_pct + host_pct:.1f}% by printed percentages")
print(f"adding maintenance: {(gpu + net + host + maint) / total:.1%} "
      f"by count, {gpu_pct + net_pct + host_pct + maint_pct:.1f}% "
      f"by printed percentages")
per_day = total / 54
print(f"{per_day:.1f} unexpected interruptions per day, one every "
      f"{24 / per_day:.1f} h")
for n in (1024, 4096, 16384):                # assume faults scale with GPUs
    print(f"  {n:>5} GPUs: one every {16384 * 54 * 24 / total / n:5.1f} h")

# ====== 7. Tables 6 and 7: do the weighted averages match ======
print("== 7. Tables 6 and 7 ==")
T6 = [   # share, turns, tokens, prompt tokens, response tokens
    (81.99, 4.1, 1000.4, 36.4, 271.2),
    (6.93, 3.2, 1621.0, 113.8, 462.9),
    (5.19, 1.8, 1299.4, 77.1, 420.9),
    (5.89, 1.6, 707.7, 46.6, 129.9),
]
T6_TOTAL = (3.8, 1041.6, 44.5, 284.0)
T7 = [   # share, turns, tokens, context tokens, final-response tokens
    (52.66, 6.3, 974.0, 656.7, 317.1),
    (14.89, 2.7, 753.3, 378.8, 374.5),
    (3.01, 2.7, 520.5, 230.8, 289.7),
    (8.14, 2.3, 297.8, 124.4, 173.4),
    (21.19, 3.1, 661.6, 359.8, 301.9),
    (0.11, 6.7, 38135.6, 37395.2, 740.5),
]
T7_TOTAL = (4.7, 846.1, 535.7, 310.4)
for label, tab, tot in (("T6", T6, T6_TOTAL), ("T7", T7, T7_TOTAL)):
    w = np.array([r[0] for r in tab]) / 100
    avg = (w[:, None] * np.array([r[1:] for r in tab])).sum(0)
    print(f"{label}: shares sum to {w.sum() * 100:.2f}%")
    print(f"  weighted {np.round(avg, 1).tolist()}")
    print(f"  paper    {list(tot)}")
# T7 token columns are off by 1.0: swap share between long context and
# general English to absorb the gap
for col, name in ((1, "tokens"), (2, "context")):
    x_lc, x_ge = T7[5][col + 1], T7[0][col + 1]
    delta = (avg[col] - T7_TOTAL[col]) / (x_lc - x_ge)
    print(f"T7 long-context share implied by {name}: "
          f"{(0.0011 - delta) * 100:.4f}% (printed 0.11%)")
lc = 0.0011 * 38135.6 / 846.1
print(f"T7 long-context: 0.11% of examples, {lc:.1%} of tokens")

# ====== 8. RoPE frequency scaling in the released code ======
print("== 8. RoPE scaling in the released code ==")
theta, dim = 500_000.0, 128
inv = 1.0 / theta ** (np.arange(0, dim, 2) / dim)    # 64 frequencies


def llama3_scale(inv, factor=8.0, low=1.0, high=4.0, old=8192):
    wave = 2 * np.pi / inv                    # wavelength, in tokens
    scaled = np.where(wave > old / low, inv / factor, inv)
    smooth = (old / wave - low) / (high - low)
    mid = (wave >= old / high) & (wave <= old / low)
    return np.where(mid, (1 - smooth) * scaled / factor + smooth * scaled,
                    scaled), wave


new, wave = llama3_scale(inv)
cfg = LlamaConfig(hidden_size=4096, num_attention_heads=32,
                  max_position_embeddings=131072,
                  rope_parameters={"rope_type": "llama3",
                                   "rope_theta": theta, "factor": 8.0,
                                   "low_freq_factor": 1.0,
                                   "high_freq_factor": 4.0,
                                   "original_max_position_embeddings": 8192})
ref, _ = ROPE_INIT_FUNCTIONS["llama3"](cfg, "cpu")
print(f"max rel diff vs transformers: "
      f"{np.abs(new / ref.numpy() - 1).max():.1e}")
bands = {"unchanged": wave < 2048,
         "interpolated": (wave >= 2048) & (wave <= 8192),
         "divided by 8": wave > 8192}
for label, mask in bands.items():
    idx = np.where(mask)[0]
    print(f"{label:>12}: frequency pairs {idx[0]}-{idx[-1]} ({len(idx)})")
mid = bands["interpolated"]
print(f"ratios in the interpolated band: "
      f"{np.round(new[mid] / inv[mid], 3).tolist()}")

# ====== 9. Versus DeepSeek-V3 (different accounting, order of magnitude) ======
print("== 9. versus DeepSeek-V3 ==")
v3 = 6 * 37e9 * 14.8e12      # 37B active params, 14.8T tokens, via 6ND
print(f"DeepSeek-V3 6ND {v3:.3e}: Llama 3 405B is {C / v3:.1f}x")
print(f"GPU hours {30.84 / 2.788:.1f}x (30.84M H100 vs 2.788M H800)")

The output:

== 1. parameters from Table 3 ==
  8B: 8,030,261,248 match HF: True
      ffn 70.2%  attn 16.7%  embeddings 13.1%
 70B: 70,553,706,496 match HF: True
      ffn 79.9%  attn 17.1%  embeddings 3.0%
405B: 405,853,388,800 match HF: True
      ffn 81.3%  attn 17.7%  embeddings 1.0%
== 2. Table 4 ==
gpus  8192: tp*cp*pp*dp= 8192, tokens/batch=16,777,216, mfu=43.5% (table 43%)
gpus 16384: tp*cp*pp*dp=16384, tokens/batch=16,777,216, mfu=40.4% (table 41%)
gpus 16384: tp*cp*pp*dp=16384, tokens/batch=16,777,216, mfu=38.4% (table 38%)
405 TFLOPs would be 40.95%
== 3. scaling law extrapolation ==
  text (a=0.53, A=0.29): D*=10.46T, N=C/6D= 605B
figure (a=0.537, A=0.299): D*=16.29T, N=C/6D= 389B
below 16.55T: text 36.8%, figure 1.5%
ln C = 58.90: exponent gap 0.007 -> x1.51, coefficient gap -> x1.031
paper fit: N=402B D=16.55T 6ND=3.992e+25 (+5.0% vs C)
  trained: N=405B D=15.60T 6ND=3.791e+25 (-0.2% vs C)
vs Llama 2 70B: 50.3x (1.8T tokens), 45.2x (2T tokens)
  8B:  1868 tokens/param, C=7.23e+23 (72x of 1e22), fit: D*= 1.9T N= 62B
 70B:   213 tokens/param, C=6.35e+24 (635x of 1e22), fit: D*= 6.2T N=170B
405B:    38 tokens/param, C=3.80e+25 (3799x of 1e22), fit: D*=16.3T N=389B
== 4. KV cache and memory ==
  8B: 131,072 B/token, 128K =  16.0 GiB, MHA 4x =   64.0 GiB
 70B: 327,680 B/token, 128K =  40.0 GiB, MHA 8x =  320.0 GiB
405B: 516,096 B/token, 128K =  63.0 GiB, MHA 16x = 1008.0 GiB
BF16 weights 812 GB vs HBM 640 GB: fits=False
FP8 FFN weights 487 GB, left 153 GB
  ctx   8192:  36.1 sequences
  ctx 131072:   2.3 sequences
== 5. GPU hours (model card) vs 6ND ==
  8B: 6ND=7.23e+23,  1.46M GPU-h -> 13.9% of peak
 70B: 6ND=6.35e+24,  7.00M GPU-h -> 25.5% of peak
405B: 6ND=3.80e+25, 30.84M GPU-h -> 34.6% of peak
Table 4 MFU x 90% uptime: 34.6% to 39.1%
405B wall-clock on 16,384 GPUs: 78 days
== 6. Table 5 ==
sum of counts 419, sum of printed percentages 94.9
row differs: Faulty GPU count 148, paper 30.1%, count/total 35.3%
  percentages sum to 100.1% if the percentage is the typo;
  counts sum to 397 if the count is (implied count 126)
GPU rows: 268/419 = 64.0% by count, 58.7% by printed percentages
GPU+network+host: 77.3% by count, 72.2% by printed percentages
adding maintenance: 85.0% by count, 79.8% by printed percentages
7.8 unexpected interruptions per day, one every 3.1 h
   1024 GPUs: one every  49.5 h
   4096 GPUs: one every  12.4 h
  16384 GPUs: one every   3.1 h
== 7. Tables 6 and 7 ==
T6: shares sum to 100.00%
  weighted [3.8, 1041.7, 44.5, 283.9]
  paper    [3.8, 1041.6, 44.5, 284.0]
T7: shares sum to 100.00%
  weighted [4.7, 847.1, 536.7, 310.4]
  paper    [4.7, 846.1, 535.7, 310.4]
T7 long-context share implied by tokens: 0.1072% (printed 0.11%)
T7 long-context share implied by context: 0.1074% (printed 0.11%)
T7 long-context: 0.11% of examples, 5.0% of tokens
== 8. RoPE scaling in the released code ==
max rel diff vs transformers: 3.2e-07
   unchanged: frequency pairs 0-28 (29)
interpolated: frequency pairs 29-34 (6)
divided by 8: frequency pairs 35-63 (29)
ratios in the interpolated band: [0.828, 0.644, 0.494, 0.371, 0.271, 0.19]
== 9. versus DeepSeek-V3 ==
DeepSeek-V3 6ND 3.286e+24: Llama 3 405B is 11.6x
GPU hours 11.1x (30.84M H100 vs 2.788M H800)

Parameter counts: Table 3 reproduces all three model sizes exactly

  • All three totals match digit for digit. 8,030,261,248, 70,553,706,496 and 405,853,388,800 equal the Hugging Face totals exactly, so Table 3 plus “SwiGLU has three matrices, the embedding and output layers are not tied, and each layer has two RMSNorms” is the whole model. The vocabulary has to be 128,256, not the 128,000 written in Table 3: Meta’s tokenizer code adds 256 special tokens on top of the base tokens.
  • The feed-forward layers hold most of the parameters. The FFN is 70.2% (8B), 79.9% (70B) and 81.3% (405B) of the parameters, attention is 16.7% to 17.7% (GQA makes the K and V projections small), and the embedding and output layers are 13.1% of the 8B model but only 1.0% of the 405B.

Parallel configs: Table 4 is self-consistent, and 41% is a rounding effect

  • In all three rows TP×CP×PP×DP equals the GPU count, and every batch has 16,777,216 tokens, that is 2242^{24}, so the “16M” in the table is 16Mi, not 16×10616\times10^6. The third row uses 128K sequences, so a batch holds only 128 sequences (8 data-parallel groups with 16 each).
  • At a peak of 989 TFLOPS, 430, 400 and 380 TFLOPs are 43.5%, 40.4% and 38.4%. Rows one and three agree with the 43% and 38% printed; row two is printed as 41%. The TFLOPs column is only given to the nearest ten, and a true value of 405 (40.95%) would explain the 41%, so this need not be an error.

Scaling law: the extrapolation is extremely sensitive to the third decimal of the exponent

  • The rounded coefficients in the text cannot be used. Plugging (α,A)=(0.53,0.29)(\alpha, A)=(0.53, 0.29) into D⋆=A CαD^\star=A\,C^{\alpha} at C=3.8×1025C=3.8\times10^{25} gives 10.46T tokens (605B parameters), 36.8% below the paper’s 16.55T; the (0.537,0.299)(0.537, 0.299) in the legend of Figure 3 gives 16.29T (389B), 1.5% below 16.55T. An exponent difference of 0.007 times ln⁡C=58.90\ln C=58.90 is a factor of 1.51, and 0.29 versus 0.299 adds another 3.1%. The extrapolation spans more than three orders of magnitude (the fitted data stops at 102210^{22} FLOPs), so quote this law with the coefficients from the legend.
  • The pair 402B and 16.55T does not match 3.8×10²⁵. 6ND6ND of that pair is 3.992×10²⁵, 5.0% above 3.8×10²⁵, while the model actually trained, 405B on 15.6T tokens, gives 3.791×10²⁵ (3.80×10²⁵ with the exact parameter count 405.85B), which matches the paper. The paper does not say which compute formula the extrapolation point used, so I do not know where the 5% comes from. The reason it gives for the choice is that the IsoFLOPs curve is very flat near the optimum, so 405B was fixed.
  • “Almost 50×” reproduces. Against Llama 2 70B it is 50.3× with the 1.8T tokens from the introduction and 45.2× with the 2T tokens of the Llama 2 paper.
  • The small models are deliberately over-trained. Tokens per parameter are 1,868, 213 and 38 for 8B, 70B and 405B (the Chinchilla rule of thumb is about 20). Applying the fit of Figure 3 directly to their own compute budgets, the 8B budget corresponds to about 62B parameters and 1.9T tokens and the 70B budget to about 170B parameters and 6.2T tokens, so the 8B model sees about 8 times the tokens the fit suggests. The 405B row is the extrapolation of the fit itself, not an independent check, and the first two rows extrapolate the fit to 72 and 635 times the largest fitted compute, so treat them as orders of magnitude only.

KV cache: GQA makes 128K feasible, but single-machine concurrency is limited

ModelKV cache per token128K contextWithout GQA
8B128 KiB16.0 GiB4×, 64.0 GiB
70B320 KiB40.0 GiB8×, 320.0 GiB
405B504 KiB63.0 GiB16×, 1008.0 GiB
  • The BF16 weights of 405B are 812 GB, which does not fit in one machine with 8 H100s of 80 GB (640 GB in all), consistent with the paper’s use of 16 GPUs on two machines for BF16.
  • Estimating from the paper’s description (only the feed-forward weights quantized to FP8, the attention layers and the first and last layer left alone), the weights drop to 487 GB, leaving 153 GB. With a BF16 KV cache that holds about 36 sequences of 8K or about 2.3 sequences of 128K. This is an upper bound: it does not subtract activations, CUDA graphs or runtime overhead, the paper does not say what precision the KV cache uses, and it does not measure concurrency at long context; its inference section only measures throughput and latency at 4,096 input and 256 output tokens.

GPU hours: the model card and the paper roughly agree

  • Taking 6ND6ND as the compute and 989 TFLOPS as the peak, the 30.84M GPU hours of the Llama 3.1 model card correspond to 34.6% for the 405B. On the paper’s side, the MFU of Table 4 (38.4% to 43.5%) times “more than 90% effective training time” is 34.6% to 39.1%, and the model card lands at the lower edge. 6ND6ND leaves out the attention FLOPs that MFU usually counts, so this is a rough cross-check, not a rigorous accounting.
  • The small models come out much lower (13.9% for 8B, 25.5% for 70B). The model card does not say whether the GPU hours include post-training, and the token count is only given as “15T+”, so I do not interpret the reason; I only note that the 405B utilization should not be carried over to the small models.
  • 30.84M GPU hours divided by 16,384 GPUs is 78 days. The early stage used only 8,192 GPUs (the first row of Table 4), so the real wall-clock time is at least that long.

Failure statistics: the first row of Table 5 does not add up, and “about 78%” cannot be reproduced

  • The counts add up to 419, which agrees with the text (“of 466 interruptions, 47 were planned and 419 unexpected”), but the printed percentages add up to only 94.9%. Dividing each count by 419, only the first row disagrees: 148 should be 35.3%, while the table prints 30.1%; every other row is within rounding. If the percentage is the typo (it should be 35.3%), the percentages sum to 100.1%; if the count is the typo (126 would match 30.1%), the counts sum to only 397, which is 22 short of 419. The first needs a single typo, but I cannot tell which it is, and v3, the version this post uses, still reads this way.
  • The text says “GPU issues account for 58.7%”. That number equals the sum of the printed percentages of the GPU rows, so it inherits the 30.1% of the first row; by count the GPU rows are 268 interruptions, 64.0%.
  • The text says “about 78% are attributed to confirmed or suspected hardware issues”, a scope that includes GPU or host-component failures, silent data corruption and unplanned single-host maintenance, without saying which rows of the table that is. Taking GPU, network and host components together gives 77.3% by count and 72.2% by printed percentages; adding unplanned maintenance gives 85.0% and 79.8%. None of the four is 78%, so I cannot reproduce the number.
  • 419 unexpected interruptions over 54 days is 7.8 a day, one every 3.1 hours. Assuming failures scale with the GPU count (crude, all causes lumped together), the same per-GPU failure rate gives one every 49.5 hours on 1,024 GPUs and one every 12.4 hours on 4,096. Each step up in scale makes “can it recover from a failure automatically” less of a nicety; the paper says that over those 54 days only three interruptions needed significant manual intervention.

Tables 6 and 7: the weighted averages match, and the extra 1.0 is rounding

  • Weighting the columns of Table 6 by share gives numbers within 0.1 of the total row (1,041.7 versus 1,041.6, 283.9 versus 284.0), which is rounding.
  • In Table 7 the weighted averages of both “tokens per example” and “context tokens” are 1.0 above the total row (847.1 versus 846.1, 536.7 versus 535.7). Assigning that 1.0 entirely to the share of the “long context” row backs out 0.1072% from one column and 0.1074% from the other, nearly the same number and inside the rounding range of “0.11%” (0.105% to 0.115%). So this is rounding, not an error.
  • Long-context examples are only 0.11% of the SFT examples but about 5.0% of the tokens.

RoPE frequency scaling: in the released code, not in the paper

The paper only says the RoPE base frequency was raised to 500,000. Meta’s reference code has an apply_scaling function (its comment says “Values obtained from grid search”), and the public weights ship a config.json with rope_type: llama3, factor: 8, low_freq_factor: 1, high_freq_factor: 4 and original_max_position_embeddings: 8192. I did not find a description of this step anywhere in the paper. The script implements it from those parameters, and against the llama3 initialization function in transformers the maximum relative difference is 3.2×10⁻⁷ (float32 precision).

  • The 64 frequency components fall into three bands: the 29 with wavelength below 2,048 tokens stay unchanged, the 29 with wavelength above 8,192 are divided by 8, and the 6 in between are interpolated with a smooth factor whose scaling ratio falls from 0.828 to 0.19.
  • This is the “leave high frequencies alone, compress low frequencies, blend in between” idea, the same family as NTK-by-parts in this site’s YaRN explainer. The paper only says the long-context ability comes from about 800B tokens of continued pre-training; whether this scaling was also used in training, the paper does not say and I do not know.

An order-of-magnitude comparison with DeepSeek-V3

DeepSeek-V3 activates 37B parameters and was pre-trained on 14.8T tokens, which is 3.286×10²⁴ FLOPs by 6ND6ND; Llama 3 405B is 11.6 times that. The GPU hours are 30.84M (H100) against 2.788M (H800), 11.1 times. The two ratios are close, which says that under this crude accounting the gap comes mainly from compute per token (405B dense against 37B activated). The GPU types and the scope of the counts both differ (DeepSeek-V3’s 2.788M covers pre-training, context extension and post-training), so only the order of magnitude means anything; see this site’s DeepSeek-V3 explainer.

Limitations and what came after

  • Cost and availability: every token of the dense 405B uses all the parameters, and deployment needs two 8-GPU machines or FP8; the contemporaneous DeepSeek-V3 trained an MoE with 37B activated parameters in about one eleventh of the GPU hours and reports being the strongest open-source model of the time on knowledge, code and math evaluations (see this site’s DeepSeek-V3 explainer). After Llama 3 Meta changed course itself: the Llama 4 Scout and Maverick released in April 2025 are mixture-of-experts models, with 108.6B and 401.6B parameters in total on Hugging Face.
  • Evaluation contamination cannot be ruled out: the paper estimates contamination with 8-gram overlap, choosing a threshold per dataset that maximizes the difference between the clean subset and the whole dataset. It says itself that for MBPP, HumanEval, MMLU and MMLU-Pro the 8-gram overlap gives such high contamination scores that a reliable performance-gain estimate is impossible, and these are exactly the headline rows of Table 2. The post-training data was only decontaminated by exact match against the benchmark prompts.
  • Human evaluation is subjective: the paper itself admits that human evaluations can be inconsistent or unreliable because of annotators’ personal biases, backgrounds and preferences.
  • What was not released: the training data and training code were not published, only the recipe is described; the weights come under the Llama 3.1 Community License, a custom commercial license rather than an open-source license in the OSI sense, so go by the official text. The multimodal models were not released when the paper came out; the later Llama 3.2 (September 2024) added small models and vision models.
  • Numbers inside the paper: the first row of Table 5 disagrees with the text’s “58.7%” and “about 78%”, and the coefficients that extrapolate to 402B and 16.55T cannot be reproduced from the numbers the paper gives; see the hands-on check. These do not affect the paper’s main conclusions, but be careful when quoting these specific numbers.

What to take away from this paper

  1. Data and scale are the lead, architecture the supporting role: the architecture is nearly Llama 2’s; cleaning, three-level deduplication, the mix, annealing and 15T tokens are the main variables.
  2. Conservative choices buy stability: a dense model, DPO and a handful of “don’t get fancy” conventions; only three significant manual interventions in 54 days is the evidence for this approach, but the paper ran no controlled comparison, so it is the authors’ judgment.
  3. Scaling laws only fix the rough size: the extrapolation is extremely sensitive to the third decimal of the coefficients; the real basis for the decision is that the IsoFLOPs curve is flat near the optimum.
  4. The engineering details are the hardest part to copy: the ordering of the 4D parallelism, the pipeline changes, the collective communication library and failure diagnosis decide whether 16K GPUs can run for 54 days at 38% to 43% MFU.
  5. Synthetic data needs a source of ground truth: the 405B learning from its own outputs did not help, and adding execution feedback did; that lesson is worth more than any single number.

Further reading

FAQ

How many parameters, tokens and FLOPs does Llama 3.1 405B use?
Llama 3.1 405B is a dense Transformer with 126 layers, a hidden size of 16,384, 128 attention heads (8 of them key-value heads), a feed-forward size of 53,248 and a vocabulary of 128,256. Recomputing the parameter count from the paper's Table 3 gives 405,853,388,800, exactly the total of the official repo on Hugging Face. Pre-training used about 15.6T tokens and about 3.8×10²⁵ FLOPs on up to 16,384 H100s; the Llama 3.1 model card lists 30.84M H100 GPU hours of training. The context goes up to 128K, obtained by six stages of continued pre-training on about 800B tokens at the end of pre-training.
Why did Llama 3 use a dense model instead of a mixture of experts (MoE)?
The paper says it chose a standard dense Transformer with small modifications rather than an MoE to maximize training stability, part of what it calls managing complexity. The evidence it gives is that training showed few loss spikes and needed no interventions for divergence; it ran no dense-versus-MoE comparison, so "dense is more stable" is the authors' judgment, not a measured result. The price is that every token uses all the parameters: by 6ND the 405B run took about 11.6 times the training compute of DeepSeek-V3 (37B activated, 14.8T tokens) and about 11.1 times the GPU hours, though the accounting differs and only the order of magnitude is meaningful.
What post-training methods did Llama 3 use, and why DPO instead of PPO?
Post-training is six rounds of a loop: train a reward model on human preference data, generate SFT data by rejection sampling (10 to 30 answers per prompt, best one picked by the reward model), fine-tune with SFT, run DPO, and finally average the weights of models trained with different data versions or hyperparameters. DPO uses β=0.1 and a learning rate of 10⁻⁵, masks formatting tokens, and adds an NLL term with coefficient 0.2 on the chosen answer. The paper says it also tried on-policy algorithms such as PPO but found DPO cheaper for large models and better on instruction-following benchmarks like IFEval; it gives no ablation table for this comparison, so it is the authors' statement.
How was the 128K context of Llama 3.1 trained?
Not from the start: attention compute grows quadratically with sequence length, so long sequences are left to the final stage of pre-training. The paper raises the context from 8K to 128K in six stages over about 800B tokens; before moving to the next stage it requires that short-context evaluations have fully recovered and that needle-in-a-haystack tasks are solved perfectly at the current length. Supporting choices are a RoPE base of 500,000, GQA with 8 key-value heads, a document mask that blocks attention across documents, and context parallelism (CP). The public weights also carry a RoPE frequency scaling (factor 8) that the paper does not describe.
Can Llama 3.1 405B run on one 8-GPU machine?
The BF16 weights are about 812 GB, more than the 640 GB of one machine with eight 80 GB H100s, so the paper runs BF16 on 16 GPUs across two machines with pipeline parallelism. The other route is to quantize the feed-forward weights to FP8, which by the paper's description cuts the weights to about 487 GB; they then fit on one machine, but only about 153 GB is left for the KV cache. With a BF16 KV cache one 128K sequence takes about 63 GiB, so only about two fit at once. The paper measures throughput and latency at 4,096 input and 256 output tokens and does not measure concurrency at long context.