AI Infra Interviews logo

kv cache

AI infra interview questions tagged kv cache, across every topic.

A model can load successfully and still run out of memory as requests accumulate. Study the cache layout first, calculate the memory required by the target context and concurrency, then check the serving engine’s measured allocation. Use the KV-cache calculator to vary the assumptions; a memory estimate alone does not predict latency.

From cache layout to serving limits

Start with a mechanism, then use a worked problem to explain a decision. Access labels below describe what is available without an account.

  1. The KV Cache

    Explain which tensors persist between decoding steps and why they grow.

    Public concept
  2. Reading config.json to Size a Model You Have Never Run

    Read layer count, KV heads and head dimension before choosing a formula.

    Public concept
  3. How big is the KV cache for Llama 3.1 70B at a 128k context?

    Work through a concrete memory budget with explicit units.

    Public answer
  4. Set max-model-len and max-num-seqs for a chat product from first principles.

    Turn the budget into context and concurrency settings.

    Public answer
  5. vLLM crashes with out of memory during startup on a model that should fit. Debug it.

    Distinguish startup allocations from the workload’s growing cache.

    Public answer
  6. Serving Benchmarks That Do Not Lie

    Check the resulting settings against a representative traffic mix.

    Public concept
29 questions · 12 unlocked for you

Concepts behind "kv cache"

Review the concepts used in these questions.

Foundational
🚀 Inference & Serving
The KV CacheThe KV cache saves attention keys and values from processed tokens. Follow one decode step, calculate its memory cost, and see why longer conversations reduce the number of requests a GPU can hold.
Foundational
🧮 Open Weights & Serving Engines
Reading config.json to Size a Model You Have Never RunRead a model configuration as an architecture description, then combine it with tensor metadata and engine allocation rules. Learn which fields determine attention state, why mixed precision needs tensor-level accounting, and how to turn a first estimate into a testable per-GPU capacity plan.
Foundational
🧮 Open Weights & Serving Engines
Multi-Head Latent Attention and Sparse IndexersLatent attention changes what is stored; sparse indexing changes which positions receive expensive attention; recurrent layers summarize history in state. Learn to budget each mechanism separately, including indexer work, cache replication and hybrid prefix snapshots.
Foundational
🧮 Napkin Math & Capacity
KV Cache SizingDerive cache payload from the stored attention state, then account for mixed sequence lengths, block allocation and per-device limits. Worked examples distinguish exact bytes from deployable capacity.
Foundational
📐 AI Systems Design
Inference Platform ArchitectureAn inference platform connects API requests to model replicas. Learn how routing, batching, memory limits and scaling work together to meet a latency target.
Advanced
🚀 Inference & Serving🔒 Premium
PagedAttentionFollow a token position through a block table, watch a cache grow, and trace a shared tail through copy-on-write. Separate memory saved from throughput gained.