ONE PROMPT · 10¹⁵ FLOPS · ¾ OF A CENT · 24 ORDERS OF MAGNITUDE

AI numbers every
AI engineer should know

LATENCY NUMBERS· 2012 ·
L1 cache reference·····································0.5 ns
main memory reference·····································100 ns
packet CA → NL → CA·····································150 ms
AI NUMBERS· 2026 ·
one LLM token (decode)·····································30 ms
one prompt, end to end·····································9.3 s
one training run·····································54 days

Seven rungs and a printed card: the tokenizer, 405 GB of weights, the memory wall, prefill, decode, the bill, and the training debt — one 11-word question ridden end to end through a frontier model, every number on the way down earned and checked. The scenes play themselves — watch, or just scroll. are tappable. You are the request.

00

The question becomes numbers

At 09:00:00.000 you press Enter on an 11-word question bound for a frontier-class model. In 9.3 seconds you’ll have a 300-token answer, and this tutorial will have a running meter: Σ FLOPs, the floating-point operations your request consumes. First comes the strange rung at the bottom — everything that happens to your words before any mathematics touches them, which is why the meter will not move once.

STEP 01 / 05
09:00:00.000 — ELEVEN WORDS, TWELVE NUMBERS
09:00:00.000 — what you typed vs what the model receives
> Why is the sky red at sunset but blue at noon?
Why10445
is374
the279
sky13180
red2579
at520
sunset44084
but719
blue6437
at520
noon38245
?30
46 chars ÷ 12 tokens = 3.8 chars/token · the words are gone

You press Enter on “Why is the sky red at sunset but blue at noon?” — 11 words, 46 characters. A splits it into 12 and replaces each with an integer ID from a fixed dictionary. That integer list is all the model will ever see — no letters, no words, no sounds. The rules of thumb every engineer eventually memorizes: 1 token ≈ ¾ of an English word ≈ 4 characters; 100 tokens ≈ 75 words. Check: 46 ÷ 12 = 3.8 characters per token. And the meter reads zero — splitting text is lookups, not math.

a token is ~¾ of a word, ~4 characters — the model has never seen a letter in its life
STEP 02 / 05
A 128,256-WORD DICTIONARY NOBODY WROTE
the 128,256-entry dictionary — ranked by frequency, written by nobody
#1" the"
#2" and"
#7"ing"
merge by frequency, repeat ×128,256
strawberry →strawberryletters visible: 0 · r’s countable: ?

The dictionary — Llama 3’s has exactly 128,256 entries; OpenAI’s o200k has ~200,000 — was written by no linguist. builds it by statistics: start from raw bytes, repeatedly merge the most frequent adjacent pair, stop at the target size. Frequency decides everything: “ the” (leading space included) is one token; rare words shatter into pieces. That’s why models famously fumbled counting the r’s in strawberry — the model receives st·raw·berry-style chunks, and the letters inside a chunk are invisible to it.

“how many r’s in strawberry?” fails because the model never sees letters — only learned chunks like st·raw·berry
STEP 03 / 05
THE TOKENIZER TAX
the same question, two scripts — billed by the token
EN
Why is the sky red at sunset?
8 tok
TE
సూర్యాస్తయంలోకాశం ఎందుకుర్రగా ఉంటుంది?
19 tok
same meaning · 2.4× the tokens here, up to ~10× for full text×2.4 price · ×2.4 window used

The dictionary was learned mostly from English-heavy data, so the same meaning costs different token counts in different languages: an identical sentence can cost 3–10× more tokens in Telugu, Burmese, or Khmer than in English — and since every API bills per token and every is measured in tokens, that’s a real tax on both price and how much fits. Code pays it too: deep indentation and rare identifiers fragment badly. Token count, not word count, is the unit your bill, your latency, and your context budget all share.

the same sentence can cost ~10× more tokens in Telugu than in English — billed accordingly
STEP 04 / 05
YOUR 12 TOKENS RIDE IN WITH 988 STRANGERS
what actually gets sent — the request payload, to scale-ish
system prompt620 tok
instructions240 tok
your question12 tok
retrieved context128 tok
= 1,000 tok
▪ your words are the 1.2% sliver — the rest is scaffolding you pay for

Your question does not travel alone. Ahead of it the app stacks a system prompt — identity, rules, tone, formatting — plus instructions and retrieved context: 988 tokens of boilerplate wrapping your 12. Total input: 1,000 tokens, and the model will weigh all of them equally; it has no idea which part “is” the user. This ratio is the norm, not the exception — production prompts are overwhelmingly scaffolding (the agent tutorial’s 4,200-token “constitution” is the same fact again). Everything downstream — prefill time, the bill — scales with the 1,000, not your 12.

your 12-token question ships inside 83× its weight in boilerplate — and you pay for all of it
STEP 05 / 05
ONE TOKEN = 16,384 NUMBERS, AND STILL ZERO FLOPS
the embedding lookup — an ID becomes 16,384 numbers, for free
sky → #13180
lookup table
128,256 × 16,384
0.031
−1.207
0.114
−0.482
0.960
⋮ ×16,384
16.4M values staged · lookups are copies, not math · Σ +0 FLOPs

At the model’s front door each ID is swapped for its — a learned vector of 16,384 numbers (405B’s hidden dimension). That’s 32 KB of meaning per token; your 1,000-token prompt becomes a 1,000 × 16,384 grid of numbers ready for arithmetic — 16.4 million values, and still the meter reads zero, because a lookup is a copy, not a computation. Everything so far was clerical. The next chapter meets the thing the grid is about to hit: 405 billion learned numbers, and the machines that hold them.

inside the model one token is 16,384 numbers — 32 KB of meaning apiece, before any math happens
deep dive: tokenizer fine print

Byte-level fallback. Modern vocabularies bottom out at raw bytes, so there is no such thing as an unknown token — any string, in any script, tokenizes to something. The cost of weirdness is length, not failure.

