Skip to content
10/30Chapter 10 of 30

Pretraining an LLM: Data, Compute, Scaling Laws and Cost

Twenty models trained on one laptop GPU to measure a scaling law, and the 6ND compute estimate checked against a real FLOP counter.

On this page

Chapter 9 ended with a transformer block that trains. Stack a few of them, point the next-token loss of Chapter 8 at the output, and there is nothing left to invent. Everything that remains is a purchase.

That is a bigger shift than it sounds. Every chapter so far asked does it learn? — a yes-or-no question a laptop settles in ten minutes. This one asks a question with money in it: given a fixed amount of arithmetic, what is the best model I can buy? The answer is a formula, and it was not obvious to anyone in 2018.

Here is that question answered by measurement, on one laptop GPU. Twenty models, from 98,624 to 15 million parameters, were trained from scratch on 174 million tokens of Wikipedia — a 2,048-token BPE vocabulary trained the way Chapter 7 trains one, the transformer of Chapter 9. Each run got exactly one of three compute budgets and not one operation more, so a bigger model necessarily reads less text. The best held-out loss reached at each budget:

TEXT
budget C (FLOPs)   best loss   reached by a model of
       1.00e13       5.3531           98,624 params
       3.16e13       4.8638           98,624 params
       1.00e14       4.3383          295,808 params

fitted:  L = (Cc / C)^0.0913     over one decade of compute

Ten times the arithmetic takes 19 % off the loss, and the three points lie on a straight line in log-log. Nothing in the first nine chapters predicts that. There is no theorem behind it — it is an empirical regularity, holding with a different exponent over the ten orders of magnitude between this laptop and a datacentre, and it is the single observation that persuaded an industry to spend the GDP of a small country on GPUs.

What pretraining is, and what is new about it

Link to the section: What pretraining is, and what is new about it

Nothing in the objective changes. The model still predicts the next token, the loss is still the cross-entropy of Chapter 4 applied to the factorisation of Chapter 8, the optimiser is still the AdamW of Chapter 6. Pretraining is not a new algorithm; it is the same algorithm run on a corpus large enough that the run has to be budgeted. Two things make that possible: the labels are free, since the target for position tt is the token at t+1t+1 and is already in the text; and Chapter 6's last section removed the objection, because a model with far more parameters than the classical rules allow does not fall apart, it improves. What comes out is a base model — something that continues text rather than answering.

Counting the compute before spending it: 6ND

Link to the section: Counting the compute before spending it: 6ND

Before any of this can be budgeted it has to be counted, and the field counts it with one formula:

C6NDC \approx 6ND

where NN is the parameter count, DD the training tokens and CC the total floating-point operations. Kaplan et al. derive it in two steps.1 Forward: 2 FLOPs per parameter per token, since every parameter in a matrix multiply is used once per token, in one multiply and one add. Backward: twice the forward, since the backward pass of Chapter 5 computes two gradients at each layer — with respect to the layer's inputs, so the signal keeps travelling, and with respect to its weights — each a matrix multiply the size of the forward one, so 4N4N.

That is the whole derivation, and it is worth checking rather than believing. PyTorch ships a real FLOP counter, torch.utils.flop_counter.FlopCounterMode, which intercepts every operation a model dispatches and totals the actual work. Run it across four orders of magnitude, the largest on the meta device, which allocates shapes and no memory:

flops.pyPYTHON
from torch.utils.flop_counter import FlopCounterMode

counter = FlopCounterMode(display=False)
with counter:                       
    loss = model(x, targets)[1]     
    loss.backward()                 
measured = counter.get_total_flops()
print(measured / (6 * n_params * n_tokens))
configurationNN without embeddingsNN totalmeasured, fwd+bwd÷ 6ND6ND (total NN)÷ 6ND6ND (no emb.)fwd+bwd ÷ fwd
dd 128, 4 layers, TT 256788,7367,254,4004.60e101.0319.4853.000
dd 512, 8 layers, TT 25625,183,23251,045,8883.26e111.0382.1043.000
dd 768, 12 layers, TT 102484,973,056124,356,8641.75e121.1451.6763.000
dd 1600, 48 layers, TT 10241,474,870,4001,556,920,0002.10e131.1001.1613.000
dd 4096, 32 layers, TT 20486,442,983,4246,582,444,0328.74e131.0801.1043.000
dd 8192, 80 layers, TT 819264,427,147,26465,544,929,2803.75e151.1631.1833.000

The forward+backward over forward ratio is 3.000, exactly, at every scale: not an approximation that happens to be good, but the arithmetic identity above returned as a round number by a counter that knows nothing about the derivation.

The measured total then sits between 3 % and 17 % above 6ND6ND, once NN counts the embedding matrices — and that clause matters, because the two founding papers count NN differently. Kaplan excludes "all vocabulary and positional embeddings" because doing so "produces significantly cleaner scaling laws" (§1.3); Chinchilla's Appendix F says "we also count embeddings matrices in the total parameter count".2 For a wide vocabulary and a narrow hidden dimension the two differ by a factor of nine, as the first row shows.

