Unit 5 of 11 · about 4 hours · explain, implement

Replica routing, load balance and cache-locality skew

A warm prefix saves prefill work but can attract enough requests to overload its owner. Routing must value the saved work against waiting and capacity, not maximize hits alone.

You'll be able to

  • Implement a deterministic cache-aware router that checks capacity before applying locality and load tie-breaks.
  • Compare load-only and cache-aware decisions under hot-prefix skew, changing reuse and stale worker information.
  • Diagnose a higher cache-hit rate that worsens queueing, fairness or SLO-qualified completions.

Covers

Replica routing and load balancingCache-aware routing and locality skew
1

Read

In this order, only the parts listed

0 of 3 done

  1. Routing independent serving replicasHands-On LLM Serving and Optimization - Chapter 7, multi-GPU and disaggregation

    Chapter 7, Data Parallelism, printed pp. 244 to 245 - round robin, least connections, latency-based and cache-aware routing

  2. Balance predicted waiting against cache reuseMooncake: A KVCache-Centric Disaggregated Architecture for LLM Serving

    FAST 25 paper, Section 4.1 Prefill Global Scheduling and Section 4.2 Cache Load Balancing, printed pp. 161 to 162

    Study the decision rule and hot-cache replication. Leave the cluster experiments and their numerical results out of your local routing claims.

  3. Worker selection at phase boundariesNVIDIA Dynamo - Disaggregated Serving and KV-Aware Routing

    Dynamo v1.5.1, Efficient KV Transfer - Router Orchestration, steps 1 to 4

2

Focus on

  • Build on Exact prefix identity, version scope and tenant privacy scope. A cache overlap score is useful only for compatible, authorized KV; it is not permission to reuse another tenant's state.
  • Track full assigned token capacity separately from uncached prefill work. Reuse saves computation but does not make the destination request's complete context disappear.
  • The TensorTonic problem prioritizes the longest cached prefix before projected uncached load. Mooncake instead minimizes predicted TTFT including waiting; these are different policies, not equivalent implementations.
  • Worker discovery, cache events and load estimates can lag. Revalidate capacity and identity at admission, and keep a fallback for evicted prefixes or unavailable workers.
Common mistakes · 3
  • Using uncached tokens as the memory-admission cost. The public rule admits against the full assigned request length even when most tokens have a prefix hit.
  • Interpreting a router's hit estimate as guaranteed resident KV. Eviction or worker restart between selection and admission can invalidate it.
  • Improving aggregate TTFT while starving tenants with cold prefixes. Compare waiting and completions by tenant or request class.
3

Try it yourself

Closed-book, before checking anything

Implement the named TensorTonic rule from a blank file. Check feasibility using full assigned request lengths, then rank by longest prefix, lowest projected uncached load, most remaining capacity and smallest worker ID. Reproduce the public example with request lengths [10, 8], prefix lengths [[8, 0], [0, 6]], worker IDs [2, 1] and capacities [20, 20]: assignments [2, 1] and uncached loads [2, 2]. Then construct a queued hot-prefix case where a predicted-TTFT policy deliberately chooses less reuse.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.A six-token request has a four-token cache hit on a worker with capacity five. Is it feasible under the problem's rule?Answer

    No. Full assigned length, six tokens, exceeds capacity five. The two uncached tokens determine compute load, not feasibility.

  2. 2.Why can longest-prefix routing lose to load-only routing?Answer

    A hot cache owner can have enough waiting work to outweigh the saved prefill. Low reuse or stale cache information can also remove the expected saving.

  3. 3.Two workers tie on prefix, projected work and remaining capacity. What breaks the public problem's tie?Answer

    The smaller worker ID, not the first worker in the input array. Returned loads remain in input-worker order.

  4. 4.Does replicating a hot prefix always improve goodput?Answer

    No. It costs memory and transfer work, can evict useful other prefixes and may not relieve the current compute or queue bottleneck. Test it on the same arrival trace.

5

Practice

  • TensorTonic: Route Cache-Aware Prefill Requests

    Implement cache_aware_prefill_routing(request_token_counts, cached_prefix_lengths, worker_ids, worker_capacities)

    The free public cases check cache-local choices, worker-ID tie-breaking and rejection when no worker fits. Add tests for projected-load and remaining-capacity ties yourself. The section mini-project compares this locality-first rule with load-only and predicted-TTFT routing.

You're done when

Your router passes the three public cases and your additional tie-break tests, and your hot-prefix counterexample explains why saved prefill does not guarantee lower waiting or better goodput.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 10 more in the section

Also in this section