Why vocab sizes cluster at 32K–256K. A bigger vocabulary means shorter sequences (cheaper attention) but a bigger embedding table and softmax. The sweet spot has drifted upward with model size: Llama 2 used 32,000, Llama 3 jumped to 128,256, o200k sits near 200,000.

Images are tokens too. Multimodal models slice images into patch tokens — a photo costs ~85 tokens at low detail to ~1,600+ at high detail in OpenAI’s scheme. The context window doesn’t care what a token means, only that it counts.

Glitch tokens. Strings like SolidGoldMagikarp made it into GPT-2/3’s vocabulary from scraped data (a Reddit username) but barely appeared in training — prompting older models with them produced babble, evasion, or insults. A vocabulary entry with no learned meaning is a tiny haunted house.

The ugliest surviving part of the stack. Karpathy’s judgment stands: most LLM “weirdness” — arithmetic failures, spelling blindness, language inequity — traces back to tokenization. Byte-level and tokenizer-free architectures keep being proposed; the lookup table keeps winning on cost.

01

The thing your question hits

Your 1,000 tokens arrive at a server rack. What is physically waiting there? Not a program in any usual sense — a single enormous array of learned numbers, sharded across eight GPUs, resident in memory day and night. This chapter weighs the thing itself: how many numbers, how many bytes, why it fits on no single chip, and why it never, ever gets unloaded. The meter stays at zero one more chapter — numbers sitting still compute nothing.

STEP 01 / 05
405,000,000,000 DIALS
parameter counts, on the only axis that fits them — a log scale
GPT-21.5B · 2019
GPT-3175B · 2020
Llama 3.1405B · 2024
10⁹10¹⁰10¹¹10¹²
now print them, one per millimeter:
moon · 384,400 km405B params · 405,000 km ↦

A model is its : 405 billion learned numbers arranged into a few hundred giant matrices. Nothing else — no database, no rules, no code that “understands.” The count is the industry’s headline stat for a reason: GPT-2 (2019) had 1.5B, GPT-3 (2020) 175B, and by 2024 you could download 405B of open weights. For scale: print one parameter per millimeter and the line runs 405,000 km — past the Moon (384,400 km away). Every one of those dials was set by training; your request will disturb none of them — inference only reads.

one parameter per millimeter: 405B parameters stretch 405,000 km — past the Moon
STEP 02 / 05
810 GIGABYTES OF KNOWING
the model on disk — a directory listing with no secrets in it
model.safetensors···············810,000,000,000 bytes
facts.db···············not found
rules.txt···············not found
paris_is_in_france.json···············not found
≈ 34 × English Wikipedia (24 GB of text) — shown half, ran out of panel

Each parameter is a 16-bit number — 2 bytes — so the model is, physically, an 810 GB pile of floats. That pile is the knowledge: that Paris is in France, how Python indents, why sunsets redden — all of it is somehow in the matrices, and nobody can point to where. For contrast, the text of English Wikipedia compresses to ~24 GB. The weights are ~34 Wikipedias of bytes holding a lossy digest of far more. There is no file inside labeled facts.db; interpretability research is the ongoing attempt to find out where “Paris” lives.

the model “knows” Paris is in France somewhere in 810 GB of floats — and nobody can point to where
STEP 03 / 05
IT FITS ON NO CHIP ON EARTH
tensor parallelism — the model, cut into eight and made to confer
one model · 810 GB · fits nowhere
H100
51/80
H100
51/80
H100
51/80
H100
51/80
H100
51/80
H100
51/80
H100
51/80
H100
51/80
NVLink · 900 GB/s per GPUconfers on every layer of every token

The fastest memory money can buy — stacked directly on the GPU — tops out at 80 GB on an H100. The model is 810 GB. No single accelerator on Earth holds it, so serving begins with surgery: slices every matrix into 8 shards across 8 GPUs, which then must confer over NVLink at 900 GB/s on every layer of every token. Every frontier answer you have ever received was a group project — computed by a committee of chips voting in nanoseconds.

no chip on Earth holds a frontier model — every answer is a committee of 8+ GPUs conferring on every layer
STEP 04 / 05
THE FP8 DIET
quantization — the same dial, described in half the bits
weight[2,147,483,648] = 0.03271484
BF16 → FP8
810 GB+235 GB freed for KV cache
accuracy: −0.2 benchmark pts · nobody noticed

810 GB across eight 80-GB cards leaves no room for anything else — so production serving puts the model on a diet. stores each weight in fewer bits: FP8 halves every number to 1 byte — 810 → 405 GB — with accuracy loss measured in fractions of a benchmark point; 4-bit halves it again (203 GB) and is how a 405B-class model squeezes onto hobbyist rigs. Our node serves FP8: 405 GB of weights, 235 GB left over for the working memory the next chapters will spend. Precision, it turns out, is mostly padding.

halve the precision of every one of 405 billion numbers and the model barely notices — FP8 is standard serving
STEP 05 / 05
THE MODEL NEVER SLEEPS (BECAUSE LOADING TAKES MINUTES)
two ways to serve 405 GB — only one of them has users left
COLD START · load on requestuser left at ~8 s
405 GB @ 10 GB/s40.5 s to ready
RESIDENT · loaded once, never dropped$24/hr, answering or not
weights in HBM · 24/7ready in 0 ms
→ your 1,000 tokens land on a machine that was already awake

Could the server load the model when your question arrives? 405 GB over a very good 10 GB/s disk array is 40+ seconds — over a typical network, minutes. Nobody waits that long, so weights are loaded once and stay resident in HBM around the clock, request or no request. That standby has a price: an 8×H100 node rents for roughly $24 an hour whether it’s answering questions or listening to silence — which is why idle GPUs are the industry’s quietest money leak, and why strangers together (chapter 04) is a moral imperative of the economics.

the model is never “opened” — it sits in GPU memory 24/7 at ~$24/hour, answering or not
deep dive: parameter fine print