The residual gap is what 6ND6ND deliberately omits: the attention scores. Kaplan's Eq. (2.2) writes the forward cost as 2N+2nlayernctxdmodel2N + 2\,n_{\text{layer}} n_{\text{ctx}} d_{\text{model}} and drops the second term because dmodelnctx/12d_{\text{model}} \gg n_{\text{ctx}}/12 — safe in 2020, less safe now, and the reason the ratio drifts upward as T/dT/d grows — which is why two rows here share a TT of 1,024 and the ratio falls, from 1.145 to 1.100, when dd goes from 768 to 1,600. It is the O(T2)O(T^2) cost Chapter 9 introduced and Chapter 16 turns into a price.

Compute decides how long a run takes; memory decides whether it can start. Train with plain fp32 AdamW and every parameter carries four numbers: the weight, its gradient, and Adam's running mean mm and variance vv — the two averages built by hand in Chapter 6. Four numbers at four bytes each is 16 bytes per parameter, before a single activation. Measured on an 8 GB laptop GPU, taking the resident allocation at the point in the step where no graph is alive:

modelvocabularybatchNN16N16N predictedresident measuredpeak in a stepthe difference
dd 512, 8 layers50,257851,045,888779 MB801 MB2,500 MB1,699 MB
dd 512, 8 layers4,096827,411,456418 MB426 MB1,043 MB617 MB
dd 256, 6 layers4,09685,839,36089 MB89 MB382 MB293 MB
dd 256, 6 layers4,096325,839,36089 MB89 MB1,259 MB1,170 MB
dd 256, 6 layers4,0961285,839,36089 MB89 MB4,771 MB4,681 MB

Prediction and measurement agree to within 3 %. The surprise is the last column: the activations dwarf the model. The same 5.8-million-parameter model that needs 89 MB of persistent state needs 4,681 MB of activations at a batch of 128 — fifty-two times the model — and much of that is not the transformer at all. It is the logits, one vector of vocabulary size per token at four bytes an entry: 512 MB in the last row, 393 MB in the first. The vocabulary size was chosen in Chapter 7, and it is still deciding what fits on the card.

Which term dominates depends on the shape of the run, which is why Micikevicius et al. say memory "is dominated by activations"3 while ZeRO says a 1.5-billion-parameter model needs "at least 24 GB" of model states alone.4 ZeRO reaches the same 16 bytes by another route — 2Ψ2\Psi for fp16 weights, 2Ψ2\Psi for fp16 gradients, 4Ψ4\Psi each for the fp32 master weights and Adam's two moments — which for 70 billion parameters is 1.12 terabytes, fourteen 80 GB GPUs' worth before a single activation.

Parallelism, in one paragraph and one delegation

Link to the section: Parallelism, in one paragraph and one delegation

None of that fits on one device at frontier scale, so the run is split four ways at once. Data parallelism puts a copy of the model on every GPU and averages the gradients — the default, and the one ZeRO improves by refusing to keep redundant copies of the optimiser state. Tensor parallelism splits individual matrices across devices. Pipeline parallelism gives each device a contiguous group of layers. Context parallelism splits the sequence itself, necessary only once TT is long enough for the attention term to dominate. Llama 3's Table 4 lists all four at once: tensor 8, context up to 16, pipeline 16, data up to 128, across 16,384 H100 GPUs.5 That is all this course will say about it; distributed training engineering is a semester of its own, and Stanford's CS336 is that semester, lectures 5 to 8, with the code.6 What survives the delegation is a single number, model FLOPs utilisation — the fraction of a GPU's peak arithmetic a real run achieves — which is what turns the tidy 6ND6ND into wall-clock time and therefore into money.

In January 2020, Kaplan et al. trained a grid of transformers and found the test loss follows a power law in each of the three resources over more than six orders of magnitude.1 Their §1.2 gives three fitted laws:

L(N)=(NcN)αN,αN0.076,Nc8.8×1013L(N) = \left(\frac{N_c}{N}\right)^{\alpha_N}, \qquad \alpha_N \approx 0.076, \qquad N_c \approx 8.8 \times 10^{13}

with companions αD0.095\alpha_D \approx 0.095 for data and αCmin0.050\alpha_C^{\min} \approx 0.050 for optimally allocated compute. The constants are not universal, and the paper says so: "the precise numerical values of NcN_c, CcminC_c^{\min} and DcD_c depend on the vocabulary size and tokenization and hence do not have a fundamental meaning."

The exponents are tiny: ten times the parameters buys a factor 100.0761.1910^{0.076} \approx 1.19 off the remaining loss. That sounds like nothing, and it is the most important fact here — the returns are terrible and they never stop. A power law with a small exponent promises that the next order of magnitude will help, less than the last one did, forever. Buying compute stops being a gamble and becomes a purchase with a published exchange rate, which is exactly the argument that unlocked the capital.

