Tokenizer3 XP · 1-day streak
Topics / Inference, Serving & Production

Inference, Serving & Production

This is the topic that separates "I call the API" from "I can own an LLM feature in production" - and it dominates system-design rounds for AI Engineer roles at labs, big tech, and startups alike. Infra-flavoured teams will drill into KV cache maths and batching schedulers; product-flavoured teams will drill into SLOs, cost engineering, and reliability.

0%mastery
0/76questions tried
0due today
0/12cards read

Card 1 of 12

The two phases of inference

Every LLM request has two radically different phases:

  • Prefill: process the entire prompt in one pass. All prompt tokens are computed in parallel → big matrix-matrix multiplies → compute-bound. Cost grows with prompt length (attention is quadratic, GEMMs linear). Prefill determines time-to-first-token (TTFT).
  • Decode: generate output tokens one at a time. Each step is a matrix-vector multiply that must stream all model weights (plus the KV cache) from GPU HBM to produce a single token → memory-bandwidth-bound. Decode determines time-per-output-token (TPOT).

Arithmetic intensity (FLOPs per byte moved) explains this. GPUs have a "ridge point" - roughly peak FLOPs ÷ memory bandwidth (~300 FLOPs/byte for an H100 at BF16). Prefill sits far above it (fully parallel GEMMs); batch-1 decode sits at ~1-2 FLOPs/byte, so the GPU idles waiting on memory. Consequences:

  • Batch-1 decode speed has a hard ceiling: weight bytes ÷ bandwidth. A 70B model in FP16 (~140 GB) on ~3.35 TB/s HBM ⇒ ~24 tok/s max, no matter how fast the compute is.
  • Batching decode is nearly free: the same weight-read serves every sequence in the batch, so throughput scales almost linearly with batch size until you hit compute or memory limits. Almost every serving optimisation is a scheme to keep decode batches large.
All 76 Inference, Serving & Production questions

Basic

  1. Walk me through what happens inside the server when an LLM processes a request. Why are prefill and decode bottlenecked differently?
  2. What is the KV cache, why is it needed, and how big does it get? Ballpark it for a 70B-class model at 128K context.
  3. Define TTFT, TPOT, and tokens/sec. What drives each one, and what are reasonable targets for a chat product?
  4. Why do LLM products stream responses, and how does streaming actually work over HTTP?
  5. How do you estimate whether a model fits on a given GPU? Will a 70B model fit on one 80 GB card?
  6. Why do output tokens cost more than input tokens, and how should that shape how you build?
  7. What is quantization for inference? Explain weights-only vs weights-and-activations, and the typical tradeoffs.
  8. What's the difference between static and continuous batching, and why did continuous batching become universal?
  9. What is prompt (prefix) caching, and why is it one of the biggest cost levers available?
  10. Your app is getting 429s from your LLM provider at peak traffic. How do you handle rate limits properly?
  11. We set temperature to 0, so outputs should be deterministic. Why do users still get different answers to the same prompt?
  12. What does FlashAttention actually do, and how is it different from PagedAttention?
  13. A user closes the tab halfway through a streamed response. What happens on the server, and what should happen?
  14. Your production code reads the response text but never checks finish_reason (or stop_reason). Why is that a bug, and what should you do with each stop reason?

Intermediate

  1. Why do we obsess over P99 latency rather than the average, and what causes tail latency in LLM serving specifically?
  2. Explain arithmetic intensity and the roofline model as applied to LLM inference. Why does batching improve decode throughput so dramatically?
  3. What problem does PagedAttention solve, and how does it work?
  4. What is chunked prefill and what scheduling problem does it fix?
  5. Explain speculative decoding. Why is the output provably faithful to the target model, and when does it actually help?
  6. Compare GPTQ, AWQ, GGUF, INT8, and FP8. How do you actually choose a quantization approach for a deployment?
  7. What is KV-cache quantization, and when is it the right lever?
  8. Describe the throughput - latency tradeoff curve for an LLM server, and explain goodput.
  9. vLLM, SGLang, TensorRT-LLM, TGI, llama.cpp/Ollama - how do you choose a serving stack?
  10. Explain tensor parallelism vs pipeline parallelism for inference. When do you need each?
  11. Self-host an open-weights model or call a provider API - walk me through the decision.
  12. When would you use a batch API, and how do you design a pipeline around one?
  13. What is semantic caching, how is it different from prompt/prefix caching, and what are its failure modes?
  14. How do you handle streaming when the model is emitting tool calls or structured JSON?
  15. You need to serve 200 customer-specific fine-tunes of the same 8B base model. How do you do that on a handful of GPUs, and what breaks first?
  16. How do you load test an LLM service so the numbers actually mean something?
  17. Your product is moving from a standard chat model to a reasoning model with extended thinking. What changes for capacity, SLOs, and design?
  18. Explain KV cache offloading and cross-request reuse beyond a single GPU's memory. When does loading a cached prefix beat just recomputing prefill?
  19. How do you choose inference hardware: NVIDIA GPUs, AMD, TPUs, or cloud silicon like Inferentia and Trainium?
  20. When does on-device or edge inference make sense, and what actually constrains it?
  21. At low batch sizes your decode is slower than the bandwidth math predicts, and the GPU timeline shows gaps between kernels. What is CPU overhead in LLM serving, and how do CUDA graphs and overlapped scheduling fix it?
  22. Providers now sell the same model at several service tiers: standard, priority, flex or batch, and provisioned throughput. How do you decide which traffic goes where?
  23. Prompt caching now has a write price and a choice of lifetimes: 5 minutes or 1 hour on Anthropic, 30 minutes or 12 hours on OpenAI's newest models. Work out the break-even reuse count for an agent that resends a 50K-token prefix, and tell me which TTL and breakpoint placement you would pick and when a cache write never pays for itself.