Total vs active: the MoE asterisk. Mixture-of-experts models route each token through a fraction of their weights: DeepSeek-V3 is 671B total but 37B active per token; Llama 4 Maverick 400B/17B. Param counts stopped being comparable across architectures — always ask which number you’re being told.

The rumor economy. Closed labs stopped publishing counts after GPT-3; GPT-4’s widely-reported ~1.8T MoE figure is a leak, not a paper. The open models are where the checkable numbers live — which is exactly why this tutorial rides one.

The VRAM napkin. Will it fit? Weights (params × bytes) + KV cache (chapter 03’s ½ MB/token × context × batch) + activations (small at inference). An 8×80 GB node at FP8 = 640 GB budget: 405 weights + 235 for everything else. Every deployment conversation is this arithmetic.

Why not just always 4-bit? Quality loss is real but small and task-dependent (long-tail knowledge and math degrade first). The industry default drifted FP16 → FP8 → FP4 with each hardware generation shipping native support — Blackwell does FP4 in silicon.

02

The small fast world

Before the big numbers, the smallest ones. This chapter drops to the floor of the ladder — the single operation, measured in femtoseconds and picojoules — and meets the physical law that governs everything above it: arithmetic is nearly free, and moving data to the arithmetic is not. The meter ticks exactly once, from 0 to 2. Everything else here is calibration you’ll spend in the next four chapters.

STEP 01 / 05
THE METER’S FIRST TICK: ONE MAC, 2 FLOPS
the atom of AI — one multiply-accumulate, at last
0.031 × 0.882 + 0.104=0.13131 multiply + 1 add = 2 FLOPs
Σ FLOPS
2
— after two chapters of zero, the first tick
elapsed: ~2 femtoseconds · light traveled 0.6 µm — a bacterium is bigger

The atom of all of AI is the multiply-accumulate — : a × b + c, two floating-point operations. Every embedding, every attention score, every one of the 405 billion weights participates in the answer only through this one primitive, repeated ~10¹⁵ times. At an H100’s pace one MAC amortizes to ~2 femtoseconds — 2×10⁻¹⁵ s, an interval in which light itself travels 0.6 micrometers, less than the width of a bacterium. After two chapters at zero, the meter finally moves: Σ 2 FLOPs.

one multiply-add amortizes to ~2 femtoseconds — light crosses 0.6 µm in that time, less than a bacterium
STEP 02 / 05
989,000,000,000,000 PER SECOND
twenty-two years of “fastest thing on Earth” — log scale, as always here
12.3 TF
ASCI White2000 · #1 · 106 t · $110M
989 TF
one H1002022 · 700 W · handheld
15.8 PF
our node · 8× FP8…and it will still wait
×80 the year-2000 champion, per card* · *precision differs — scale, not substitution

One H100 sustains up to 989 trillion of those operations per second in BF16 — 1,979 trillion in FP8 — from a 700-watt card you can lift with one hand. Calibration: the fastest computer on Earth in June 2000, ASCI White, peaked at 12.3 TFLOPS, weighed 106 tons, and cost $110M. At AI precision, one H100 out-computes it ~80-fold (an honest asterisk: ASCI White ran 64-bit science; the comparison is about scale, not substitution). Our node has eight of them — ~15.8 FP8 petaFLOPS on tap — and, as the next step shows, they will still spend most of their time waiting.

one 700 W card ≈ 80× the operations/second of the year-2000 world-champion supercomputer (106 tons, $110M)
STEP 03 / 05
THE MEMORY WALL: MOVING BEATS MULTIPLYING, 170 TO 1
the energy bill of one number, two ways (Horowitz, ISSCC 2014, 45 nm)
multiply it
×
3.7 pJ
fetch it first
DRAM
640 pJ
×170 — the memory wall · and the gap keeps widening

Here is the number that runs the industry, and almost nobody quotes it. Measured at silicon level (Horowitz, ISSCC 2014): a 32-bit floating-point multiply costs ~3.7 picojoules; fetching those same 32 bits from DRAM costs ~640 pJ — moving a number is ~170× more expensive than multiplying it. And compute has been improving faster than memory for decades, so the gap grows. This is the , and it inverts every intuition: the question is never “can the GPU do the math?” — it’s “can memory feed the math?” Remember 170:1; chapters 03–05 are consequences of it.

fetching a number from memory costs ~170× the energy of multiplying it — the wall the whole field is built against
STEP 04 / 05
3.35 TERABYTES PER SECOND (WRITE THIS ONE DOWN)
one full read of the model — the division to memorize
HBM
405 GB FP8
26.8 TB/s aggregate · every weight, exactly once

H100
405 GB ÷ 26.8 TB/s =15.1 ms
⚑ bookmark this — in chapter 04 it becomes the speed of every word

The counter-weapon is : DRAM stacked on top of the processor. One H100 reads its 80 GB at 3.35 TB/s — an entire Blu-ray collection per second. Now the division that will explain the next two chapters: our model is 405 GB of FP8 weights; reading it once through one GPU’s 3.35 TB/s takes 121 ms — spread across all 8 GPUs, ~15 ms. Fifteen milliseconds just to look at every weight once, before any arithmetic is even attempted. Hold that number; in chapter 04 it becomes the speed limit of every word the model says.

even at 26.8 TB/s of aggregate bandwidth, reading the model once takes ~15 ms — remember this number
STEP 05 / 05
THE ROOFLINE: WHY A $30,000 GPU IDLES
the roofline — how busy the silicon gets, by FLOPs-per-byte
speed ↑FLOPs / byte →
ridge: 590
prefill · ~1,000s
decode, batch-1 · ~2
<1% busy — the $30,000 chip is waiting on memory, not thinking

Whether hardware runs at full speed comes down to one ratio — : FLOPs performed per byte fetched. An H100 needs ~590 FLOPs per byte (1,979 TF ÷ 3.35 TB/s) to stay busy. Big matrix-×-matrix work — a full prompt at once, many users batched — clears that bar easily. But generating one token for one user is matrix-×-vector: each weight byte is used for ~2 FLOPs, then discarded — 0.3% of the bar. The most expensive chip in the building does arithmetic well under 1% of the time at batch size 1. It isn’t a math machine; it’s a memory pump with a math habit.