Then came the prescription, and this is where the paper was wrong in a way that cost the industry a great deal of money. Kaplan's Table 6 gives NoptC0.73N_{\text{opt}} \propto C^{0.73} and DoptC0.27D_{\text{opt}} \propto C^{0.27}: ten times the compute means a model 5.4 times bigger fed only 1.9 times as much text. The abstract is explicit — "optimally compute-efficient training involves training very large models on a relatively modest amount of data and stopping significantly before convergence." The field did exactly that: GPT-3 is 175 billion parameters on 300 billion tokens,7 Gopher 280 billion on 300 billion, Megatron-Turing NLG 530 billion on 270 billion.2 Half a token to two tokens per parameter, across the board.

Chinchilla, and what the sweep above was measuring

Link to the section: Chinchilla, and what the sweep above was measuring

In March 2022, Hoffmann et al. trained over 400 models from 70 million to 16 billion parameters and reached the opposite conclusion by three independent routes.2 Their Table 2 reports the exponent aa in NoptCaN_{\text{opt}} \propto C^{a} as 0.50, 0.49 and 0.46, against Kaplan's 0.73. In plain terms: model size and training data should grow in equal proportion.

Their second approach is the one reproduced by the sweep at the top of this chapter, at a millionth of the scale: fix a budget, train many sizes at exactly that budget, plot final loss against model size.

parametersC=1013C = 10^{13}C=3.16×1013C = 3.16 \times 10^{13}C=1014C = 10^{14}
98,6245.3531 (171)4.8638 (542)
150,3205.4636 (74)
194,2085.5041 (44)4.8730 (140)4.4040 (442)
295,8085.5550 (19)4.9029 (60)4.3383 (190)
665,2805.7849 (3.8)5.1254 (12)4.4192 (38)
1,280,7685.8174 (1.0)5.1751 (3.2)4.5003 (10)
3,101,5685.4686 (0.5)4.7768 (1.7)
5,315,0725.5894 (0.2)4.8514 (0.6)
15,053,5685.3534 (0.1)

Held-out loss in nats per token, tokens per parameter in brackets, bold for the best model at each budget; a dash is a point not run, because the budget demanded more text than the corpus holds or the size fell outside those swept there.

Read down a column: the loss falls, bottoms out and climbs again. A model can be too big for its budget exactly as easily as too small — at 101410^{14} the penalty for choosing 665,280 parameters over 295,808 is 0.08 nats, which on the envelope fitted above is the loss a correctly sized model reaches with 18 % less compute. Picking the wrong shape throws away a fifth of the budget. That is Chinchilla's Figure 3 in an afternoon on one GPU instead of with four hundred models.

Now read across. At 101310^{13} the best model is the smallest one swept; at 101410^{14} it is 295,808 parameters, bracketed on both sides. The optimum moves right as the budget grows, which is the whole content of the correction. Fit the paper's third approach — the surface L(N,D)=E+A/Nα+B/DβL(N,D) = E + A/N^{\alpha} + B/D^{\beta} over every run — and minimise subject to C=6NDC = 6ND:

TEXT
L(N, D) = 24.7 / N^0.195 + 46.8 / D^0.169       (E fits to ~0; see below)
implied   N_opt ∝ C^0.464
  compare   Chinchilla 0.46-0.50 · Besiroglu 0.513 · Kaplan 0.73

0.46, from a laptop, against Kaplan's 0.73. Agreement to three digits from a three-budget fit is luck; agreement to the first is not. The exponent travels — the constant does not, since the token-to-parameter ratio at these optima is 170 to 540, not 20. Three reasons, all instructive. EE fits to zero because at a loss above 4 nats the run is nowhere near the entropy floor that dominates Chinchilla's fit. Batch size and learning rate were fixed rather than tuned per point, which handicaps whichever runs get fewest steps — and those are the large models: at 101310^{13} FLOPs a 1.28-million-parameter model gets 159 optimiser steps in total, far under the few thousand Kaplan's SminS_{\min} term says any model needs. A scaling law is fitted inside a regime, and this one sits six orders of magnitude below Chinchilla's.

Hence the paper's abstract: "current large language models are significantly undertrained". Chinchilla is the demonstration — 70 billion parameters on 1.4 trillion tokens, the same total compute as Gopher's 280 billion on 300 billion, beating it on 51 of 57 MMLU tasks, 67.5 % against 60 %.2 Four times smaller, four and a half times more text, same money, better model.

Two caveats on that famous ratio. "Twenty tokens per parameter" is not a sentence in the paper, which says only that "for every doubling of model size the number of training tokens should also be doubled"; the 20 is an inference from Table 3 and from Chinchilla's own 70 B on 1.4 T. And its precision is worse than published: Besiroglu et al. refitted from a digitisation of Figure 4, found the original parameters "fit the reconstructed data poorly" with intervals "implausibly tight given the number of data points", and put the honest range at "between 4 and 40" tokens per parameter.8

One detail of Chinchilla's method pays off a promise Chapter 1 made about learning-rate schedules. The cosine schedule has to be matched to the token budget. A model that will see 10 million tokens must decay its learning rate to zero at 10 million tokens; give it a schedule sized for 100 million, stop it early, and you are reading a loss mid-descent at a rate far too high. Chinchilla trains each model at four cycle lengths to control for exactly this; the sweep above sets its schedule from the budget for the same reason.

They are the most useful empirical result in the field and they are routinely oversold. Four limits.

