WRITE · TRACE · UNDERSTAND
Reserve KV-cache memory with explicit grouped-query dimensions
Compute unpaged KV bytes per token as 2*layers*kv_heads*head_dim*bytes_per_element.
Read lesson: Reserve KV-cache memory with explicit grouped-query dimensions →
Your experiment
Compute unpaged KV bytes per token as 2*layers*kv_heads*head_dim*bytes_per_element. Reserve each request's prompt+maximum-output tokens. In input order admit requests that fit remaining byte capacity, skipping those that do not fit. Return admitted,rejected,reserved_bytes,bytes_per_token. IDs are unique. Dimensions are positive integers; capacity and token counts are nonnegative integers. This estimate excludes model weights, activations, allocator/page overhead and tensor parallel replication.
Python runs in your browser. Your draft stays on this device.
What to look for
Compare the estimate with real accelerator measurements and paged-cache behavior. Treat memory reservation, throughput, fairness and latency as separate constraints.
Watch your code work
Ready to experimentWrite a solution or load the worked answer, then choose Trace & check.
Step through arrays, variables and training curves produced by your own Python.