at batch size 1, a $30,000 GPU computes <1% of the time — it’s a memory pump with a math habit
deep dive: the hardware ladder, 2026 edition

Above the H100. B200/GB200 (Blackwell): HBM3e, native FP4, and NVL72 racks that make 72 GPUs behave like one — the industry’s answer to the memory wall being “buy more wall.” TPUs take the systolic-array route: silicon shaped exactly like a matrix multiply.

The SRAM heretics. Groq and Cerebras skip HBM entirely, keeping weights in on-chip SRAM (orders of magnitude faster, and tiny). Result: 1,000+ tokens/s on models that fit — proof that decode speed is purely a memory story.

The interconnect ladder. Every request descends it: HBM 3.35 TB/s → NVLink 900 GB/s → InfiniBand ~50 GB/s → datacenter Ethernet. Each hop is roughly an order of magnitude slower — which is why sharding within a node is routine and sharding across nodes is a last resort.

MFU, the honesty metric. Datasheet FLOPS assume a perfect kernel with perfect data flow. Real workloads sustain a fraction: Meta’s tuned 405B training run held 38–43% MFU — and that’s considered excellent. When someone quotes peak TFLOPS, divide by two and a half.

03

Reading the question

The 1,000 embedded tokens meet the 405 billion weights. What happens in the 200 silent milliseconds before the first word of the answer appears? The meter finally earns its fourteen zeros — 810 trillion operations just to read the question — and yet this turns out to be the cheap, fast, hardware-friendly half of inference. This chapter is that gulp: the FLOPs, the parallelism, the user-facing silence it becomes, and the ½-megabyte notes it leaves behind per token.

STEP 01 / 05
EVERY TOKEN VISITS EVERY WEIGHT
the tour — no skipping
1,000 tokens ↓
layer 1 · every weight touched
layer 2 · every weight touched
· every weight touched
layer 125 · every weight touched
layer 126 · every weight touched
Σ FLOPS
2
2 FLOPs × 405×10⁹ params × 1,000 tokens — fourteen orders of magnitude in one step

The forward pass is not a lookup — it is a full tour. Each token’s vector is multiplied through essentially all 405 billion : ~2 FLOPs per parameter per token, or 810 GFLOPs per token. There is no shortcut, no index, no skipping to the relevant parts; the relevance is computed by the multiplication. Your 1,000-token prompt therefore costs 1,000 × 810 GFLOPs = 810,000,000,000,000 FLOPs just to be read. The meter, stuck at 2 for a whole chapter, jumps fourteen orders of magnitude in one step.

FLOPs per token ≈ 2 × parameters — reading ONE token through 405B params is 810 billion operations
STEP 02 / 05
ALL AT ONCE: WHY READING IS THE CHEAP PART
prefill — one matmul the size of the whole prompt
1,000
× 16,384
×
405B
weights
tensor cores: busy
all 1,000 tokens, in parallel:129 ms
one at a time: ~15 s — nobody does this

810 trillion operations sounds fatal — it takes ~130 ms. The trick: processes all 1,000 tokens simultaneously, as one giant matrix-×-matrix multiplication — exactly the high-arithmetic-intensity shape from the roofline step, thousands of FLOPs per byte, tensor cores saturated. 8.1×10¹⁴ FLOPs ÷ ~6.3 effective PFLOPS (the node at ~40% ) ≈ 129 ms. The model reads your entire prompt in one parallel gulp. This is the half of inference hardware loves — the other half, one chapter away, is the one it hates.

the model reads all 1,000 prompt tokens at once — one giant matmul, ~130 ms, tensor cores actually busy
STEP 03 / 05
TTFT: THE SILENCE YOU CAN FEEL
time to first token — where the silence goes
this request · 1,000-token promptTTFT ≈ 200 ms
queue 20 msnetwork 50 msprefill 129 ms
100 ms · feels instant1 s · flow unbroken10 s · user gone
same model · 100K-token prompt pastedTTFT ≈ 13 s of dead air
reading. just reading. 8.1×10¹⁶ FLOPs of reading.

Prefill time surfaces in the product as — the “thinking…” silence between Enter and the first word. Our request: ~130 ms of prefill + queueing and network ≈ 200 ms, comfortably under the ~1-second threshold where a user’s flow of thought breaks (Nielsen’s 1993 numbers still hold). But TTFT scales with prompt length: paste a 100,000-token codebase and prefill alone is 2 × 405×10⁹ × 10⁵ = 8.1×10¹⁶ FLOPs ≈ 13 seconds of dead air. Every “why is it just sitting there?” bug report is this arithmetic, rediscovered.

TTFT is just prefill, seen from the user’s side — paste a 100K-token codebase and the “thinking…” is 13 s of pure reading
STEP 04 / 05
THE MODEL TAKES NOTES: ½ MB PER TOKEN
notes per token
516,096 B / token
1,000 tok = 0.5 GB
…at a full 128K context
66 GB
HBM
one H100 · 80 GB
the “long context surcharge” is this bar’s rent

Prefill leaves something behind. Attention requires every later token to consult every earlier one, and recomputing that would be quadratic suicide — so the model caches each token’s keys and values: the . For 405B: 2 × 126 layers × 8 KV-heads × 128 dims × 2 bytes = 516,096 bytes ≈ ½ MB per token. Your 1,000-token prompt just parked 0.5 GB of notes in HBM — and a full 128K context parks 66 GB, nearly a whole H100 of the eight. When long-context pricing looks steep, this is the real estate it’s paying for.

the model’s working memory costs ½ MB per token — a full 128K context is 66 GB of notes, most of an H100
STEP 05 / 05
THE CONTEXT LADDER, AND THE ROT AT THE TOP
the context-window ladder, 2019 → 2025 — and what attention did
answer quality on the same simple task↘ context rot
1K'19
2K'20
32K'23
200K'24
2M'24
10M'25
tokens the window holds · log scale · ×10,000 in six years
rot ≠ full — 18 frontier models degrade long before the window fills (Chroma, 2025)

