What a Token Costs
Part 1 of 4
A working model of LLM inference built from two hardware numbers and two model numbers, and what it says about batching, speed, and price.
When Anthropic launched fast mode for Claude Opus 4.6, it charged six times the normal price per token for up to 2.5 times the output speed. Other coding tools sell similar tiers. That raises a few obvious questions. Why does paying more make tokens come out faster? Could you pay 100 times more and get tokens 100 times faster? And could you go the other way, accept a slow mode that takes minutes, and pay much less?
The answers come from a small model of how a transformer runs on a rack of GPUs. The same model explains why output tokens cost more than input tokens, why a cache hit costs a tenth of a normal input token or less, why very long contexts stay expensive, and why frontier models are trained on far more data than Chinchilla would suggest. This series builds that model from scratch.
This first part covers the core: two costs, two hardware limits, and the one knob that trades them off, which is batch size. Parts 2 to 4 apply it to hardware layout, API pricing, and training budgets.
The whole system on one page
Before any equations, here is the picture we're building toward.
Requests from many users arrive at a batcher. Every step, the batcher takes every sequence that's ready and runs them together through one forward pass of the model. That pass produces exactly one new token for each sequence, and then the next step starts. A step takes tens of milliseconds, so a sequence that's generating text goes around this loop about 40 times a second.
The model lives in a scale-up domain, which today usually means one rack of GPUs tied together by a fast switch. NVIDIA's GB200 NVL72 is the standard example: 72 GPUs, each with its own high-bandwidth memory (HBM). That HBM holds the model's weights, which every sequence shares, and the KV cache, which is a per-sequence record of every token the sequence has seen so far. Anything that has to leave the rack goes over a much slower network. KV caches that aren't in use can be parked in cheaper, slower memory such as host DRAM or flash.
Almost everything in this series comes from a handful of numbers about that picture.
Numbers to keep in your head
One more model property shows up in Part 3: the size of the KV cache per token, which ranges from about 1 KB to over 300 KB depending on how attention is designed.
The rest of this post derives the following results.
- Serving one sequence at a time costs hundreds to thousands of times more per token than serving a big batch, because every step has to read every weight no matter how many sequences share it.
- There is a hard floor on latency: the time to read all the weights from HBM once. Fast modes buy speed by running smaller batches, which moves you toward that floor and spreads the fixed cost of a step over fewer tokens.
- There is also a floor on cost. Once the batch is big enough, each token still needs its own multiply-adds and its own KV cache reads, and batching doesn't share those. A slow mode can't get much below that floor.
- The batch size where weight reads stop dominating is about 300 times the model's sparsity. For DeepSeek-V3 that's around 5,000 sequences.
- At scale, a decode step takes about as long as it takes to read all of HBM once, around 25 ms, because the memory fills up with KV cache and every step reads all of it.
Two costs and two hardware limits
Let's look at what one decode step does.
A sequence is a row of tokens. To produce the next token, the model takes the newest token and runs it through every layer, which means multiplying it by every weight matrix it's routed to. Inside each attention layer, the new token also looks back at every earlier token. It doesn't recompute those tokens. It reads the keys and values that were computed when each one was first processed, and that stored data is the KV cache. After the step, the new token's own keys and values are appended to it.
So each step does two kinds of work, and each is limited by a different part of the chip.
Compute
For every sequence in the batch, we multiply by all of the active parameters. A multiply-add counts as two floating-point operations, so for a batch of \(B\) sequences
\[ t_{\text{compute}} \approx \frac{2\,B\,N_{\text{active}}}{\text{FLOPS}} \]Here \(N_{\text{active}}\) is the number of parameters a single token uses. In a mixture-of-experts (MoE) model that's much smaller than the total. DeepSeek-V3 has 671 billion parameters, but each token uses about 37 billion of them. FLOPS is the hardware's floating-point throughput, summed over all the GPUs holding one copy of the model.
I'm leaving out the multiply-adds inside attention itself. During decode, each byte of KV cache we read is used for only a handful of multiply-adds, so attention's cost shows up almost entirely as memory traffic, which we count next.
Memory
Every step has to stream all of the weights out of HBM, and for each sequence it has to stream that sequence's entire KV cache:
\[ t_{\text{memory}} \approx \frac{\beta\,N_{\text{total}} + B\,n_{\text{ctx}}\,s_{\text{kv}}}{\text{BW}} \]The weight term uses \(N_{\text{total}}\), not \(N_{\text{active}}\). With a large batch, some token in the batch is routed to every expert, so every expert's weights get read. \(\beta\) is bytes per weight (1 for 8-bit weights, 0.5 for 4-bit). \(n_{\text{ctx}}\) is the context length in tokens, \(s_{\text{kv}}\) is the size of the KV cache per token in bytes, and BW is the total HBM bandwidth.
GPUs overlap memory transfers with math, so a step takes as long as the slower of the two:
\[ t_{\text{step}} \gtrsim \max\left(t_{\text{compute}},\ t_{\text{memory}}\right) \]The \(\gtrsim\) is there because real systems never quite reach these limits. This is a roofline model. It ignores plenty, and it still predicts a surprising amount. In every term, the numerator describes the model and the denominator describes the hardware.
Batch size is the knob
Latency
Here is how each piece scales with batch size.
Compute time is a straight line through the origin: twice the batch, twice the multiply-adds. Memory time has a fixed part, the weights, which cost the same whether you serve one sequence or ten thousand, plus a KV part that grows with the batch. The step time is the upper envelope of the two.
Look at the left edge. Even with a batch of one, a step can't be faster than the time it takes to read every weight once. That's the latency floor for a given set of hardware. For a one-trillion-parameter model stored in 8 bits and spread across 64 Blackwell GPUs, each with 8 TB/s of HBM bandwidth,
\[ \frac{10^{12}\ \text{bytes}}{64 \times 8\ \text{TB/s}} \approx 2\ \text{ms per step} \]So no single sequence on that hardware gets more than about 500 tokens per second, whatever you pay. To go faster you need more total memory bandwidth (more GPUs reading weights in parallel, which Part 2 picks up), fewer bytes per weight, or a trick that produces more than one token per step, like speculative decoding.
Cost
Latency is what the user feels. Cost is what the provider pays, and it's easiest to see per token. Renting the hardware costs a fixed amount per second, and one step produces \(B\) tokens, so the cost per token is proportional to \(t_{\text{step}}/B\). Dividing every curve in Figure 3 by \(B\) gives this:
Compute per token is flat, since every token needs its own multiply-adds. KV reads per token are flat too, since each sequence reads its own cache. The weights are the only thing that gets shared, so their cost per token falls as \(1/B\). At small batches that hyperbola dominates and tokens are expensive. At large batches it fades away, and the cost settles onto a floor set by whatever each token can't share.
How much more expensive is a batch of one? At \(B=1\) each token pays for a full read of the weights. On the floor it pays only for its own multiply-adds. With short contexts, the ratio of the two works out to exactly the balance batch size \(B^{*}\) that we derive below, about 5,400 for DeepSeek-V3. With long contexts the floor also includes each token's KV reads, which shrinks the ratio. In the DeepSeek-V3 example later in this post it's about 300. Either way, serving one sequence at a time costs hundreds to thousands of times more per token.
Fast mode and slow mode
Now we can answer the opening questions. A fast mode moves left on these curves. The provider runs your requests in smaller batches, so each step reads less KV cache and finishes sooner. The weights still have to be read in full every step, and fewer tokens share that cost, so each token costs more.
How much more depends on how much of the step is weight reads. Take the DeepSeek-V3 example worked out later in this post, where a normal step takes 23.2 ms: 1.3 ms to read the weights and 21.9 ms to read KV cache. Write the step as a fixed weight-read time plus a KV-read time proportional to the batch, \(t = w + cB\). To make tokens 2.5 times faster, the step has to shrink to 9.3 ms. The weights still take 1.3 ms, so the KV reads have to drop to 8.0 ms, which takes a batch 2.7 times smaller. Cost per token is step time over batch size, so it changes by a factor of
\[ \frac{t_{\text{fast}}/B_{\text{fast}}}{t_{\text{normal}}/B_{\text{normal}}} = \frac{1}{2.5} \times 2.7 \approx 1.1 \]That's only about 10% more per token. When KV reads dominate the step, a smaller batch removes KV reads and tokens in proportion, and only the weight reads get spread over fewer tokens. Fast mode gets expensive when the weights are a big share of the step, as with short contexts or very large models. Then each halving of the batch comes close to doubling the cost per token while buying little extra speed.
So the launch price, 6 times as much for 2.5 times the speed, isn't explained by the cost of a step alone. Some of it likely pays for capacity held in reserve, since batches only stay small if the provider doesn't fill them with other traffic, and some of it is margin on a new product. A provider can also put fast traffic on different hardware or lean harder on speculative decoding. Anthropic has since cut the premium, and fast mode on its newer Opus models costs about twice the normal price.
Why can't you pay 100 times more for 100 times the speed? Shrinking the batch only gets you down to the latency floor. In this example that's the 1.3 ms weight read, about 18 times faster than a normal step. Near the floor, batches are down to a handful of sequences, each token pays for nearly a whole weight read, and the cost per token climbs to hundreds of times normal. Past the floor you need more GPUs reading weights in parallel, fewer bytes per weight, or speculative decoding.
Slow mode is the reverse: bigger batches. That helps only until the weights are amortized. After that you're on the floor, paying for each token's own multiply-adds and its own KV reads, and waiting longer doesn't change either one. Batch APIs do sell a 50% discount for results within 24 hours, but that discount comes from scheduling. The provider fills hardware that would otherwise sit idle between traffic peaks. It doesn't come from making any single step cheaper.
Where the balance point is
The batch size that matters most is the one where weight reads stop dominating, the crossover \(B^{*}\) in the last two figures. Ignore the KV term for a moment and set the weight-read time equal to the compute time:
\[ \frac{\beta\,N_{\text{total}}}{\text{BW}} = \frac{2\,B\,N_{\text{active}}}{\text{FLOPS}} \]Rearranging so the hardware is on one side and the model on the other,
\[ B^{*} = \underbrace{\frac{\text{FLOPS}/2}{\text{BW}/\beta}}_{\text{hardware}} \times \underbrace{\frac{N_{\text{total}}}{N_{\text{active}}}}_{\text{model}} \]The hardware term is a plain number. The top is multiply-adds per second. The bottom is weights per second that HBM can deliver. Their ratio is how many multiply-adds the chip can do in the time it takes to load one weight. For an H100 running 8-bit math, that's 989 trillion multiply-adds per second against 3.35 trillion one-byte weights per second, about 295. For a Blackwell GPU in a GB200 NVL72 running 4-bit math, it's 5 quadrillion multiply-adds per second against 16 trillion half-byte weights per second (8 TB/s), about 310. Dropping to lower precision doubles the math and halves the bytes per weight, so the ratio barely moves. Call it 300.
The model term is the sparsity: how many parameters exist for every one a token uses. So
\[ B^{*} \approx 300 \times \frac{N_{\text{total}}}{N_{\text{active}}} \]| Model | Total params | Active params | Sparsity | \(B^{*}\) |
|---|---|---|---|---|
| Any dense model | \(N\) | \(N\) | 1 | ~300 |
| DeepSeek-V3 | 671B | 37B | 18 | ~5,400 |
| Kimi K2 | 1.04T | 32B | 32 | ~9,800 |
Model size isn't in that formula. A dense model of any size balances at a few hundred sequences, and it's sparsity that pushes the number into the thousands. In practice you'd run somewhat above \(B^{*}\), because real kernels don't reach the roofline, and the KV term we dropped also uses bandwidth, which pushes the crossover further right.
Keep in mind that \(B\) counts sequences, not tokens. A batch of 5,000 means 5,000 different conversations, each getting one more token in the same step.
If the context is long enough, the KV line in Figure 3 becomes steeper than the compute line, and then the step is memory-bound at every batch size. The DeepSeek-V3 example below is in that regime, and so is most long-context serving. Part 3 uses exactly this to read the size of a model's KV cache off its price list.
Why a step takes about 25 milliseconds
So far we've only used memory bandwidth. Memory capacity adds one more constraint, and it pins down the length of a step.
A provider wants big batches to amortize the weights, and it wants to support long contexts. Both mean more KV cache, so in practice the HBM fills up. Every step reads the entire KV cache of every sequence in the batch. If HBM is full and every step reads roughly all of it, the step time is capacity divided by bandwidth:
\[ t_{\text{step}} \approx \frac{\text{HBM capacity}}{\text{HBM bandwidth}} \]That ratio has stayed in a narrow range. An H100 has 80 GB at 3.35 TB/s, which is 24 ms. A GB200 GPU has 186 GB at 8 TB/s, which is 23 ms. A B300 has 288 GB at 8 TB/s, which is 36 ms. So it's 20 to 40 milliseconds, and I'll use 25 ms as a round number. A step much longer than that would need more data than the memory can hold.
Let's check this against a real model. Put DeepSeek-V3 in 8-bit on 64 GB200 GPUs (its 256 experts divide evenly into 64, as Part 2 explains). Total HBM is 11.9 TB. The weights take 0.67 TB, and the other 11.2 TB holds KV cache. At \(B \approx 5{,}400\), that's about 2 GB of cache per sequence, or about 30,000 tokens of context at DeepSeek-V3's roughly 70 KB per token.
Weight reads and multiply-adds are balanced, as designed, at about 1.3 ms each. The KV reads take 22 ms. At scale, decode spends almost all of its time reading KV cache. That fact sits behind a lot of the pricing in Part 3, starting with why output tokens cost more than input tokens.
Batches leave on a timetable
If a step takes 25 ms, what happens to a request that arrives in the middle of one? Think of each step as a train. A train leaves every 25 ms whether or not it's full. Any sequence that's ready gets on, and if the train is full, it waits for the next one.
The worst case is a request that arrives just after a train leaves. It waits up to one step for the next departure and then one more step for its token, about 50 ms in total. That's small next to network latency and the time it takes to process a long prompt. Batching costs users very little in waiting time. What they notice is mostly the step time itself.
The timetable also gives the throughput of one copy of the model: \(B\) tokens every step. At \(B \approx 5{,}400\) and 25 ms, that's about 216,000 tokens per second. Google said in May 2026 that it was processing more than 3.2 quadrillion tokens a month, which is about 1.2 billion per second. That count includes input tokens, so it isn't a like-for-like comparison, but one efficient replica is clearly a tiny slice of a large provider. For a small provider it sets a minimum. Without about 200,000 tokens per second of steady demand per replica, you can't fill the batch, and every token costs more.
Where the series goes from here
The next three parts apply this model.
- Part 2 looks at how a model is laid out on GPUs, why a single rack is the natural unit for MoE models, and why pipelining across racks helps with weights but not with KV cache.
- Part 3 reads API price sheets with this model and recovers the KV cache size per token and the kind of storage behind prompt caching.
- Part 4 works out how much to train a model that will be served at this scale, and finds that frontier models are probably trained on hundreds of times more data than Chinchilla-optimal.
Diagrams are drawn in TikZ.