They predict loss, not capability. The left-hand side is cross-entropy on held-out text. Nothing in these papers licenses a claim about whether a model will write correct SQL, refuse a harmful request or use a tool. This is Chapter 5's lesson again: a prediction of the loss is not a prediction of the behaviour you are paying for.

They are fitted, not derived. No theory produces αN=0.076\alpha_N = 0.076. The constants move with the tokenizer — which is why a perplexity comparison across two tokenizers is meaningless, as Chapter 8 explained — and with the data mixture, architecture and optimiser. Every published law is a law of the setup that produced it, which is why Meta refitted its own before Llama 3.5

They assume a fresh token for every step, which quietly assumes an infinite corpus. Muennighoff et al. measured what happens when it runs out: up to four epochs of repeated data cost almost nothing — an 8.7-billion-parameter model on 44 billion unique tokens seen four times finished "only 0.5 % higher validation loss" than the same model on 178 billion unique ones — while past about sixteen epochs additional compute buys nothing.9

And nobody trains compute-optimal any more. Chinchilla minimises the cost of training; a deployed model then pays roughly 2N2N FLOPs per generated token, forever. LLaMA 1 said it plainly: "given a target level of performance, the preferred model is not the fastest to train but the fastest at inference".10 Sardana et al. formalised it by minimising 6NDtrain+2NDinference6ND_{\text{train}} + 2ND_{\text{inference}} instead, and found anyone expecting a billion requests should train "smaller and longer than Chinchilla-optimal".11 Llama 3's §9.1 agrees: its small models train "far beyond the point of compute optimal training, effectively trading training compute for inference efficiency".5 The ratio is not obsolete; it answers a question that is no longer the one being asked.

Emergent abilities, and the argument about whether they are real

Link to the section: Emergent abilities, and the argument about whether they are real

Loss falls smoothly. Benchmark scores sometimes do not. Wei et al. collected cases where a task sits at chance across orders of magnitude of training compute and then jumps — three-digit arithmetic appearing in GPT-3 at about 2×10222 \times 10^{22} FLOPs, MMLU rising above guessing between 33 and 5×10235 \times 10^{23} — and named the pattern: "an ability is emergent if it is not present in smaller models but is present in larger models".12 If that is a real property, extrapolating from cheap experiments is unsafe, because the capability you are buying may not exist at any scale you can afford to test.

Schaeffer, Miranda and Koyejo argued that most of it is an artefact of measurement, and the mechanism is arithmetic.13 Per-token loss falls smoothly, so the probability of one token being right, exp(L)\exp(-\mathcal{L}), improves gradually. Score the model with exact string match over an LL-token answer and you raise that probability to the power LL — a smooth curve raised to a large power looks like a cliff. Swap in a metric that counts tokens instead of demanding all of them, on the same outputs, and "the family's performance smoothly, continuously and predictably improves with increasing scale".

Their audit is the number to remember — "of the 39 preferred metrics in BIG-Bench, at most 5 display emergence", with two discontinuous metrics accounting for over 92 % of claimed cases — and so is their caution: "nothing in this paper should be interpreted as claiming that large language models cannot display emergent abilities". A jump in a chart is evidence about the metric until shown otherwise. Chapter 29 is where that becomes your problem, because choosing a hard-cutoff metric is a decision you will make without noticing.

The corpus is the part of a pretraining run with no equation attached, and where most of the consequential decisions live. The raw material is a web crawl: Common Crawl's August 2026 archive holds "2.14 billion web pages or 360 TiB of uncompressed content", one month of it, free to download.14 Almost none is usable as it stands. The T5 paper says the crawl "largely comprises gibberish or boiler-plate text like menus, error messages, or duplicate text", and the C4 pipeline it introduced is a list of blunt heuristics — keep only lines ending in terminal punctuation, drop pages with fewer than three sentences, drop any page containing a curly brace or a word from a public list of obscenities — turning twenty terabytes of monthly text into about 750 GB.15

Blunt is the word. Dodge et al. audited what those filters remove and found the obscenity blocklist deletes 42 % of documents in African-American English and 32 % in Hispanic-aligned English, against 6.2 % of White-aligned English, leaving a corpus 97.8 % of the last category.16 A rule with no opinion about dialect had one.

Then deduplication, which is not housekeeping: Lee et al. found a 61-word sentence repeated 61,036 times in C4, and showed deduplicating cuts the rate at which models "emit memorized text" tenfold, from 1.9 % of generated tokens to 0.19 %.17 More is not better, though — FineWeb's team deduplicated globally across 96 crawls, got 4 trillion tokens and no measurable gain, then deduplicated each crawl separately, got 20 trillion, and matched the best existing corpus.18

Then contamination. Llama 3 measured its own and published it: 98 % of AGIEval, 95 % of BIG-Bench Hard and 85 % of HellaSwag overlapping the training set by 8-grams, and for MMLU an overlap so high that "it is impossible to get a good performance gain estimate".5 GPT-3's §4 reports a filtering bug that left benchmarks in the data with no way back: "because of cost considerations it was infeasible to retrain the model".7

