Exact Memory-Time Optimization for Prefix-Cached Language Model Serving
Organizations: Independent Researcher, Delhi, India
Abstract
Retaining language-model prefix states trades recomputation against storage time. Optimizing each cached block independently can overcount savings: a resident block is usable only when the required preceding prefix is also available. We introduce Prefix-Certificate Retention (PCR), an exact finite-trace formulation for static, grouped, reset-on-access timeouts. Usable-prefix rewards become nodes whose prerequisites are timeout thresholds and preceding hit certificates. The resulting maximum-weight closure reduces to one minimum cut, with graph size linear in the number of block lookups and timeout choices. A breakpoint theorem extends the construction to all nonnegative timeouts without discretization error. We also derive a linear-time-in-grid-size dynamic program for ordered timeouts and bounds that certify the cost of this restriction. Exhaustive small-instance checks and chronological replay of 39,632 public Mooncake requests validate the formulation. On the fixed grid, ordered timeouts attain the unrestricted training optimum in 118 of 120 trace-grouping-price cases. Heterogeneous retention improves several held-out memory-time tradeoffs, but finer training optimization does not uniformly improve transfer. The contribution is a tractable optimization model and an auditable benchmark for retention policies; the experiments measure usable prefix blocks and storage time, not GPU latency.
Figures & tables
| Trace | Requests | Full lookups | Unique blocks | Duration (s) | Train/validation/test requests |
|---|---|---|---|---|---|
| Conversation | 12,031 | 276,491 | 170,899 | 3,537.0 | 4,401 / 2,447 / 5,183 |
| Tool agent | 23,608 | 386,041 | 159,983 | 3,537.0 | 8,779 / 4,832 / 9,997 |
| Synthetic | 3,993 | 117,888 | 40,148 | 1,022.0 | 1,512 / 807 / 1,674 |
| Trace | Grid nodes | Event nodes | Grid solve (ms) | Event solve (ms) | Prep. (s) |
|---|---|---|---|---|---|
| Conversation | 4,694 | 28,280 | 4.25 | 24.41 | 0.62 |
| Tool agent | 4,341 | 26,901 | 4.00 | 23.44 | 0.68 |
| Synthetic | 2,362 | 9,995 | 1.68 | 8.47 | 0.20 |
LLM Serving
Large language model serving studies how to deliver model responses with low latency, high throughput, and efficient use of compute and memory.
See all 211 papers