KV memory
Pages, and the memory cap.
The scheduler checks for room for KV cache before admitting a new request. 80 GB on the card, 16 GB of weights, and everything else is room for KV cache. Running requests fill it a token per step.
The memory arithmetic, once
Per token, the cache costs , 128 KB for Llama-3-8B in bf16. The batch cap is
Reserving the maximum length per request wastes whatever is never written, typically well over half, and fragments as requests finish. Paging with page size wastes at most tokens per request and never fragments: a request’s cache is a list of page numbers, and the attention kernel gathers through that list. In SGLang, TokenToKVPool is the page pool (page size 1 by default), req_to_token holds the page tables, and retract_decode is the eviction when nothing frees up. Sharing pages across requests is the next chapter.