Provenance is the unresolved part. The Pile shipped a 100.96 GiB component called Books3 — 12 % of the corpus and, by the paper's own consent table, books from a private torrent tracker;19 it was taken offline in August 2023 after a copyright complaint. The legal position as of September 2026 is unsettled, and the three US rulings cited as a trend disagree with one another. Alsup found training on lawfully acquired books "exceedingly transformative" while holding that a library built from pirated copies was not, and Anthropic settled that half for $1.5 billion covering 482,460 works, roughly $3,000 each, approved 20 July 2026.20 Chhabria granted Meta summary judgment while writing that his ruling "does not stand for the proposition that Meta's use of copyrighted materials to train its language models is lawful", only that "these plaintiffs made the wrong arguments".21 Bibas, ruling against Ross Intelligence, noted that "only non-generative AI is before me today".22 No US appellate court has ruled on the question.

People do the parts the loss cannot. TIME reported in January 2023 that workers labelling toxic text for OpenAI through the firm Sama took home "between around $1.32 and $2 per hour" reading passages describing child sexual abuse, torture and self-harm, while OpenAI paid Sama $12.50 an hour for the work; Sama disputes both the pay range and the quota.23 That is the filtering around pretraining rather than pretraining itself — but it is on the same invoice, and it is where a person sits.

The electricity is real and usually misquoted. The most careful published figure is BLOOM's: 1,082,990 GPU-hours, 433 MWh and 24.7 tonnes of CO₂ equivalent for the run, 50.5 counting manufacturing and idle nodes;24 Patterson et al. put GPT-3 at 1,287 MWh and 552 tonnes.25 Two cautions. BLOOM's advantage is its French nuclear grid at 57 g CO₂ per kWh rather than efficiency — it used more energy than OPT-175B. And the field's most-quoted emissions figure, Strubell et al.'s 626,155 lb for a neural architecture search, was later shown to be 88 times too high, having assumed the search ran at full model size when it ran on a proxy.26 LBNL's framing is the defensible one: US data centres used 192 TWh in 2024, 4.7 % of national electricity — a number attached to an industry, not to any one run.27

The through-line is what Bender et al. named documentation debt: "putting ourselves in a situation where the datasets are both undocumented and too large to document post hoc".28 Every fact above exists because somebody looked. For the corpora behind the models most people use, nobody can.

Now the arithmetic everyone wants, from four cited inputs, so that when they go stale it is obvious which to replace.

NVIDIA's H100 page lists 1,979 teraFLOPS of BF16 tensor-core throughput under a footnote reading "with sparsity".29 No pretraining run uses structured sparsity, so the dense figure is half of it: 989.5 TFLOP/s.

Llama 3's Table 4 reports 38–43 % BF16 model FLOPs utilisation. Take 40 %: 395.8 TFLOP/s of useful arithmetic per GPU.5

Lambda's on-demand price for an 8×H100 SXM node, accessed 2026-09-06: $3.99 per GPU-hour, so $31.92 an hour for the node.30

Chinchilla's ratio, D=20ND = 20N, gives C=6ND=120N2C = 6ND = 120N^2 and therefore N=C/120N = \sqrt{C/120}.

budgetH100-hoursFLOPscompute-optimal paramstokenson one 8×H100 nodeGPUs to finish in 90 days
$100253.6e19546 M10.9 B3.1 h1
$1,0002513.6e201.73 B34.5 B31.3 h1
$10,0002,5063.6e215.46 B109 B13 days2
$100,00025,0633.6e2217.3 B345 B131 days12
$1,000,000250,6273.6e2354.6 B1.09 T4 years116
$10,000,0002,506,2663.6e24173 B3.45 T36 years1,160
$100,000,00025,062,6573.6e25546 B10.9 T358 years11,603

Read the last two columns together. At $10,000 you get a 5-billion-parameter model on one rented node in a fortnight. At $100,000,000 the arithmetic says 546 billion parameters — and twelve thousand H100s wired together for three months, which is not something you rent with a credit card. Past about $100,000 the binding constraint stops being money and becomes the cluster.

Before trusting a table like that, test it against runs whose real cost is published — llm.c reproduces GPT-2 124M in "~90 minutes" on an 8×A100 node "for about $20", and GPT-2 1.6B in 24 hours on an 8×H100 node for $672.31

TEXT
$672, against what $672 actually bought (llm.c GPT-2 1.6B, one 8xH100 node, 24 h)
  this table predicts:      168 H100-hours   N = 1.41 B params   D = 28.3 B tokens
  what was actually run:    192 H100-hours   N = 1.558 B params  D = 33.6 B tokens

Llama 3 405B, against Meta's own published GPU-hours
  from the paper's 3.8e25 FLOPs at 40 % MFU:   26.67 M H100-hours
  published in Meta's Llama 3.1 model card:    30.84 M H100-hours    ratio 0.86

Both within about 15 %, which is roughly the accuracy this kind of estimate deserves and considerably better than the accuracy it is usually quoted with.

The headline comparison, with both definitions on the table

Link to the section: The headline comparison, with both definitions on the table

