Design A Shared Prefix KV Cache For Managed Inference
Last updated: November 29, 2026
Quick Overview
Design a KV cache layer for an LLM inference service that reuses attention key and value tensors for repeated prompt prefixes across requests and across replicas, to cut time-to-first-token and raise throughput.
Crusoe
November 29, 20260
0
0 solved
Design a KV cache layer for an LLM inference service that reuses attention key and value tensors for repeated prompt prefixes across requests and across replicas, to cut time-to-first-token and raise throughput.
Crusoe Managed Inference promotes cache reuse across requests (its MemoryAlloy engine) as a way to beat a standard vLLM deployment on time-to-first-token. Interviewers want you to reason about prefix matching, memory tiers from GPU HBM to host memory and remote storage, routing for cache affinity, and isolation between tenants.
What the Interviewer Expects
- Explains why prefill dominates time-to-first-token for long shared prompts
- Uses block-level prefix hashing so partial prefix matches are reusable
- Designs a tiered cache (HBM, host DRAM, remote) with transfer cost reasoning
- Routes requests to replicas likely to hold their prefix while balancing load
- Addresses tenant isolation and cache poisoning
- Defines metrics: hit rate, TTFT, throughput, memory overhead
Key Topics to Cover
How to Approach This
- Start by mapping the business objective to a concrete ML objective and metric.
- Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
- Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
- Address the serving latency budget and whether batch or real-time inference is needed.
- Think about the data flywheel: how user feedback improves the model over time.
Possible Follow-up Questions
- When is fetching KV from another node slower than recomputing the prefill?
- How do you size the host memory tier per node?
- How do you invalidate caches when a model version or LoRA adapter changes?
- How would you evaluate the system against a plain vLLM baseline fairly?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice ML System Design ProblemsSample Answer
Requirements
Serve open models (say a 70B model on 8 GPUs per replica) to many tenants with long system prompts, RAG contexts and multi-turn chats. Goals: lower TTFT and higher tokens per GPU through reuse of pref...
High-Level Design
Split each prompt into fixed blocks of, say, 16 tokens. Each block's key is a hash of (model id, adapter id, tenant scope, all tokens up to and including that block), so a block key identifies a whole...