The window those notes live in has exploded: GPT-2 held 1,024 tokens (2019); GPT-3, 2,048; GPT-4 launched at 8K/32K (2023); Claude hit 100K then 200K; Gemini 1.5 reached 2M; Llama 4 Scout claims 10 million — a ~10,000× climb in six years. But capacity outran attention: Chroma’s 2025 “” study measured 18 frontier models degrading as input grows even on trivial tasks, long before the window fills. A window is an invitation, not a promise: the model holds 10M tokens the way you hold a phone book — technically, all of it; usefully, the page you’re on.

context windows grew ~10,000× in six years — measured attention quality didn’t keep up (rot sets in before “full”)
deep dive: attention’s fine print

Where 2N bends. The 2-FLOPs-per-param rule ignores attention’s O(n²) term — negligible at 1,000 tokens, dominant past ~100K. Long-context prefill is quadratically worse than the napkin says, which is another reason long prompts bill extra.

FlashAttention. The memory wall strikes inside attention too: the naive n×n score matrix wouldn’t fit in fast memory. FlashAttention computes attention in tiles that never leave on-chip SRAM — an IO-aware algorithm; same FLOPs, far fewer bytes moved. The 170:1 lesson, applied.

GQA, already priced in. Full multi-head attention would store keys/values for all 128 query heads — 8 MB per token. Grouped-query attention shares 8 KV heads across them: 16× smaller. Our ½ MB figure is the discount already applied.

Prefix caching. If the first 988 tokens are the same for every user (they are — that’s the system prompt), prefill them once and keep the KV. This is exactly what providers sell as prompt caching at ~90% off — chapter 05 shows the price tag. Moral: keep your system prompt byte-stable.

Chunked prefill. A 100K-token prefill would monopolize the node for seconds, starving everyone mid-decode. Servers slice big prefills into chunks and interleave them with decode steps — one more scheduler trick between you and the datasheet.

04

Writing the answer

The first token appears at t+200 ms. The remaining 299 take nine more seconds. You now have the tools to answer why: why is writing 40× slower than reading, when it’s the same weights and the same arithmetic? (Chapter 02’s bookmark — 15 ms to read the model once — is about to become the punchline.) Along the way: why streaming exists, why batching is the entire economics of inference, and the draft-and-grade trick that speeds decode without changing a single output token.

STEP 01 / 05
ONE. TOKEN. AT. A. TIME.
autoregression — the loop you watch every time text “types itself”
context
model
next token
append
answer:
The sky is
lap 3 / 300
token №2 before №1? ✕ depends on previous — no skipping ahead, ever

Generation is : the model predicts one token, appends it to the context, and runs again — because token №2 depends on token №1, there is nothing to parallelize inside your own answer. The 1,000-token prompt was read in one gulp; the 300-token answer will be 300 separate full passes through the model. This is the serial heart of the whole product experience: the typing effect in every chat window isn’t a UI flourish, it’s the physics of the loop, streamed to you at its native speed.

the typing effect in chat windows isn’t cosmetic — you are watching the model’s actual generation loop in real time
STEP 02 / 05
EVERY WORD RE-READS ALL 405 GIGABYTES
the price of one word — the whole model, through the pipe, again
weights
405 GB
every byte, every token · 26.8 TB/s
“grand”
“canyon”
the math itself
~0.1 ms
reading the weights
15 ms floor
real serving: ~33 tok/s · 30 ms/token · 300 tokens ≈ 9.1 s

Here the bookmark from chapter 02 pays off. Each decode step multiplies one vector through all the weights — which means all 405 GB stream from through the cores for every single token. Chapter 02’s floor: ~15 ms per read at 26.8 TB/s. That is the speed limit — not FLOPs (a token’s 810 GFLOPs would take ~0.1 ms of pure compute), bandwidth. Real serving lands at 30–60 tok/s; our request runs at ~33 tok/s, 30 ms per token: 299 more tokens ≈ 9.1 seconds. Generation speed is a memory-bandwidth number, not a compute one.

every word the model says re-reads all 405 GB of weights — token speed is a bandwidth number, not a compute one
STEP 03 / 05
FASTER THAN YOU CAN READ (ON PURPOSE)
the same paragraph, consumed — writer vs reader
MODEL · writing33 tok/s ≈ 1,500 wpm
YOU · reading~238 wpm ≈ 5 tok/s
REASONING MODEL · “thinking” before word one2,400 tokens · billed, unseen
×6 your reading speed — that’s why streaming feels instant at 9 s total

Is 33 tokens/second slow? Humans read English at ~238 words per minute — about 5 tokens per second. The model writes 6× faster than you can read, which is why streaming works as UX: the text outruns your eyes, so generation feels instant even though it takes 9 seconds. The budgets flip for machine consumers: an agent chaining 7 calls (see the agent tutorial) waits on every one serially, and “reasoning” models burn thousands of decode tokens thinking before the first visible word — decode you pay for, at output prices, that no human ever reads.

you read ~5 tokens/s; the model writes 33 — streaming works because the text outruns your eyes
STEP 04 / 05
BATCHING: 64 STRANGERS SHARE THE READ
one 405 GB read — how many tokens does it buy?
batch 1 · 1 token / readutil <1%
batch 64 · 64 tokens / readsame 405 GB, split 64 ways
cost per token:¢¢¢→ ¢/64 · you never rode alone

The 405-GB-per-token read is decode’s shame — and its business model. The read serves one token for one user… but the same read can serve 64 tokens for 64 users at once: stack their vectors, multiply through the weights together, and per-user cost collapses ~64× until compute becomes the binding wall again. — admitting new requests mid-flight as others finish — is the single most important serving optimization in existence. It is why your quadrillion-FLOP answer will cost cents: you never rode alone.