The most repeated figure in this subject is that a GPT-2-class model costing about $43,000 in 2019 can be reproduced today for a few tens of dollars. The modern half is well documented; the historical half is not.

Today. Karpathy's nanochat README: "you can train your own GPT-2 capability LLM ... for only $48 (~2 hours of 8XH100 GPU node) ... On a spot instance, the total cost can be closer to ~$15."32 "GPT-2 capability" here is precise and published — beating GPT-2's CORE score of 0.256525 — on a leaderboard whose best entry as of 14 March 2026 is 1.65 hours. The $48 assumes $3 per GPU-hour, below Lambda's list $3.99; at list it is nearer $64.

In 2019. There is no primary source: OpenAI never published a duration or a cost. The chain runs The Register, February 2019, reporting "256 Google TPU3 cores" with no price and no duration; then Synced, June 2019, noting that hardware cost $256 an hour on Google Cloud and stating explicitly that "OpenAI didn't specify the training duration". $43,008 is $256 an hour times an assumed 168 hours that nobody has ever sourced.

So the honest headline is: a model matching GPT-2's published benchmark score can be trained today for well under $100 on rented hardware, against a 2019 cost that was never published and whose famous estimate rests on an unsourced guess about the duration. The collapse is real and the modern half is reproducible by anyone with a credit card; the ratio is arithmetic on a number that does not exist. That is the state of published training costs generally. The GPT-3 paper contains no dollar amount at all, only 3.14×10233.14 \times 10^{23} FLOPs in Table D.1;7 the Llama 3 paper contains none either.5 Every training cost you have read is an estimate from a FLOP count, a hardware assumption and a price assumption — always worth asking whose.

What a base model knows, and when it stopped knowing it

Link to the section: What a base model knows, and when it stopped knowing it

What comes out has seen a fixed corpus assembled at a fixed moment, and two properties follow.

The first is the knowledge cutoff. After the collection date the model knows nothing — not "is uncertain", nothing — and it will confabulate fluently rather than say so, because saying so was never a behaviour it was trained on. Llama 3.1's model card gives December 2023;33 every model has one, and it is a property of the training data, not the deployment. Working around it is a retrieval problem, which is Chapter 19.

The second is that a base model completes rather than answers. Give it "What is the capital of France?" and a plausible continuation is another question, because in the corpus that string most often appears in a list of exercises.

A text completer is not an assistant. It does not follow instructions, because nothing in the corpus told it a request should be obeyed rather than continued. It has no notion of a conversation with two participants. It will happily produce the most probable continuation of a harmful prompt, because probable is the only thing it was ever optimised for.

Turning it into something that answers takes a second stage costing a fraction of a per cent of the first, and consisting almost entirely of showing it examples of the behaviour you want and then comparing pairs of its own outputs. That stage is where instruction following, chat templates, refusals and — this surprises people — the ability to call a tool all come from. Chapter 11 is that stage: supervised fine-tuning, RLHF, DPO and GRPO, and the question of what "aligned" means and who decides.