Advanced

  1. Build the full GPU memory budget for a serving deployment, and show how it determines maximum batch size and concurrency.
  2. Design the SLOs for a new LLM-powered feature. What do you promise, and how do you measure it?
  3. Capacity planning: you're told to expect 100 requests/sec at peak with ~2K input and ~300 output tokens per request. Walk me through estimating the GPU fleet.
  4. GPU cold starts take minutes. How do you autoscale an inference fleet anyway?
  5. What do you monitor in production LLM serving, and what pages someone at 3 a.m.?
  6. Design the reliability layer for calls to an LLM provider: timeouts, retries, circuit breakers, idempotency.
  7. Traffic doubles overnight and you can't get more GPU capacity for a week. What are your graceful-degradation options?
  8. How is structured output actually enforced at the serving layer, and what does it cost?
  9. Your LLM bill tripled this quarter. Design a cost-engineering programme - attribution, cascades, context management.
  10. Go deeper on speculative decoding: acceptance-rate math, modern drafters (EAGLE-3, built-in MTP, n-gram lookup, parallel block drafters), and when it backfires.
  11. What is prefill/decode disaggregation, and why do large-scale deployments separate the two?
  12. Design a multi-provider LLM gateway: routing, fallbacks, and the pitfalls teams hit.
  13. You run 40 replicas of the same model behind a load balancer, and round-robin gives you a terrible prefix cache hit rate. Design the routing layer.
  14. How does serving a large sparse mixture-of-experts model differ from serving a dense model, and what does expert parallelism change?
  15. You run a shared LLM platform for 30 internal teams on one GPU fleet. Design the tenancy model: fairness, isolation, and cost attribution.
  16. Your traffic is shifting from single-turn chat to agents: 20 to 50 model calls per task, tool calls in between, sessions lasting tens of minutes. What does that do to your serving design?
  17. After a routine deploy, P99 TTFT went from ~600 ms to ~4 s. Throughput, error rate, GPU utilization and the model version are all unchanged. Debug it.
  18. You are moving from a dense transformer to a Mamba-attention hybrid. What changes in your serving stack?
  19. Product wants to offer a 1M-token context window on a model you self-host. What breaks in serving, and how do you make it work?
  20. What changes in your serving design when the NVLink domain grows from 8 GPUs in a server to 72 GPUs in a rack, as with GB200 NVL72-class systems?
  21. Providers now sell the same model in a 'fast' mode at roughly twice the price for up to 2.5x the output speed. What is the provider changing on the serving side, why does a faster token cost more, which of your traffic deserves it, and what happens when your client falls back to standard speed on a 429?
  22. vLLM now ships an opt-in lossy verification policy for speculative decoding (FLy), reporting roughly 1.04 to 1.31x decode throughput on MI355X and B300. Would you ever turn it on, and how would you prove it is safe for your product?
  23. Design a serving path where prefill runs on GPUs or Trainium and decode runs on an SRAM-based accelerator from another architecture, as in NVIDIA's pairing of Vera Rubin GPUs with Groq 3 LPX, or the Trainium plus Cerebras design AWS has announced. What crosses the boundary, how do you size each pool, and what happens to prefix caching and failure handling?
  24. CUDA graphs and overlapped scheduling are on, but batch-1 decode is still well below the bandwidth roofline. What would a persistent megakernel change, and why might an inference vendor argue that megakernels are the wrong target for production traffic?
  25. A model can now return close to a million output tokens from one request, as with Gemini 4 Argon's long-decode mode. What changes for serving, streaming, timeouts, cost control and evaluation?

Quick-fire

  1. How would you keep an LLM feature's cost and latency under control?
  2. Explain the latency-throughput-cost triangle and the main dials you have.
  3. What is prompt caching / KV caching and when does it help?
  4. How do you decide which model to use for a given step (model routing)?
  5. How does quantization affect an AI Engineer's decisions, even if you do not train models?
  6. What does observability look like for an LLM application in production?
  7. What is the difference between time-to-first-token and inter-token latency, and why care?
  8. What is semantic caching, and how is it different from prompt caching?
  9. What is speculative decoding, and why might it matter to you?
  10. What is continuous (in-flight) batching, and how does it change throughput?
  11. API prices have dropped sharply. How should that change your architecture decisions?
  12. How do you attribute and monitor LLM cost per feature or per user?
  13. When do you self-host an open-weight model instead of using a hosted API?
  14. How do you set up a safe fallback when a model call fails, times out, or is rate-limited?
+3 XP · card read