64 strangers’ answers ride one 405 GB weight-read — batching is the reason tokens cost cents, not dollars
STEP 05 / 05
A SMALL MODEL GUESSES, THE BIG ONE GRADES
speculative decoding — and the end of the answer
DRAFT
8B · fast
at
the
horizon
,
sunlight
light
VERIFY
405B · one pass
4 of 5 accepted in one parallel pass · output provably identical · 2–3× faster
<eos> · token 300 · t+9.3 s
Σ 1,053,000,000,000,000 FLOPs

One more trick bends the serial law. : a small, fast draft model guesses the next 4–8 tokens; the big model then verifies the whole guess in one parallel pass — checking is a prefill-shaped problem, so it’s cheap. Accepted tokens ship; the first wrong one is discarded and decoding resumes — provably identical output, 2–3× faster. At t+9.3 s our model emits <eos> — end of sequence, token 300. The meter rests: Σ 1,053,000,000,000,000 FLOPs. A quadrillion operations to explain a sunset. Now: the receipt.

speculative decoding: a small model drafts, the big one grades — mathematically identical output, 2–3× faster
deep dive: serving-room machinery

Continuous batching (Orca, 2022). Static batching waited for the slowest request in the batch; continuous batching admits and retires requests every step. Throughput gains of 10–20× over naive serving came from scheduling alone — no model change.

PagedAttention / vLLM. KV caches used to be allocated as contiguous max-length blocks — mostly-empty reservations that wasted 60–80% of memory. vLLM manages KV like virtual-memory pages, cutting waste to <4% and lifting real-world throughput 2–4×. Operating-systems ideas keep winning in inference.

Disaggregated serving. Prefill wants maximum compute; decode wants maximum bandwidth per byte of KV. Big providers now run them on separate GPU pools and ship the KV cache between them — the two halves of your request may never touch the same silicon.

Why your local 405B is slower. Benchmarks quote batched throughput; alone at batch 1 you get the bandwidth floor and nothing amortized. Same math explains Groq/Cerebras headlines in reverse: SRAM bandwidth turns the same model into a 1,000+ tok/s sprinter.

The TTFT ↔ throughput dial. Bigger batches = more tokens/s served, worse individual latency. Every provider’s “speed” is a chosen point on that curve, and the SLO (time to first token vs tokens/s) is set by the business, not by the hardware.

05

What one answer costs

The answer is on your screen. Somebody now has to pay for a quadrillion operations and three hundred re-reads of a 405 GB file — so why is the invoice less than a cent? This chapter reads the receipt line by line and finds the previous four chapters hiding in it: the memory wall priced as the output premium, the KV cache resold as a caching discount, batching as the reason any of it costs cents. The Σ meter stays frozen throughout: money is arithmetic about FLOPs, not FLOPs.

STEP 01 / 05
THE RECEIPT: THREE-QUARTERS OF A CENT
the itemized receipt for one answered question
··· INFERENCE RECEIPT · 09:00:09.3 ···
input · 1,000 tok @ $3/M·············$0.0030
output · 300 tok @ $15/M·············$0.0045
8× H100 · 9.3 s · 10¹⁵ FLOPs·············included
TOTAL·············$0.0075
PAID · ¾¢
≈ 1.4×10¹⁷ FLOPs per dollar · Σ meter frozen — money isn’t FLOPs

At representative frontier-class pricing — $3 per million input tokens, $15 per million output — the damage is: 1,000 in = $0.003; 300 out = $0.0045; total $0.0075. A quadrillion FLOPs, eight GPUs conferring for 9.3 seconds, 405 GB read three hundred times: three-quarters of one cent, retail. The meter freezes this chapter — money is arithmetic about FLOPs, not FLOPs — but stare at the ratio: ~1.4×10¹⁷ FLOPs per dollar. The deflation curve behind that number is the story of the decade, and it’s step 4.

a quadrillion operations, 405 GB read 300 times, 8 GPUs, 9.3 seconds — retail price: ¾ of one cent
STEP 02 / 05
THE PRICE SHEET IS A SYSTEMS DIAGRAM
the price sheet, annotated — architecture wearing dollar signs
cached input
$0.30/M
← ch 03: the KV notes, resold at 90% off
input
$3/M
← ch 03: one parallel gulp — hardware likes reading
output
$15/M
← ch 04: 405 GB re-read per word — the wall, invoiced
output ÷ input = 5× — the roofline’s two dots, as a ratio on an invoice

Look closer at the menu and the whole tutorial reappears as pricing. Output costs 5× input ($15 vs $3): decode holds the machine serially (chapter 04) while prefill batches well (chapter 03) — the asymmetry is the roofline, invoiced. costs $0.30/M — 90% off: a re-sent system prompt re-uses stored KV (chapter 03’s notes) instead of re-prefilling. Long context bills extra past thresholds: that’s the 66-GB KV real estate. Every line item is a hardware fact wearing a dollar sign.

read the price sheet as architecture: output 5× input = the memory wall; cached input 90% off = the KV cache, resold
STEP 03 / 05
THE MENU SPANS 1,800×
the mid-2026 menu
small open models~$0.10/M
workhorse tier$1–5/M
frontier$15–25/M
frontier-pro$180/M
×1,800
$ per million output · log
the discipline it created: routing
classify a ticketcheapest
draft an emailworkhorse
find the race conditionfrontier-pro
model choice > any prompt trick

Zoom out from one model to the whole mid-2026 menu and the spread is comic: the cheapest usable API token (small open models) runs ~$0.10 per million output; the priciest frontier tier lists at $180 per million — a ~1,800× range on the same unit. No other commodity is priced like this. The engineering discipline it created is routing (the agent tutorial’s first move): classify the task, spend Opus-class tokens only where Haiku-class fails. Model choice is a bigger cost lever than any prompt optimization ever written.

