Malotru
Back to notes

The Inference Bill Moved into Memory

November 5, 2026

Agentic sessions have moved inference cost from arithmetic to where the key–value cache lives, how requests are routed to it, and what offload does to latency. Sparse attention and expert routing change which resource saturates first; a cheaper token can still be a more expensive request.

The Inference Bill Moved into Memory

API prices are still quoted per million tokens. The sessions that now dominate serving do not spend like that. A coding agent keeps a long history, reuses almost all of the previous turn, bursts a few cold sub-agents, and emits comparatively little new text. The expensive object is the key–value cache: where the prefix lives, whether the next request is routed there, and what you pay in latency and energy when it does not fit. Mid-2026 serving measurements and a GPU energy study agree. Sparsity helps. It does not retire the memory problem, and a lower joule-per-token figure can hide a more expensive request.

Fixed-length tests stopped describing the traffic

SemiAnalysis treats coding agents, from late 2025 onward, as the point at which production inference stopped looking like one prompt and a fixed continuation. AgentX, published in August 2026, measures the replacement: an open multi-turn coding trace, context up to a million tokens, released under Apache 2.0 beside the older fixed shapes. The group says the trace set cost more than $3 million to build. The response they emphasize is software. More than 70 upstream pull requests, across vLLM, SGLang, TensorRT-LLM, AMD's ATOM and AITER, Dynamo, LMCache, and Mooncake, use AgentX as a stand-in for agent traffic, and they chase prefix-aware routing, cache movement between machines, and tiered storage [Source 1].

A single-turn chart misses the structure. Sessions run for many turns. Prompts, tool definitions, and history accumulate. Because each turn usually appends to the last, the share of the prompt served from cache tends toward one. Sub-agents then arrive with cold context, a burst of misses rather than hits. Routing has to know where a prefix sits. Offload has to decide what is worth keeping in a slower tier. A benchmark that decodes a fixed continuation and drops the cache never sees that [Source 1].

Sparse attention reads less and still stores the context

GLM-5.3 is a useful case because the model already tries to spare memory. In the 5.2 and 5.3 line, compression shrinks the state stored per token, and sparse attention shrinks how much of that state each step reads. SemiAnalysis's 28 September note on an InferenceX snapshot is blunt about what remains. Top-k selection cuts bandwidth inside the attention kernel and typically still wants the full context resident. SGLang's HiSparse keeps hot entries in high-bandwidth memory, pulls a miss from host memory, and overlaps that load with compute in the previous layer. High-concurrency throughput rises. The price is miss traffic, not a vanished working set [Source 2].

The dollars in that snapshot are a cost model for owning hyperscale hardware, not invoices. At 150 tokens per second, the curves put a GB200 near $0.044 per million total tokens and an MI355X running ATOM near $0.049. Total tokens include cached history, most of an agent prompt. Generated output alone is about $5.92 per million tokens on the GB200 and $6.68 on the MI355X, which matches long inputs and short replies, and hides latency. Near that speed target, cited GB200 runs have a 90th-percentile time to first token of roughly 14 to 19 seconds, against about 1.1 to 1.2 seconds for the MI355X. Keep only setups actually tested at 150 tokens per second or faster with that percentile at most two seconds, and ATOM is near $0.0607 per million total tokens, a B200 on Dynamo with SGLang near $0.0666. Allow ten seconds and a GB300 on Dynamo with TensorRT-LLM comes in near $0.0451. A GB300 in the SGLang slice also serves about 13,950 total tokens per second per GPU against about 11,873 on a GB200. The model assumes $2.31 per GB300 GPU-hour against $1.86, and at this target the dearer hour spends the throughput edge [Source 2].

The cache tier, not the badge on the chip, is doing much of the work. On B200 runs, raising concurrency from 8 to 16 drops GPU-memory reuse of prompt tokens from 90.3 percent to 54.8 percent, while host-memory reuse rises from 6.0 percent to 40.3 percent. Combined hits stay above 95 percent. The cache moved [Source 2].

A 25 August note on DeepSeek V4 Pro makes the capacity arithmetic explicit. Under the same style of cost model, B300 and B200 look similar in aggregate; extra B300 throughput tracks more high-bandwidth memory, about half again the B200's. At 384 concurrent traces, a B300 vLLM DEP8 setup with 3 terabytes of host memory and simple offload held a 91 percent fast-tier hit rate and only 1.36 percent more from the host. The fast working set was about 43 million tokens, barely above the offered load. A B200 at concurrency 196 inverted the picture: 73 percent in the fast tier, nearly 20 percent from the host, working set about 22 million tokens. Offload is usually write-through, so a GPU-resident prefix is also written to the slower tier. It pays when host memory is roughly 1.5 to 3 times the fast cache, and it fails when the slow tier is the working set rather than the overflow [Source 3].

Joules per token can fall while the request costs more

A Carnegie Mellon energy study states the accounting bug cleanly. Serving is priced in tokens. The GPU spends energy over a window: prefill, launch, synchronization, then one step per output token. Prabhu Vellaisamy, Vanessa Lam, Shawn Blanton, and John Paul Shen split the window into a fixed part — prefill that builds the cache, plus setup that does not grow with length — and a marginal cost per generated token for the batch. Joules per token fall when a fixed cost is spread over more tokens, even if total energy rises [Source 4].

On an H200, Llama-3.2-1B at batch 16 and a 4K context shows it. Stretching the output from 10 tokens to 512 drops token energy from 7.46 joules to 0.72, while the batched window rises from 1.19 kilojoules to 5.93. Batching helps less as context grows. At 10 output tokens, a batch of 16 beats a single request by about 6.31 times at a 512-token context, and by about 1.17 times at 4K. Mixture-of-experts models make the fixed term louder: sparse routing and fragmented experts cost energy at low concurrency, and batching is what narrows their per-token gap with a dense model. A scheduler that watches only joules per token will congratulate longer answers [Source 4].

Agent traffic is that shape. A turn is a large prefill, or a cache reload in its place, plus a short decode. Expert sparsity does not erase expert-weight traffic. It moves cost into the fixed term a short reply cannot amortize [Source 1][Source 4].

What a faster kernel does not settle

Sparse attention is still worth pursuing. In June, MIT Technology Review reported Subquadratic's claim that SubQ drops dense attention, handles up to about twelve times as much text as typical models, and offers a window of 12 million tokens. Appen, as the magazine reports it, measured SubQ as 56 times faster than models using FlashAttention on a pure speed test, and about 98 percent on needle-in-a-haystack retrieval at 6 million and 12 million tokens. A 400-document task returned in seconds in a demo; Perplexity, given the same pile, did not load all of it [Source 5].

That is not a serving plan. GLM was already sparse and compressed, and capacity was still the constraint. HiSparse wins by moving bytes with overlap. The B300's advantage over the B200, in the DeepSeek note, is how large a working set fits in the fast tier. A cheaper decode step can leave prefill, or the reload that replaces it, as the dominant energy. A microbenchmark does not price a million-token session, a two-second cap on time to first token, or an offload tier used as primary memory [Source 2][Source 3][Source 4][Source 5].

For anyone buying or building inference late in 2026, the unit is the session. Hit rate by tier, time to first token at a real concurrency, joules per request beside joules per token. Expert routing and sparse attention change which resource saturates first. The chip, the offload path, and the scheduler are one design. A chart of tokens per second, or of dollars per million tokens that treats cache hits as free compute, describes a workload production has already left.

Sources