Unit 9 of 11 · about 3 hours · explain

Cache-aware routing, KV offload and connector metadata

A prefix can be correct but live in the wrong place. Reuse pays only if reaching compatible state costs less than recomputing it, and movement must not outlive its storage owner.

You'll be able to

  • Explain cache affinity as a routing hint that competes with queueing and load balance.
  • Distinguish local prefix reuse, host/storage offload and KV transfer.
  • Specify transfer metadata and ownership until load or save completion.

Covers

Cache-aware routing and load balanceKV offload to CPU or storage vocabularyKV connectors and transfer metadata
1

Read

In this order, only the parts listed

0 of 3 done

  1. RadixAttention: replica affinity and stale routing hintsSGLang: Efficient Execution of Structured Language Model Programs

    arXiv:2312.07104v2, Appendix A.4, Data-Parallel Distributed RadixAttention

  2. Hands-On LLM Serving and Optimization: offload vocabularyHands-On LLM Serving and Optimization - Prefix Caching and Advanced KV Caching

    Chapter 7, Advanced KV Caching: Self-Hosting LLMs, KV cache offloading, printed pp. 261 to 262; Hands-on LMCache, printed pp. 264 to 266

    Read the hierarchy and cold/warm comparison. Skip the deployment commands, compression, blending and fleet cost claims; this unit needs a local transfer model, not that model size or topology.

  3. vLLM 0.31.0: connector ownership and synchronizationvLLM 0.31.0 - cache specifications and connector lifecycle

    KVConnectorMetadata, KVConnectorHandshakeMetadata; KVConnectorBase_V1 methods get_num_new_matched_tokens, update_state_after_alloc, start_load_kv, wait_for_layer_load, wait_for_save and request_finished

    Read these contracts only. The metadata base classes do not prescribe a complete wire schema; design your compatible-state descriptor explicitly.

2

Focus on

  • Compare predicted queue plus remaining prefill cost, not prefix length alone. A hot replica can have enough queue delay to lose to an idle replica that recomputes.
  • Offload retains compatible state on a colder tier; it does not make host or storage bytes GPU-resident. Restore time includes lookup, transfer, synchronization and any conversion, with real destination capacity reserved.
  • Transfer metadata needs request generation, exact prefix/position boundary, model and adapter version, tenant authorization, layer/group layout, dtype/scales, valid length and source/destination mapping. A checksum detects corruption, not permission or compatibility.
  • Asynchronous save pins source blocks until completion; load must finish before its consumer reads. A cancelled transfer still needs acknowledged cleanup. Routing metadata may be stale, so the destination validates the hit and falls back safely.
Common mistakes · 3
  • Treating a router's hit prediction as authority to use state. The destination must confirm presence, identity, compatibility and authorization.
  • Freeing a source page as soon as a save is submitted. A pending copy can then read a recycled generation.
  • Assuming a larger cold-tier cache gives a faster decode path. Restoring state and attending to it still consume time and device capacity.
3

Try it yourself

Closed-book, before checking anything

Use a labeled CPU event simulation, not a fleet measurement. Route one request between a busy prefix-hit replica and an idle miss replica by comparing queue plus service costs; increase only the hit replica's queue until routing changes. Then transfer a small token-labeled state buffer between two CPU stores with a versioned descriptor: reject one stale version, cancel during a pending copy, and keep its source pinned until the copy is acknowledged. Verify byte equality and unchanged logical positions for an accepted transfer.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.When should an idle miss replica beat a busy hit replica?Answer

    When its predicted queue plus recomputation and remaining service is less than the hit replica's queue plus reuse and remaining service, under the same request contract.

  2. 2.Is a matching checksum enough to accept transferred KV?Answer

    No. It can confirm payload integrity but not model compatibility, logical positions, tenant permission or freshness.

  3. 3.In the V1 connector contract, what does deferred freeing on request_finished require?Answer

    The engine must retain the request's blocks while asynchronous save/send owns them, and release them when transfer completion is reported. Submission alone is not completion.

You're done when

Your local simulation changes routing at the predicted queue crossover, rejects incompatible transfers and preserves source ownership through completion or acknowledged cancellation.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 11 more in the section
  • SGLang: Efficient Execution of Structured Language Model ProgramsSGLang Project · required

    Study RadixAttention, longest-prefix matching, eviction and cache-aware scheduling. Compare its sequence-level radix index with vLLM's block-level paging instead of treating them as competing names for one mechanism.

  • Hands-On LLM Serving and Optimization - Prefix Caching and Advanced KV CachingChi Wang and Peiheng Hu (O'Reilly) · required

    Read "Prefix Caching" in Chapter 6 (RadixAttention, use cases, best practices, scaling the prefix cache) and "Advanced KV Caching" in Chapter 7 (long context, cost and latency, LMCache). Separate exact-reuse mechanisms from capacity extensions such as offload.

  • vLLM 0.31.0 - cache specifications and connector lifecyclevLLM Project · reference

    Read the per-layer attention, MLA and Mamba specifications for hybrid state contracts; read the V1 connector metadata, load synchronization and deferred-free methods for transfer ownership. These fill the pool's hybrid-state and connector-contract gaps, without requiring distributed execution.

Also in this section