the priciest API token costs ~1,800× the cheapest — picking the right model beats any prompt trick ever written
STEP 04 / 05
LLMFLATION: 1,000× CHEAPER IN 3 YEARS
the price of GPT-3-quality output (MMLU ≈ 42), 2021 → 2024 — log scale
the frontier: ~$60/M, always — only the name on it changes
GPT-3 $60
3.5-turbo $2
Llama 3 8B $0.20
3.2 3B $0.06
÷1,000 in 3 years
~10×/year at fixed quality — faster than Moore, faster than dotcom bandwidth

Now the axis nobody believes until they see it dated. GPT-3-quality output (MMLU ≈ 42) cost $60 per million tokens in November 2021. By late 2024 the cheapest model matching that score cost $0.06 per million — a 1,000× collapse in 3 years, ~10× per year, faster than Moore’s law ever moved and faster than dotcom bandwidth deflated (a16z named it “LLMflation”). The twist: the frontier price barely moves — o1 launched at the same $60/M output that GPT-3 launched at. Capability at fixed price explodes; price at fixed capability collapses; the invoice line stays the same and only the model behind it changes.

GPT-3-quality tokens: $60/M in 2021 → $0.06/M in 2024 — 1,000× deflation in 3 years, ~10×/year
STEP 05 / 05
THE WATT-HOUR ANSWER
the median text prompt, measured in production (Google, Aug 2025)
0.24 Wh
energy
≈ 9 s of television
0.03 g
CO₂e
per prompt
0.26 mL
water
about five drops
÷33 in one year — batching, quantization, better silicon: chapters 01–04, again

The other bill. In August 2025 Google published the first serious production measurement: the median Gemini text prompt = 0.24 Wh of energy, 0.03 g CO₂e, and 0.26 mL of water — about five drops. 0.24 Wh is ~9 seconds of television. And the same report’s buried headline: that footprint fell 33× in one year — , , better silicon: chapters 01–04, again. Honest ledger: per-prompt is small; the aggregate — billions of prompts, and chapter 06’s training runs — is the number utilities plan around.

one prompt ≈ 0.24 Wh — nine seconds of TV, five drops of water — and it fell 33× in a single year
deep dive: the bill’s fine print

Cache writes cost extra. Before reads get 90% off, writing the cache bills a ~1.25× premium — caching is a bet that the prefix will be reused. Stable system prompts win the bet; timestamps in your system prompt lose it byte by byte.

Batch APIs: 50% off for patience. Submit jobs to run within 24 h and pay half — the provider schedules you into idle capacity. The discount is literally the shape of their load curve.

Reasoning tokens bill as output. The thousands of “thinking” tokens a reasoning model burns are decode at full output price, whether or not you ever display them. A hard question can silently cost 10–50× its visible answer.

$/token is the wrong unit for agents. A 7-call agent loop re-reads its whole history each call (see the agent tutorial’s 43,230-token ticket) — the honest unit is $/task, and it multiplies fast. Rate limits, not prices, are usually what actually gates production: tokens-per-minute quotas are the real scarcity.

The margin debate. Analyst estimates put inference pricing at roughly 5–10× the raw compute cost at scale — the profit pool that 10×/yr deflation keeps eating. When a price drops 80% overnight, it’s the curve arriving, not charity.

06

The numbers behind the weights

Your request is closed: answered, billed, forgotten by the server in milliseconds. But the 405 GB it flowed through — someone set every one of those dials, once, at colossal expense. This final numbered chapter opens the other ledger: the training run. One napkin formula, one staggering division, a finite library, a cluster where failure is weather, and the growth curve that dates every number in this tutorial. The Σ meter can’t contain it; it gets a second line.

STEP 01 / 05
6ND: A NINE-FIGURE BILL ON A NAPKIN
the training-cost napkin — one multiplication, nine figures
FLOPs ≈ 6 ×N = 405×10⁹×D = 15.6×10¹²
= 3.79×10²⁵
published: 3.8×10²⁵ ✓ Δ<1%
10²⁴10²⁵ · EU AI Act line10²⁶ · US reporting line10²⁷
the napkin, regulated — this run sits just past the EU threshold

Training cost has a napkin formula as clean as inference’s 2N: FLOPs ≈ 6 × N × D — six operations per parameter per training token (2 for the forward pass, 4 for the backward). Plug in Llama 3.1 405B: 6 × 405×10⁹ × 15.6×10¹² tokens = 3.79×10²⁵ — Meta’s published figure is 3.8×10²⁵, a miss of under 1%. One multiplication predicts a nine-figure industrial project. Every training-compute number in every AI-policy debate (the EU Act’s 10²⁵ threshold, the US 10²⁶ reporting line) is this napkin, regulated.

6 × params × tokens predicts a $100M training run within 1% — the napkin formula written into AI law
STEP 02 / 05
YOUR REQUEST, TIMES 36 BILLION
THE TWO METERS
training3.8×10²⁵
your request1.05×10¹⁵
= 36,000,000,000
requests of prepaid compute — one per 5 humans alive, ×25
every dot ≈ 375M requests · the bright one is you

Divide the two meters this tutorial has been keeping: training 3.8×10²⁵ ÷ your request’s 1.05×10¹⁵ = ~36,000,000,000. The run that set the dials equals 36 billion of your sunset questions — roughly one for every five humans alive, asked 25 times each. This is the deepest economic fact in AI: capability is bought in one colossal prepayment, then amortized over inference forever after. It is why labs overtrain (next step), why weights are guarded like reactors, and why your ¾¢ receipt is, in accounting truth, a 36-billionth share of a datacenter’s season.

the weights carry a debt of 36 billion requests’ worth of compute — you just paid back exactly one
STEP 03 / 05
15.6 TRILLION TOKENS: EATING THE LIBRARY
the library — everything good ever written in public, as a fuel gauge
0~300T tokens of quality public human text (Epoch AI)
empty ~2028
GPT-3 · 0.3T
Llama 3 · 15.6T
frontier ’26 · ~100T+
full-use window: 2026–2032, median 2028 — earlier if overtrained
Chinchilla-optimal:20 tok/param
Llama 3.1 fed:39 tok/param— on purpose: inference is forever

