Benchmarking and the capstone interview questions
11 questions with model answers
- junior 2
- mid 5
- senior 4
11 benchmarking and the capstone questions asked in AI engineer, ML engineer and applied AI engineer interviews, each with a model answer you can say out loud in a minute or two: 2 junior, 5 mid-level and 4 senior. The lesson Benchmarking Inference, and the Module Capstone teaches the ideas behind them.Updated
Model answer
Everything except the thing you changed: model and precision, prompt and reply lengths, batch, concurrency and arrival rate, warm-up, repeats, environment and unit. Report percentiles, TTFT and TPOT separately.
Scroll sideways to see the whole diagram
Decide what is held fixed. Two numbers are comparable only if everything except the thing you are testing is the same.
Text version
- Decide what is held fixed. Two numbers are comparable only if everything except the thing you are testing is the same.
- Throw away the first runs. Our scripts ran two or three untimed requests before timing anything.
- Time the same request many times. One run is one draw from a distribution.
- Summarise with percentiles. A few slow runs move the mean without telling you how slow they were.
- Write down everything you didn't vary, so someone else (or you, next month) can tell whether a new number is comparable.
After AI Engineering, Ch. 9, "Inference Performance Metrics", and the measuring routine in scripts/generate-latency-data.py.
Lengths alone move results: on our laptop CPU, the first token took 12.8 ms after 16 prompt tokens and 223.3 ms after 960.
Model answer
Not on that evidence. Three runs of the same CPU prefill on our laptop, same model, versions, threads and prompt, gave 219.6, 223.3 and 239.4 ms: 9% apart. Their methods also differed, so no cause could be named. A 5% gap sits inside that spread. Interleave several runs of each version with an identical method, and compare the spreads.
Model answer
Ask: for which phase, prompt length and batch? On our test laptop the Apple GPU's first-token advantage was 1.6× at 16 tokens and 2.3× at 960, but batch-1 decode only about 1.4×, which fits bandwidth-bound decode with similar copy ceilings. Short prompts with long replies are almost all decode, so the headline barely applies.
The book's three questions: can it run the workload, how long does it take, what does it cost. I'd measure my own prefill and decode mix, comparing ratios from one run.
Model answer
Measure it myself: their number is their workload on their day. Latency depends on my prompts and sampling settings, so I'd send my own prompts at my lengths and concurrency and measure p90 TTFT, as the book's criteria table does on an internal prompt dataset.
Test at peak concurrency, since some providers throttle. Check quality too: the same Llama models scored differently across providers in a Cerebras experiment. Compare cost per request, not per token.
Model answer
It has no headroom. Capacity, the highest arrival rate still within 300 ms at p90, is 6 per second against a target of 9: eight seats fill as traffic grows, and requests queue. A larger batch limit buys capacity until the KV caches break the 2 GB budget.
It's simulated from measured steps, but those were measured at a 128-token context while this workload reaches 768, so it's optimistic. First real measurement: p90 TTFT and capacity under the real workload.
Model answer
Perplexity is exp of the mean negative log-likelihood per token, the model's effective branching factor on held-out text. Being per token, it isn't comparable across tokenizers: longer tokens mean fewer, harder predictions. Normalise to bits per byte to compare. It also measures fit to a text distribution, not helpfulness, correctness or instruction following, so it says little about a chat model's quality, and it shifts with the eval set.
Model answer
Benchmark the workload you'll serve: realistic prompt and output length distributions, arrival rates and concurrency, not one fixed prompt. Report time to first token, inter-token latency and end-to-end at p50 and p99, plus throughput at a latency SLO; peak throughput at unbounded latency means little.
Scroll sideways to see the whole diagram
Decide what is held fixed. Two numbers are comparable only if everything except the thing you are testing is the same.
Text version
- Decide what is held fixed. Two numbers are comparable only if everything except the thing you are testing is the same.
- Throw away the first runs. Our scripts ran two or three untimed requests before timing anything.
- Time the same request many times. One run is one draw from a distribution.
- Summarise with percentiles. A few slow runs move the mean without telling you how slow they were.
- Write down everything you didn't vary, so someone else (or you, next month) can tell whether a new number is comparable.
After AI Engineering, Ch. 9, "Inference Performance Metrics", and the measuring routine in scripts/generate-latency-data.py.
Change one knob at a time, batch size, precision, tensor-parallel degree, engine, and rerun a quality eval after each, since quantization can quietly cost accuracy. Warm up, pin versions, repeat runs, and profile to explain each result.
Model answer
Ask which mistake costs more. Precision when a false alarm is expensive, like an agent that issues refunds or bans accounts. Recall when a miss is expensive, like a safety agent that must catch harmful content. F1 when both matter and positives are rare, so accuracy misleads. With known costs, weight errors directly.
Model answer
Agreement tells you whether labels are reliable enough to score against. Raw agreement overstates it, since raters agree by chance; Cohen's kappa corrects for that with two raters, and Krippendorff's alpha handles many raters and missing labels. Low agreement often means a vague rubric.
LLM judges are cheap but biased by position, length and self-preference. Let humans build the gold set; trust a judge once its agreement with them matches human-to-human agreement.
Model answer
First remove the randomness you control: greedy decoding or a fixed seed, and a pinned model, prompt and parameters. Even then, GPU serving isn't bitwise deterministic, because batch composition changes floating-point reduction order, so cache outputs for exact replay.
For the score, treat runs as samples. Measure the standard deviation across repeats in a pilot, then pick n so the standard error, sd over root n, is well below the difference you need to detect.
Model answer
Vary what drives risk: actor types and behaviours, speeds and gaps, occlusions, road geometry, weather and sensor noise. Sample from real-world distributions fitted to driving logs, so results mean something. Collisions are rare, so plain Monte Carlo wastes runs; use importance sampling to oversample dangerous regions, then weight each run by its likelihood ratio, keeping the collision-rate estimate unbiased, with confidence intervals. Validate the simulator against logged events.