Log inStart free
LESSON 34.01 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Cost per token

Watch a GPU's hourly price turn into the price of one token.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 34.01 · COST CALCULATORSTEP 5.86 MS · 5,463 TOKENS/S · 77% EFFICIENT
01
Stage 1 of 6 · Decode step
One decode step reads all 15.01 GB of weights once. A batch of 32 shares that read.
Explain it simply

Each bar is one decode step on the H100. The ochre part reads the weights, and the teal part reads each request's KV cache. The weight read is the same for 1 request or 32. So a batch of 32 writes 5,463 tokens a second, 77% of 32 times one request's speed.

Three bars, one per batch size. At batch 32 a step takes 5.86 ms and the GPU writes 5,463 tokens per second.

prompt tokens, busy GPUsweights, GPUs, pricesoutput tokens, cost per tokenidle, restarts, latency targetdashed box: time the cache saves; dashed lines are labelled
batch 1weights 15.01 GB4.52 ms221 tokens/s100% batching efficiencymath 0.02 msbatch 84.82 ms1,658 tokens/s94% batching efficiencymath 0.12 msbatch 325.86 ms5,463 tokens/s77% batching efficiencymath 0.49 msone decode step(15.01 GB + 32 × 0.144 GB) ÷ 3.35 TB/s = 5.86 msbatch 1weights 15.01 GB4.52 ms221 tokens/s100% batching efficiencymath 0.02 msbatch 84.82 ms1,658 tokens/s94% batching efficiencymath 0.12 msbatch 325.86 ms5,463 tokens/s77% batching efficiencymath 0.49 msone decode step(15.01 GB + 32 × 0.144 GB) ÷ 3.35 TB/s = 5.86 ms
Toy: a help chat, 2.7M requests a day, 8B model, toy prices
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
t=W+b KVBW,tokens/s=bt\sy{t}{ink}{t} = \dfrac{\sy{w}{param}{W} + \sy{b}{param}{b}\,\sy{kv}{data}{KV}}{\sy{bw}{param}{BW}},\quad \sy{tps}{out}{\text{tokens/s}} = \dfrac{\sy{b}{param}{b}}{\sy{t}{ink}{t}}
t=15.01+32×0.1443350 s=5.86 ms,  32/t=5,463t = \dfrac{15.01 + 32\times 0.144}{3350}\,\text{s} = 5.86\,\text{ms},\ \ 32/t = 5{,}463

A step reads the weights once and each request's KV cache.

Common mix-ups

MYTHA GPU type with a cheaper hour gives cheaper tokens.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With FP16 weights, how many times more do 1M tokens cost at batch 1 than at 32?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.