The D in the formula: 15.6 trillion training tokens — call it 12 million novels’ worth of text. The 2022 Chinchilla result said compute-optimal training wants ~20 tokens per parameter (405B → 8.1T); Meta fed it nearly double, on purpose — over-training wastes training compute to buy a smaller, cheaper-to-serve model, because inference is forever ( are advice, not law). The ceiling is in sight: Epoch AI estimates the total stock of quality public human text at ~300 trillion tokens, on track to be fully used by frontier training between 2026 and 2032 (median ~2028). The library is finite, and the industry is a fast reader.

the internet’s entire stock of good text is ~300T tokens — frontier labs are on pace to have read all of it by ~2028
STEP 04 / 05
54 DAYS, 16,384 GPUS, ONE FAILURE EVERY 3 HOURS
54 days · 16,384 H100s — failure as weather, not incident
419 unexpected interruptionsMTBF ≈ 3 hours78% hardware · GPUs + HBM3 lead416 auto-healed · 3 humans paged
FINISHED · >90% EFFECTIVE TRAINING TIME

The run itself, from Meta’s paper: 16,384 H100s for 54 days — 30.84 million GPU-hours, ~11.5 MW of GPUs before cooling, ~22 GWh, ~2,000 US-home-years of electricity for one model. The detail every infrastructure engineer frames on the wall: the cluster suffered 419 unexpected interruptions — one every three hours, for eight straight weeks — 78% of them hardware, GPUs and their the top culprits. And it still finished, at >90% effective training time, because all but three failures were healed by automation. At 16,384 GPUs, hardware failure isn’t an incident; it’s weather.

Meta’s cluster broke every 3 hours for 54 straight days — and kept >90% uptime; all but 3 of 419 failures self-healed
STEP 05 / 05
THE CURVE THAT EATS THE LADDER
frontier training compute, 2012 → 2026 — a billion-fold climb
×4–5 / year — doubling every ~6 months
Moore’s law (2-yr doubling)
AlexNet ’125×10¹⁷
GPT-3 ’203×10²³
Llama 405B ’243.8×10²⁵
Grok 4 ’265×10²⁶
1 GW runs · ~2030?
every absolute number on tonight’s card is this curve, mid-flight

Last rung — the derivative. Frontier training compute has grown 4–5× per year for over a decade: AlexNet (2012) used ~5×10¹⁷ FLOPs; GPT-3 (2020) 3.1×10²³; our 405B (2024) 3.8×10²⁵; the largest known run by 2026 (Grok 4 class) ≈ 5×10²⁶. That is a billion-fold climb in fourteen years, doubling roughly every six months while transistors took two years. Costs run $10⁸ and rising; Epoch projects gigawatt-scale runs by 2030. Every absolute number on tonight’s card is a snapshot of this curve mid-flight — which is exactly why the card’s final section (Σ) insists on ratios, not constants.

frontier training compute doubles every ~6 months — Moore’s law took two years; the gap is the whole story
deep dive: training’s fine print

Where 6ND comes from. Forward pass: 2 FLOPs per param per token (chapter 03’s rule). Backward pass: gradients flow through every weight twice — roughly 2× the forward cost. 2 + 4 = 6. What it excludes: data pipelines, failed and ablation runs, evals, and post-training.

Post-training is compute-cheap, talent-expensive. RLHF/DPO/fine-tuning add single-digit percentages to the FLOPs bill; the expensive inputs are human preference data and researcher time. The 10²⁵ is almost all pretraining.

The falling floor. While the frontier climbs, the floor collapses: GPT-2 cost ~$43K to train in 2019; Karpathy’s llm.c reproduced it in 2024 for about $20 of spot H100 time. Yesterday’s frontier is today’s weekend project — the same curve, read from below.

Dodging the data wall. The ~2028 exhaustion date assumes human text only. The hedges: synthetic data (models teaching models), multimodal data (video is vast), and better data efficiency per token. Chinchilla optimality already bends when serving cost enters the objective — expect the 20:1 rule to keep bending.

The next binding constraint: electrons. Epoch projects frontier runs needing gigawatt-scale power by ~2030 — a large nuclear plant’s output for one training job. The bottleneck migrates: data (2028) → power (2030) → whatever survives contact with both.

Σ

The card, printed

The payoff the title promised — the heir to 2012’s “latency numbers every programmer should know,” with every row earned somewhere above (the right margin says where). One request descended it: femtoseconds to seasons, two FLOPs to 10²⁵, one question to the whole library.

AI NUMBERS EVERY AI ENGINEER SHOULD KNOW · MID-2026, FRONTIER-CLASS SERVING
1 token·······································~¾ word · ~4 chars00
1 token, embedded·······································16,384 numbers · 32 KB00
weights, 405B @ FP8·······································405 GB — fits no single chip01
one multiply-add·······································2 FLOPs · ~2 fs02
one H100·······································989 TFLOPS · 3.35 TB/s · 700 W02
move a number vs multiply it·······································~170× the energy02
FLOPs per token·······································2 × params ≈ 810 GFLOP03
KV cache·······································~0.5 MB/token · 66 GB @ 128K03
TTFT·······································~200 ms, grows with the prompt03
decode·······································15 ms/token floor · 30–60 tok/s04
a human reader·······································~5 tok/s04
price·······································$3 in · $15 out · $0.30 cached /M05
one answer·······································~¾¢ · 0.24 Wh · 5 drops of water05
price at fixed quality·······································falls ~10× per year05
training·······································6 × N × D FLOPs06
compute-optimal data·······································~20 tokens per parameter06
one frontier run·······································10²⁵–10²⁶ FLOPs · $10⁸ · ~2 months06
the good public internet·······································~300 T tokens — read by ~202806
frontier compute growth·······································×4–5 per year06
this request·······································1.05×10¹⁵ FLOPs · 9.3 s · $0.0075
its training debt·······································3.8×10²⁵ FLOPs · your share: 1/36 billion
card printed
numbers current mid-2026 · ratios good for longer · re-derive, don’t memorize