Frontier
KV cache sizing and memory budgets
An 80 GB accelerator budgeted line by line for Qwen3.8-27B: weights, runtime reserve, the key-value pool at 64 KiB per token, the reference float32 DeltaNet matrix state of 144 MiB per sequence, and the same budget redone at FP8.
Updated
01 · Concept
Concept
You have one 80 GB accelerator and a product requirement: serve Qwen3.8-27B to as many simultaneous conversations as the card allows, each with an 8,192-token window. Somebody subtracts 54 for the weights from 80, divides the remainder by lesson 7.2’s 64 KiB per token, and reports 48 users. The worked result is 36: the naive estimate is high by one third, and the failure mode is an out-of-memory crash under load. This lesson does the budget line by line because everything downstream prices against it.
Start with usable capacity rather than brochure capacity. A part marketed as 80 GB carries 80 GiB-class HBM and reports roughly 79.6 GiB to the runtime once ECC and reserved firmware regions are taken out, so the number you can actually allocate is smaller than the number on the box. Doing the entire budget in one unit family is the only defence, so convert everything to gibibytes and stay there. The bf16 weights, about 54 GB from the canonical figure, are 50.3 GiB. Next comes a line the naive subtraction omits entirely: the runtime reserve. The driver context, activation buffers for the largest batch you intend to run, temporary workspace for the attention and feed-forward kernels, and allocator fragmentation together consume several gibibytes before a single token of cache exists. Six gibibytes is an illustrative and not especially generous figure; serving frameworks encode the same idea as a utilization fraction, defaulting to holding back roughly a tenth of the device. The remainder is the pool:
Now price one sequence, and price it completely. Lesson 7.2 derived the cache at 4 KiB per token per caching layer, 64 KiB per token across the 16 full-attention layers, and that derivation is not repeated here. An 8,192-token conversation therefore holds
- Weights, bfloat1654 GB · fixed69%
- KV cache, one full-context sequence16 GiB · grows per token22%
- DeltaNet recurrent state~144 MiB · constant<1%
- Activations, fragmentation, runtimereserve, never zero8%
of keys and values. But the 48 Gated DeltaNet layers are not free either. In the reference Transformers path, each keeps a 3 MiB float32 matrix state, 144 MiB across the layers, excluding the small convolution state. The state belongs to the sequence, not the model. Every concurrent conversation carries its own copy. The true per-sequence cost is 512 plus 144, or 656 MiB, and the pool holds
Thirty-six, not forty-eight. The three corrections that closed the gap were the unit conversion, the runtime reserve, and the constant recurrent state.
Push the same pool to the other extreme. A full 262,144-token sequence holds 16,384 MiB of K/V plus 144 MiB of matrix state, so the pool holds one. At 32,768 tokens each sequence costs 2,048 plus 144, or 2,192 MiB, and the card serves ten. Concurrency is a function of the context length you promise.
Redo the budget with FP8 weights and an FP8 cache. The weights halve to about 27 GB, or 25.15 GiB, and the cache halves to 32 KiB per token. The pool becomes about 48.45 GiB or 49,613 MiB. Each 8,192-token sequence now costs 256 MiB of cache plus the unchanged 144 MiB reference state, 400 MiB in total, so the card serves
and five full-native-context conversations rather than one. That is about a 3.4-fold gain in concurrency from this paired precision change.
Omitting the DeltaNet state predicts 46 bf16 sequences instead of 36, about 28 percent too many, and 193 FP8 sequences instead of 124, about 56 percent too many. The state is constant, so as each variable term shrinks its relative weight grows; many copies of a fixed 144 MiB become a major budget line.
Carry two habits out of this lesson. Budget in one unit family, and price a sequence completely rather than pricing only its cache. Lesson 9.4 changes the capacity line by changing the silicon, and lesson 9.10 turns these occupancy figures into cost per token.
02 · Analogy
Analogy
A removals van has a stated capacity, but the usable space is what remains after the tail lift, the straps, the blankets, and the driver's own toolbox. Load planning that starts from the brochure figure ends with furniture on the pavement. A memory budget is the same exercise: the brochure says 80 GB, the weights are the piano, the runtime reserve is the toolbox nobody counted, and every extra passenger brings luggage that scales with the trip and a bag that does not.
03 · Lab
Lab
04 · Teach it back
Teach it back
Budget an 80 GB accelerator for Qwen3.8-27B line by line and state how many 8,192-token conversations it serves concurrently, then redo the budget with FP8 weights and an FP8 cache.
Compare with a model answer
An 80 GB part reports roughly 79.6 GiB usable. The bf16 weights are about 54 GB, which is 50.3 GiB, and a 6 GiB runtime reserve leaves about 23.3 GiB, or 23,859 MiB, as the state pool. Lesson 7.2 derived 64 KiB per token, so an 8,192-token conversation holds 512 MiB of cache; the reference float32 DeltaNet matrix state adds 144 MiB, giving 656 MiB per sequence and 36 concurrent conversations. One full 262,144-token sequence needs 16,384 MiB of cache plus 144 MiB, so only one fits. With FP8 weights at about 27 GB and an FP8 cache at 32 KiB per token, the pool grows to 49,613 MiB and each 8,192-token sequence costs 256 plus 144, or 400 MiB, giving 124 concurrent conversations and five full-context sequences.
05 · Check your understanding
Check your understanding
Complete the teach-back and answer the quiz correctly to finish this lesson.
◎ · Evidence marker
Sources
- Woosuk Kwon et al. (2023). Efficient Memory Management for Large Language Model Serving with PagedAttention.
- vLLM Project (2026). vLLM Documentation.
- Qwen Team (2026). Qwen3.8-27B Model Card.