08.01 · Concept · Free
Test-Time Compute
State the trade the field made: buy accuracy with inference tokens instead of parameters, and understand why that moves the dominant cost of an AI product from a one-off training run to a bill that arrives every day.
Curated for this lesson
Thinking Costs Tokens
Test-Time Compute
This window explains that reasoning models answer by producing a reasoning chain before the answer, that 'when you let the LLM generate more tokens, you're just giving it more compute,' and that APIs charge for output tokens including 'reasoning tokens,' creating an incentive to get accuracy with fewer inference tokens.
Test-time compute buys better answers by spending more work during inference, often through reasoning tokens, multiple samples, or verifier-guided search. That shifts cost from building a larger model once to paying for longer, slower, more memory-hungry requests every day, with output tokens becoming a core product economics constraint.
What this lesson answers
- what is test time compute in llm inference
- why do reasoning tokens increase inference cost
- when is chain of thought too expensive
Notes
Test-time compute is the deliberate expansion of the inference-time computation budget, usually by generating hidden or visible “thinking” tokens, sampling multiple candidate solutions, or running verifier-guided search, instead of increasing parameter count or doing another training run. For an autoregressive decoder, the dominant per-request work is approximately FLOPs, while the dominant decode memory traffic for weights is approximately when batch size is too small to reuse weights efficiently. The product trade is therefore explicit: if a reasoning policy raises output length from to , it buys accuracy by multiplying decode cost and latency by roughly , plus extra KV-cache traffic. This is the shift behind chain-of-thought, self-consistency, verifier reranking, tree search, and systems such as EAGLE speculative decoding: quality is no longer purchased only by a larger checkpoint, but by spending more tokens on every customer request.
For a concrete decode-bound example, take a 70B FP16 model on one 80GB H100 with TB/s HBM bandwidth. The weights occupy about GB, so a single-token, batch-1 decode pass must stream about GB of weights, ignoring tensor-parallel sharding details. The bandwidth lower bound is s, or about tokens/s, before attention, kernels, synchronization, and sampling. If “thinking” changes a request from output tokens to , the lower-bound weight traffic changes from TB to TB, and the lower-bound time changes from s to s on that single-GPU mental model. On a real tensor-parallel deployment the weights are split and batch reuse improves throughput, but the billable fact remains: six times as many generated tokens means roughly six times as many decode steps unless speculative or parallel search accepts enough tokens to compensate.
The KV-cache term is the part that makes long thinking qualitatively different from simply printing a longer answer. With grouped-query attention using KV heads, head dimension , FP16 KV, and layers, one token’s KV footprint is bytes, about KiB/token/request. A -token scratchpad therefore consumes about GB of KV cache for one sequence; concurrent such sequences consume about GB before allocator fragmentation and metadata. This is why vLLM’s PagedAttention paper, “Efficient Memory Management for Large Language Model Serving with PagedAttention,” mattered: it made fragmented KV allocation look more like virtual memory pages, raising usable batch size for long prompts and long generations. FlashAttention, from Dao et al., attacks the attention IO pattern inside the kernel, but it does not make the KV cache free; it reduces SRAM/HBM movement for attention computation, while every extra reasoning token still creates another KV entry that future tokens must read.
The field’s economic bargain is that training is a capital expense amortized over many calls, while test-time compute is an operating expense proportional to live demand. A 70B model trained once may cost millions, but after release the marginal cost of a product feature such as “think harder” is incurred on every API request, in GPU seconds, KV residency, queueing delay, and failed speculative drafts. Self-consistency is the cleanest illustration: sampling chains and voting can raise math accuracy, but its cost is , so samples of tokens behave like an -token decode workload unless batched perfectly. OpenAI’s o1-style public framing, DeepSeek-R1-style visible reasoning, and verifier/search recipes all lean on this same exchange: spend inference tokens where a smaller direct answer would be wrong. The engineering consequence is that capacity planning moves from “can we train the model?” to “can we afford tomorrow morning’s reasoning traffic at the latency SLO?”
The serving stack has adapted by trying to make extra tokens less painful rather than pretending they are free. vLLM combines PagedAttention with continuous batching so long and short requests can share decode iterations without reserving worst-case KV blocks. SGLang, introduced with its RadixAttention/runtime work, targets structured multi-call and agent workloads where prefixes, tool traces, and branches can be cached and reused instead of recomputed. TensorRT-LLM added in-flight batching, paged KV cache, quantized KV options, and speculative decoding plugins for NVIDIA deployments. NVIDIA Dynamo, announced as a disaggregated inference serving stack, and llm-d, the Kubernetes-native distributed inference project, both reflect the same pressure: prefill, decode, KV transfer, and routing become separate scheduling objects once test-time compute dominates. EAGLE, from “Speculative Decoding with Extrapolation Algorithm for Greater Language-model Efficiency,” drafts future tokens using features from the target model so that several decode positions may be accepted per expensive target step.
The technique stops working, or becomes actively bad, when additional tokens do not buy enough marginal accuracy per dollar or when they push the request into the wrong serving regime. If a task is retrieval-bound, policy-bound, or missing information, a -token scratchpad may only elaborate a false premise while multiplying latency. If the context is already near the model’s effective attention limit, more reasoning can dilute salient evidence and increase lost-in-the-middle failures. If KV memory is the bottleneck, long thoughts reduce concurrency: with the KiB/token 70B example, adding hidden tokens costs another GB per live sequence, so a node that was throughput-efficient at batch may fall to batch and lose weight-streaming amortization. Speculative decoding also has a failure regime: when the draft model’s acceptance rate is low on hard reasoning branches, EAGLE-style or TensorRT-LLM speculative paths add draft computation and verification overhead without enough accepted tokens. In production, the right question is not whether more thinking can improve a benchmark, but whether the accuracy lift survives its daily token bill, tail latency, and capacity loss.
References
Common questions
- What does test-time compute mean for an LLM product?
- It means improving answer quality by spending more compute when the request is served, rather than only by training a bigger model. The system may generate hidden reasoning, sample alternatives, run search, or use a verifier. Each added generated token adds decode work, latency, cache pressure, and often direct API cost.
- Why are reasoning tokens expensive even if users never see them?
- Hidden reasoning still has to be generated by the model. Each token requires another decode step, creates cache state that later tokens attend to, and consumes GPU time and memory. If billing counts those output tokens, invisible scratchpad text becomes a visible operating cost in both infrastructure and vendor invoices.
- When should a system avoid spending more inference tokens?
- Extra reasoning is a bad trade when it does not improve the answer enough to justify latency and cost. It is especially risky for retrieval failures, missing context, policy decisions, or workloads already limited by cache memory and concurrency. In those cases, longer thinking can amplify a wrong premise while reducing serving capacity.
Short definition: what is Test-Time Compute?
