LLM inference engineering interview questions
66 questions that come up in inference, ML infrastructure and LLM serving interviews, each with a model answer, the numbers to back it up and the follow-ups an interviewer is likely to ask next. Free to read, with links to the lessons that teach each topic in depth.
Prefill vs decode
5 questions
- What is the difference between prefill and decode in LLM inference?
- Why is decode memory-bound? Show it with numbers.
- How do you estimate time to first token for a long prompt?
- What is chunked prefill and why do serving engines use it?
- What is disaggregated prefill and decode, and when is it worth it?
KV cache
5 questions
- What is the KV cache and why do we need it?
- How do you calculate the KV cache size for a model? Work through an example.
- How do GQA, MQA and MLA reduce KV cache size?
- Should you quantise the KV cache? What are the trade-offs?
- What do you do when the KV cache runs out of memory under load?
Roofline maths
5 questions
- Explain the roofline model.
- Estimate the decode speed of a 70B model in FP8 on 4 H100s with tensor parallelism.
- At what batch size does decode become compute-bound?
- Prefill is compute-bound. So why does FlashAttention help it?
- How does memory bandwidth explain why a Mac or a gaming GPU runs local models at the speed it does?
Batching and continuous batching
5 questions
- Why does batching increase LLM throughput so much?
- What is continuous batching and how does it differ from static batching?
- What does an LLM engine's scheduler decide on each step?
- Why can the same prompt give different outputs depending on what else is in the batch?
- How do you choose the maximum batch size or concurrency for a deployment?
PagedAttention
5 questions
- What problem does PagedAttention solve?
- How does a block table work in PagedAttention?
- How do block size choices trade off?
- How does PagedAttention enable prefix sharing and parallel sampling?
- What are the downsides or limits of PagedAttention?
Quantisation
5 questions
- Why does quantisation make LLM inference faster?
- What is the difference between GPTQ and AWQ?
- Why are activation outliers a problem, and how do methods deal with them?
- How do you validate that a quantised model is good enough to ship?
- What are FP8 and FP4, and what hardware supports them?
Speculative decoding
5 questions
- How does speculative decoding work?
- Why does speculative decoding not change the output distribution?
- What speed-up should you expect? Derive the expected tokens per step.
- Compare draft models, Medusa, EAGLE and n-gram drafting.
- When does speculative decoding hurt rather than help?
Multi-GPU serving
5 questions
- Explain tensor parallelism. What does it communicate and when?
- How does pipeline parallelism differ, and what is the bubble?
- When do you use data parallelism or expert parallelism instead?
- How do you choose a parallelism layout for a 70B model on 8 H100s?
- What are NVLink, NVSwitch and InfiniBand, and why do they matter for serving?
Engine internals: vLLM, SGLang, llama.cpp
5 questions
- Walk through what happens inside vLLM from request to token.
- How does SGLang differ from vLLM?
- How does llama.cpp run large models on a laptop?
- What are kernel fusion and CUDA graphs, and why do they matter for decode?
- How would you choose an inference engine for a new project?
Benchmarking latency vs throughput
5 questions
- What metrics do you use to benchmark an LLM server?
- Why do latency and throughput trade off, and how do you show it?
- What is Little's law and how do you use it for LLM capacity planning?
- What are common mistakes when benchmarking LLM inference?
- How would you find out why a deployment is slower than expected?
FlashAttention and attention kernels
4 questions
- How does FlashAttention work, and why is it faster?
- Why do decode steps need a different attention kernel from prefill?
- How do long-context models keep attention affordable?
- What is the computational complexity of attention in prefill and decode?
Structured output
6 questions
- How does constrained decoding guarantee valid JSON?
- How is a JSON schema turned into something the engine can run?
- Why are tokens a problem for grammars, and how do engines handle it?
- What does constrained decoding cost per step, and how do engines hide it?
- What is jump-forward decoding?
- Can constrained decoding hurt answer quality? How would you mitigate it?
Mixture of experts
6 questions
- What is a mixture-of-experts layer and how does routing work?
- What are total and active parameters, and which matters for what?
- How many experts does a batch touch, and why does batching erase the sparse advantage?
- How do you serve a large MoE across GPUs? Explain expert parallelism.
- What is expert load imbalance and how do you deal with it at inference time?
- How do quantisation and offloading apply to MoE models?
How to use these
Read the question, answer it out loud or on paper first, then compare with the model answer. The follow-ups are where interviews separate people who have memorised terms from people who can reason about the system, so practise those too. For the full background, work through the inference engineering roadmap or the Inference Engineering course.