Also worth reading alongside this chapter: Karpathy's build-nanogpt and its accompanying video, which walk a full GPT-2 reproduction end to end at a pace this chapter cannot; and Stanford CS324, Large Language Models, whose lectures on data and on environmental impact go deeper than the section above into material this course treats once and delegates.

  1. Kaplan, J., McCandlish, S., Henighan, T., Brown, T. B., Chess, B., Child, R., Gray, S., Radford, A., Wu, J. and Amodei, D. Scaling Laws for Neural Language Models. arXiv:2001.08361 (2020). The three power laws are Eqs. (1.1)–(1.3) in §1.2 and the full constants are in Appendix A, Table 5; the 6N6N derivation is §2.1; the compute-allocation exponents are Table 6. Note there are two compute laws, αC=0.057\alpha_C = 0.057 at fixed batch size and αCmin=0.050\alpha_C^{\min} = 0.050 at optimal batch size; the paper says the latter "should be used to make predictions". 2

  2. Hoffmann, J., Borgeaud, S., Mensch, A., Buchatskaya, E., Cai, T., Rutherford, E. et al. Training Compute-Optimal Large Language Models. arXiv:2203.15556 (2022). Exponents in Table 2, projected budgets in Table 3, the Gopher comparison in §4, the parameter-counting convention in Appendix F. The prose beneath Table 3 disagrees with Table 3 itself for the 175 B and 280 B rows; the table is the version to quote. 2 3 4

  3. Micikevicius, P., Narang, S., Alben, J., Diamos, G., Elsen, E., Garcia, D. et al. Mixed Precision Training. arXiv:1710.03740 (2017), ICLR 2018. FP32 master weights in §3.1, loss scaling in §3.2. 2

  4. Rajbhandari, S., Rajbhandari, S., Ruwase, O. and He, Y. ZeRO: Memory Optimizations Toward Training Trillion Parameter Models. arXiv:1910.02054 (2019), SC20. The 16Ψ16\Psi accounting is §3.1; the residual-state figures for activations are §3.2.

  5. Grattafiori, A. et al. (Llama Team, AI @ Meta). The Llama 3 Herd of Models. arXiv:2407.21783 (2024). Compute budget and token count in §1, the refitted scaling law in §3.2.1, the parallelism configuration and MFU in Table 4, the contamination analysis in §5.1.4, the over-training statement in §9.1. The paper contains no dollar figures and no emissions table. 2 3 4 5 6

  6. Stanford CS336, Language Modeling from Scratch. Lecture 2 covers resource accounting, lectures 5–8 GPUs, kernels and parallelism, lectures 9 and 11 scaling, lectures 13–14 data. It is the course this chapter delegates its engineering to, and it is public.

  7. Brown, T. B. et al. Language Models are Few-Shot Learners. arXiv:2005.14165 (2020). Compute in Appendix D, Table D.1 — which has a column literally headed "flops per param per token", whose value for every GPT-3 row is 6. Contamination analysis in §4. 2 3

  8. Besiroglu, T., Erdil, E., Barnett, M. and You, J. Chinchilla Scaling: A replication attempt. arXiv:2404.10102 (2024). Reconstructs Chinchilla's data by digitising its Figure 4, refits, and reports the corrected exponents and much wider intervals.

  9. Muennighoff, N., Rush, A. M., Barak, B., Le Scao, T., Piktus, A., Tazi, N., Pyysalo, S., Wolf, T. and Raffel, C. Scaling Data-Constrained Language Models. arXiv:2305.16264 (2023), NeurIPS 2023. The four-epoch result is §6; the sixteen-epoch half-life is the fitted RD15R_D^* \approx 15.

  10. Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T. et al. LLaMA: Open and Efficient Foundation Language Models. arXiv:2302.13971 (2023). §1 states the inference-cost argument against Chinchilla-optimal training.

  11. Sardana, N., Portes, J., Doubov, S. and Frankle, J. Beyond Chinchilla-Optimal: Accounting for Inference in Language Model Scaling Laws. arXiv:2401.00448 (2023), ICML 2024. Their §5 also contains the counterweight: models trained at extreme token ratios keep improving, but "more slowly than scaling laws predict".

  12. Wei, J., Tay, Y., Bommasani, R., Raffel, C., Zoph, B., Borgeaud, S. et al. Emergent Abilities of Large Language Models. arXiv:2206.07682 (2022), TMLR. Definition in §2, examples and compute thresholds in §3–4 and Table 1.

  13. Schaeffer, R., Miranda, B. and Koyejo, S. Are Emergent Abilities of Large Language Models a Mirage? arXiv:2304.15004 (2023), NeurIPS 2023 outstanding paper. The metric argument is §2, the BIG-Bench meta-analysis §4, the constructed vision example §5.

  14. Common Crawl, August 2026 Crawl Archive Now Available (CC-MAIN-2026-34), published 24 August 2026, accessed 2026-09-06. Its own front page claims "over 300 billion pages spanning 15 years", "totalling more than 10 petabytes" — a figure for the whole archive, not for the monthly crawl priced here.

  15. Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., Zhou, Y., Li, W. and Liu, P. J. Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer. arXiv:1910.10683 (2019), JMLR 21(140). The C4 filters are §2.2. The paper gives sizes in bytes, not tokens; the 156-billion-token figure widely attributed to it is from Dodge et al. below.

  16. Dodge, J., Sap, M., Marasović, A., Agnew, W., Ilharco, G., Groeneveld, D., Mitchell, M. and Gardner, M. Documenting Large Webtext Corpora: A Case Study on the Colossal Clean Crawled Corpus. arXiv:2104.08758 (2021), EMNLP 2021. Dialect removal rates are §5.3; benchmark contamination in C4 is §4.2.

  17. Lee, K., Ippolito, D., Nystrom, A., Zhang, C., Eck, D., Callison-Burch, C. and Carlini, N. Deduplicating Training Data Makes Language Models Better. arXiv:2107.06499 (2021), ACL 2022. The 61,036 repeats are footnote 1; the memorisation figures are §6.2, Table 4, and are percentages of generated tokens under a 50-token exact-match criterion.

  18. Penedo, G., Kydlíček, H., Ben Allal, L., Lozhkov, A., Mitchell, M., Raffel, C., Von Werra, L. and Wolf, T. The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scale. arXiv:2406.17557 (2024), NeurIPS 2024 Datasets and Benchmarks. The deduplication result is §3.4. The released dataset has since grown past the paper's 15 trillion tokens.

  19. Gao, L., Biderman, S., Black, S. et al. The Pile: An 800GB Dataset of Diverse Text for Language Modeling. arXiv:2101.00027 (2020). Books3 is §2.3 and Table 1; the consent table is Table 5. The corpus is 825.18 GiB, so even the title is a round-down.

  20. Bartz v. Anthropic, No. 4:24-cv-05417 (N.D. Cal.). Fair-use order 23 June 2025 (Dkt. 231); class certification 17 July 2025; final approval and judgment 20 July 2026 (Dkt. 680). The settlement releases past inputs only, not outputs and not future conduct.

  21. Kadrey v. Meta, No. 3:23-cv-03417-VC (N.D. Cal.), summary judgment 25 June 2025 (Dkt. 598). Note that the distribution claim over torrenting was not decided and remains live.

  22. Thomson Reuters v. ROSS Intelligence, No. 1:20-cv-00613-SB (D. Del.), revised opinion 11 February 2025 (Dkt. 770), Bibas J. On interlocutory appeal to the Third Circuit (No. 25-2153), argued 11 June 2026, undecided at the time of writing.

  23. Perrigo, B. Exclusive: OpenAI Used Kenyan Workers on Less Than $2 Per Hour to Make ChatGPT Less Toxic. TIME, 18 January 2023. The $2 is a ceiling for senior reviewers who met every target; junior labellers, the majority, took home $1.32. Sama's rebuttal, quoted in the same article, gives $1.46–$3.74 and a lower quota.

  24. Luccioni, A. S., Viguier, S. and Ligozat, A.-L. Estimating the Carbon Footprint of BLOOM, a 176B Parameter Language Model. arXiv:2211.02001 (2022), JMLR 24(253). Tables 1 and 3.

  25. Patterson, D., Gonzalez, J., Le, Q., Liang, C., Munguia, L.-M., Rothchild, D., So, D., Texier, M. and Dean, J. Carbon Emissions and Large Neural Network Training. arXiv:2104.10350 (2021). GPT-3's figures are Table 4; the correction of the NAS estimate is §4.1.

  26. Strubell, E., Ganesh, A. and McCallum, A. Energy and Policy Considerations for Deep Learning in NLP. arXiv:1906.02243 (2019), ACL 2019. Worth reading precisely because of what happened to its most-quoted number: the paper is careful, states its extrapolation, and was still wrong by two orders of magnitude on the one line everybody repeated.

  27. Smith, S. J., Hubbard, A., Newkirk, A., Ganeshalingam, M., Holecek, B., Sartor, D., Mills, M. and Shehabi, A. United States Data Center Energy Usage Report: 2025 Update. LBNL-2001758 (18 June 2026). This revises the widely cited 2024 report downward for the historical series; if you are quoting the 176 TWh figure for 2023, you are quoting the superseded edition.

  28. Bender, E. M., Gebru, T., McMillan-Major, A. and Shmitchell, S. On the Dangers of Stochastic Parrots: Can Language Models Be Too Big? FAccT '21, pp. 610–623. DOI 10.1145/3442188.3445922. "Documentation debt" is §4.4. Note that the paper's own carbon figures are cited from Strubell et al. and inherit the correction above — which is an illustration of its argument rather than a refutation of it.

  29. NVIDIA. NVIDIA H100 Tensor Core GPU product page, nvidia.com/en-us/data-center/h100/ (accessed 2026-09-06). Every tensor-core row on that page except FP64 carries the footnote "with sparsity"; the dense BF16 figure used here is half the published 1,979 TFLOPS.

  30. Lambda. GPU Cloud pricing, lambda.ai/pricing (accessed 2026-09-06). On-demand, per GPU per hour, before tax. Prices in this section will go stale faster than anything else in this course; the arithmetic around them will not.

  31. Karpathy, A. karpathy/llm.c, discussion #481, Reproducing GPT-2 (124M) in llm.c in 90 minutes for $20 (28 May 2024), and discussion #677, Let's reproduce GPT-2 (1.6B): one 8XH100 node, 24 hours, $672, in llm.c (11 July 2024).

  32. Karpathy, A. karpathy/nanochat, README and "time to GPT-2" leaderboard (accessed 2026-09-06). The $48 figure and the CORE-score definition of "GPT-2 capability" are both in the README; the repository's own speedrun.sh says "approximately 1.5 hours", so treat the two-hour figure as rounded.

  33. Meta. Llama 3.1 model card, models/llama3_1/MODEL_CARD.md in meta-llama/llama-models (accessed 2026-09-06). Source of the 30.84 M H100-hours for the 405 B model, the 39.3 M total, the 11,390 tCO2eq location-based figure, and the December 2023 data cutoff.


Created by

David Vicente Campos

Founder of NeuraLIA Labs & Co-Founder of MyRealFood

I'm a computer engineer from the University of León. I co-founded MyRealFood, where as CTO I built the app millions of people have used to eat better, and I founded NeuraLIA Labs, where I build AI products. Here I write about what I've had to understand along the way, as I wish someone had explained it to me.

More about the author

Published by NeuraLIA Labs.

Get new posts in your inbox

AI news, guides and product updates — a short email when we publish something worth your time.

Course index

Abstract software decision engine with branching paths, probability nodes, and glowing gates.
jev11 min read

Jev AI model is built for decisions, not prose

TypeSafe AI’s Jev is drawing attention because it treats software intelligence as a probability problem: choose the right branch, attach confidence, and avoid paying an LLM to write text when code needs a decision.

Abstract agent runtime sorting documents, memory blocks and pointer nodes inside a bounded context frame.
context-engineering12 min read

Context engineering for long-horizon AI agents

Long-running agents do not fail only because the window is small. They fail when files, tool outputs and stale history crowd out the task the agent was supposed to finish.

Ready to let LIA do the choosing?

Build with every AI model in one place — start free today.