Library

AI engineering in production

Running LLM features for real users, with the numbers behind each choice. Latency targets and GPU budgets, cost per request, evals and hallucination checks, agents, rate limits, and the system designs Anthropic and OpenAI ask for.

Practice questions

40
Serving people who wait: latency, GPU memory and autoscaling
  1. 1.A decode step takes 4.6 ms for 1 sequence and 6.7 ms for 64 on the same GPU. What explains the small difference?
  2. 2.Which pair of metrics should trigger adding GPUs to an LLM serving pool?
  3. 3.When the service is busy, users see answers freeze mid-sentence for a fraction of a second. What's the likely cause?
  4. 4.Conversations on the shop's GPUs grow from 2,000 tokens to 8,000, with the same traffic and answer lengths. Roughly how many GPUs does the fleet need now?
  5. 5.You switch the weights of the 7.6 billion parameter model from 16 bits to 8, keeping the cache in 16. At batch 1, what happens to a decode step?
What a request costs: tokens, caching and routing
  1. 1.A provider charges $2 per million input tokens and $10 per million output tokens. What does a request with 1,000 input tokens and 100 output tokens cost?
  2. 2.A prompt starts with the current time, then 1,800 tokens of instructions that never change. You turn prompt caching on. What happens to the bill?
  3. 3.Each customer's conversation is cached as its own prefix, and customers reply about every 10 minutes. Which cache lifetime fits?
  4. 4.Questions go to a small model first, and the ones it can't handle go on to a large model. What gets worse for the questions sent on?
  5. 5.A rented H100 costs $4.89 an hour, and your feature produces 350 output tokens a second. Why does it cost more per token than an API charging $0.50 per million?
Evals for LLM features and agents
  1. 1.A model passes 180 of 200 questions. What's the 95% interval for its pass rate, roughly?
  2. 2.Two prompts score 84% and 87% on the same 300 questions. How should you compare them?
  3. 3.A support agent succeeds on a task 3 times in 4. Many customers bring that task, and each gets one try with no retry. Which number tells you how reliably the agent serves them, and which one would mislead you?
  4. 4.After a prompt change, answers get longer, and your LLM judge's average score rises. Nothing else changed. What do you check first?
  5. 5.Overall, Haiku is 3 points behind Sonnet with a paired interval that clears zero. Most of your users ask order-status questions. What do you do?
Catching hallucinations before users do
  1. 1.Which of these is a hallucination?
  2. 2.A prompt change raises your eval's accuracy from 72% to 74%. It also makes the model stop saying it doesn't know. What do you check before shipping?
  3. 3.Every quote in an answer is found, word for word, in the retrieved policy. Can the answer still be wrong?
  4. 4.Your checker's answers scored around 0.9 turn out supported only 75% of the time. You can't retrain it. What fixes its scores?
  5. 5.You sample each answer five times and send it only when four agree. What does that cost?
An agent loop with tools: plans, calls and limits
  1. 1.In a tool-using agent, what does the model do, and what does your code do?
  2. 2.A tool call fails because the order service timed out. What should the harness do?
  3. 3.Why does the refund tool take an idempotency key?
  4. 4.An agent makes 5 model calls, and the last one reads 2,700 tokens. Why does the run cost far more than 2,700 input tokens?
  5. 5.Which pair of calls can a harness safely run at the same time?
Rate limiting requests and tokens across many servers
  1. 1.A token bucket holds 5 and refills 10 a minute. What do those two numbers control?
  2. 2.Why do providers limit output tokens and not only requests?
  3. 3.A limiter takes a request token, then finds the output bucket short and denies the question. What's the bug?
  4. 4.The shop runs 5 servers, each with a fifth of every customer's limit. A customer's requests all arrive on one connection. What happens?
  5. 5.The bucket says the next request passes in 2.5 seconds. What should the Retry-After header say?
Designing a prompt playground
  1. 1.Why give a prompt version an id from a hash of its content and parent?
  2. 2.A browser loses its connection in the middle of a streamed run. What lets it pick up where it left off?
  3. 3.Why does a side-by-side comparison of one sample per version prove little?
  4. 4.The run endpoint takes a version id but checks access only when the page loads. What's the risk?
  5. 5.Two people edit the same sentence of a template at once. Which approach keeps both edits?
Splitting a model across GPUs: memory, compute and network
  1. 1.How many bytes a parameter does training with Adam in mixed precision need, before activations?
  2. 2.What does ZeRO stage 3 add over stage 2, and what does it cost?
  3. 3.Why does tensor parallelism stay inside one node?
  4. 4.A pipeline has 8 stages and 28 microbatches. What's the bubble as a share of the ideal time?
  5. 5.Sharded data parallelism alone trains a 70B model well on 64 GPUs. Why does it fail for a 405B model on 16,384 GPUs?