The interview problem

Practice prompt

A hosted model repeatedly processes shared instructions and private customer documents. Design a prefix cache that saves prefill work without reusing incompatible or unauthorized state.

Original practice, not a reported company interview. All worked numbers are illustrative. Interview date: not applicable. Written October 3, 2026.

1. Scope and assumptions

Cache exact compatible prefixes, not semantically similar prompts. Distinguish model weights, tokenizer, adapter and attention configuration. Decide whether timing leakage across tenants is acceptable before enabling cross-tenant reuse.

2. Architecture and decisions

Tokenized request → compatibility namespace → prefix lookup → prefill miss → decode → bounded eviction

Key reusable blocks by an immutable execution configuration and prefix identity. Place private content in tenant-specific namespaces; an explicitly public system prefix may use a separate shared namespace. Reference-count active blocks so eviction cannot invalidate a running request. Revoke namespaces when a model or adapter revision changes.

Track saved prefill tokens, hit depth and time to first token. A request can hit a short prefix yet still spend most time processing its uncached document. Cache admission should account for reuse and memory pressure from active sequences. The decode phase continues to consume compute even when the entire initial prompt is reusable.

3. Work through the example

For 100 requests with the same 2,000-token prefix and a different 500-token suffix, uncached prefill processes 250,000 tokens. Ideal exact reuse processes 2,000 + 100 × 500 = 52,000 tokens, saving 198,000, or 79.2%. This is a token-work estimate, not an equivalent latency reduction.

4. Failure cases and trade-offs

A key that omits adapter identity can return numerically wrong state. A tenant can probe hit timing to infer another tenant submitted a prefix. Isolation reduces reuse but strengthens privacy. Cache memory can reduce concurrent decode capacity, so a high hit rate alone is not a success criterion.

5. Validation and acceptance

Compare output behavior with caching disabled under the chosen numerical tolerance. Alternate model and adapter revisions, revoke a namespace during load and stress eviction with active readers. Measure tail latency and memory pressure together.

6. Follow-ups and self-review

When would you share a public prefix across tenants? Reward exact compatibility keys, explicit privacy policy, active-block lifetime and separate prefill/decode accounting.

Sources and related practice

vLLM documents automatic prefix reuse and its prefill-focused benefit; the tenant policy and calculation are original.

Read the primary technical reference

Reference retrieved October 3, 2026. Retrieval date is not an interview or source publication date. The reference supports the named concept; scenario, architecture, examples and rubric are original.

Continue with Design a streaming LLM inference service; Cache semantically similar model requests.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.