Model Serving interview question

MLOps & ProductionModel ServingLatencyhard

An 8B support model (≈ 16 GB of BF16 weights) is served with a vLLM-style engine as shown below. At peak, the time per output token (TPOT) spikes and the engine logs preemptions. What is happening, and what is the most direct fix?

text
# one dedicated 80 GB GPU, nothing else runs on it
vllm serve /models/support-8b \
    --gpu-memory-utilization 0.60 \
    --max-model-len 32768 \
    --max-num-seqs 128

# observed at peak traffic
GPU memory used    48 GB of 80 GB
engine log         (paraphrased) WARN preempting request 9137 (mode=recompute): no free KV-cache blocks
p95 TPOT           38 ms -> 410 ms
typical request    2,000 prompt tokens + 400 output tokens
  1. AEach sequence reserves KV space for the full 32,768-token context when it is admitted, so 128 sequences cannot fit; lower max-model-len to 4,096 so every reservation becomes eight times smaller.
  2. BRunning sequences fill the paged KV cache, so the scheduler evicts some and later recomputes their KV; raise gpu-memory-utilization to about 0.9 so the engine can allocate more KV blocks.
  3. CMemory is not the bottleneck, since 40% of the GPU is still free; the spikes come from max-num-seqs being too low, so raise it to 256 so that more sequences can share each decode step.
  4. DPreempted requests fail with an out-of-memory error and are resent by the client, which doubles the load at peak; add client-side retry backoff and keep the engine settings as they are.
Show the answer and explanation

Correct answer: B, Running sequences fill the paged KV cache, so the scheduler evicts some and later recomputes their KV; raise gpu-memory-utilization to about 0.9 so the engine can allocate more KV blocks.

Explanation Model Serving

A vLLM-style engine takes the memory budget gpu-memory-utilization × GPU memory, loads the weights, reserves activation workspace, and turns the rest into KV-cache blocks. Here that is 0.6 × 80 = 48 GB, minus ~16 GB of weights and some workspace, so roughly 30 GB of KV cache. The other 32 GB on the GPU is simply outside the engine's budget.

Demand at peak: a typical 8B model with grouped-query attention needs 2 (K, V) × 32 layers × 8 KV heads × 128 dims × 2 bytes ≈ 128 KB per token, so 128 sequences × ~2,400 tokens can need ~40 GB, more than the ~30 GB pool.

With paged attention, blocks are allocated on demand as each sequence grows. When running sequences need new blocks and none are free, the scheduler preempts some sequences: it frees their blocks and later rebuilds their KV by recomputing the prompt plus the tokens generated so far (some engines can instead swap blocks to CPU memory). Requests are not lost, but the recompute steps and the paused sequences show up as TPOT spikes.

On a dedicated GPU the direct fix is to give the cache the idle memory: at 0.9 the budget is 72 GB, so the KV cache grows from ~30 GB to ~54 GB, about 1.8× more blocks and enough for that peak. Other levers: cap max-num-seqs lower (trades throughput for stability), use an FP8 KV cache, or add replicas.

Why the distractors fail:

  • Reserving the full max-model-len per sequence is the pre-paging behaviour; here blocks follow the real length (~2,400 tokens), so shrinking the limit does not reduce what these requests need.
  • Admitting more sequences into an already full cache causes more preemption.
  • Preemption is internal rescheduling, not a failed request.

Interview tip: name the three knobs and what each controls: memory budget (gpu-memory-utilization), concurrency cap (max-num-seqs) and longest allowed context (max-model-len), and say you watch preemption counts and KV-cache usage on the dashboard.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More MLOps & Production questions

  1. Re-running the training job below from the same git commit one month later gives a validation AUC of 0.861 instead of the logged 0.874. The library versions,…
  2. Estimate the monthly LLM bill for this RAG chatbot workload. Every user turn is a separate API call that re-sends the full prompt.
  3. What does this symmetric INT8 quantization snippet print, and which statement about using an asymmetric (zero-point) scheme for ReLU outputs is correct?
  4. A telecom team adds a new feature, dropped_calls_7d, produced by a streaming job from network events starting today. To train on 18 months of history, past…
  5. A retailer's progressive-delivery pipeline shifts traffic to a new recommendation-API version in steps of 5% → 25% → 50% → 100%. At each step, automated…