Pidoku

Design Docs and Design Reviews

Module 31 Lesson 31.b 55 min Difficulty 3/5

Prerequisites 31.a, 12.q, 23.a, 23.b


Before you start: words you need#

WordPlain meaning
Design docA written proposal for a system or a large change, read and discussed before the code is written.
Design reviewThe meeting (or comment thread) where other engineers test the design and the author decides what to change.
Non-goalSomething the design deliberately does not try to do. Writing it down stops scope creep and endless debate.
Napkin mathsRough arithmetic, accurate to a factor of two, that tells you whether a design can possibly work.
Little’s lawItems in a system = arrival rate × time each spends in it. Turns requests per second into requests in flight, and so into KV-cache memory (12.q).
One-way doorA decision that is expensive or impossible to reverse (a 3-year contract, a public API). A two-way door can be undone cheaply.
Load-bearing assumptionAn assumption that, if wrong, breaks the design. The review exists to find these.

1. What is it?#

A design doc is how an engineering organisation thinks before it spends. For inference, a good one fits in 4–8 pages and answers: what problem, what numbers, which options, which choice and why, what it costs, how it fails, how we will know it works, and how we roll it out and back.

A design review is where experienced engineers try to break the design on paper, where breaking it is cheap. The principal’s job is twofold: review the designs that matter most, and set a standard of doc and review that catches problems when the principal is not in the room.

Inference designs fail reviews for predictable reasons: the capacity arithmetic does not close, the quality impact is unmeasured, the cost per token is missing, or the design breaks under the real traffic shape (long prompts, bursts, agents). This lesson gives a template and a checklist for those.


2. Why does it matter?#

  • Writing is cheaper than building. A wrong capacity estimate found in review costs an hour. Found after a GPU reservation is signed, it costs millions (31.d).
  • Inference designs hide arithmetic. “We’ll serve it on four nodes” is a claim about Little’s law, KV-cache size, prefill rate and decode rate at once (12.q). Most bad designs are bad arithmetic.
  • Decisions outlive their authors. In a year, the doc is the only record of why the system is shaped the way it is.
  • Reviews spread judgement. Every review is a lesson in what the organisation values. Done well, the next ten designs need less of the principal.

3. Simple analogy#

An architect does not let builders pour foundations for a house that exists only in the client’s head. They draw plans, a structural engineer checks the loads, the council checks the fire exits, and only then does anyone dig. Finding that a beam is too thin costs an eraser on paper and a demolition on site. A design review is the structural engineer’s check, and napkin maths is the load calculation.


4. Tiny example: one sentence that fails review#

A design doc says:

"The new support assistant (70B, FP8) will handle 200 requests/s at peak
 with 2,000-token prompts and 400-token answers on 4 nodes of 8×H100."

The reviewer does the arithmetic before reading on:

output tokens/s needed:  200 × 400   =  80,000   ÷ 8,136 per node (23.c) ≈ 9.8 nodes of decode
input tokens/s needed:   200 × 2,000 = 400,000   ÷ 50,000 per node       ≈ 8.0 nodes of prefill

Nearly 18 nodes kept 100% busy, before any headroom. Four nodes cannot work; the doc needs either 27 nodes, a high prefix-cache hit rate, or a lower peak. Section 6 does it properly.


5. Technical explanation#

A template for inference design docs#

1. Context and problem       who is hurting, how much, why now (one paragraph)
2. Goals and non-goals       measurable goals; what we will NOT do
3. Requirements (numbers)    traffic shape, SLOs, quality bar, cost target, availability
4. Options considered        at least three, including "do nothing" and "buy it" (31.c)
5. Proposed design           diagram, request path, data path, failure path
6. Capacity and cost         napkin maths, GPUs, $/M tokens, $/month (12.q, 23.b, 23.c)
7. Quality                   evals, regression tests, what "no worse" means (Module 28)
8. Failure modes             what breaks, blast radius, degradation plan (23.e)
9. Rollout and rollback      phases, gates, canary metrics, kill switch (23.g)
10. Observability            the metrics and alerts that prove it works (23.h)
11. Open questions, risks    the load-bearing assumptions, named
12. Decision record          what was decided, by whom, when; one-way or two-way door

Section 3 is where most inference docs are weakest. “Peak traffic” must be a distribution, not a number:

RequirementWeakStrong
Traffic“200 QPS”“200 req/s at p99 minute; 60 req/s daily average; 3× bursts at 09:00”
Prompts“~2k tokens”“median 1,800, p95 9,000, p99 31,000 input; 70% share a 1,500-token system prompt”
Latency“fast”“p95 TTFT < 800 ms for inputs ≤ 8k; p95 ITL < 40 ms” (23.a)
Quality“same as now”“no drop beyond noise on our 3 evals; KL vs reference < 0.01 nats” (Module 28)
Cost—“< $1.50 per million output tokens at peak load” (23.c)

Options: always three, always including “buy”#

A design with one option is a decision already made, looking for approval. Require at least:

  • Do nothing / minimal change. What does it cost to wait a quarter?
  • Buy or rent it. API or managed endpoint (31.c). Often the right answer for a new workload.
  • Build it. With the self-hosted cost from the waterfall (23.c), not the raw GPU price.

The reviewer’s checklist for inference#

Read the doc once for understanding, then once with this list.

Arithmetic

  • Does Little’s law close? Requests in flight × tokens per request × KV per token ≤ KV memory (12.f).
  • Are prefill and decode both counted? Input-heavy workloads (RAG, agents) are often prefill-bound.
  • Is the throughput figure measured at the SLO, on this model and hardware (22.g), or copied from a vendor slide?
  • Is utilization realistic? Peak at 100% busy means queueing explodes (20.c).

Traffic shape

  • What happens to the p99 prompt? To a burst of 3× in one minute?
  • Are there long-lived sessions (agents) whose KV should be kept between turns (24.h, Module 27)?
  • Is there batch or offline work that could fill troughs (Module 27)?

Quality

  • Which serving changes alter outputs: quantization, speculative decoding, new kernels, a new engine version? How is each gated (Module 28, 31.h)?
  • Are tokenizer and chat template pinned and tested (12.b)?

Failure

  • What is the blast radius of one GPU, one node, one zone, one bad deploy (23.e, 23.f)?
  • Is there admission control and load shedding (20.c, 20.e), or does overload become a retry storm?
  • What is the degraded mode: smaller model, shorter context, queue (21.k)?

Operations

  • Rollout gates and rollback time (23.g). Can we roll back a model in minutes?
  • The dashboards that would show this design failing, before users report it (23.h).
  • Who is on call, and do they know how to operate it?

Cost

  • $/M tokens at expected load and at peak, with the full waterfall (23.c).
  • Commitments created: reservations, contracts, minimum spends (31.d).

Running the review#

  • Send the doc 2–3 days before. Reviews of unread docs become presentations.
  • Comments in the doc, decisions in the meeting. Use the meeting for the 3–5 contested points.
  • Separate “must fix” from “consider”. A review that blocks on style teaches people to avoid reviews.
  • Name load-bearing assumptions and how to test them early. “If the prefix-cache hit rate is below 60%, we need 27 nodes, not 17. Measure it on a week of logs before ordering hardware.”
  • Record the decision with the doc: what, who, when, and what would make us revisit it.
  • Match rigour to reversibility. A two-way door (a new routing rule behind a flag) needs a page. A one-way door (a reserved cluster, a public API contract) needs the full template.

Lighter formats#

FormatUse for
Decision record (one page)a single choice with options and reasons
RFC (request for comments)changes many teams must agree on (an API, a platform contract)
Design doca new system or a large change
Pre-mortem“it is a year from now and this failed; why?” — run on any one-way door

6. Under the hood: checking a capacity claim#

The program checks section 4’s design. It uses Little’s law for memory and work per second for compute, then asks what would have to be true for the doc’s claim to hold. Throughput and memory numbers come from 23.c and 12.f; treat them as placeholders for your own measurements.

Go
// napkin.go — check a design doc's capacity claim in thirty lines of arithmetic.
package main

import (
	"fmt"
	"math"
)

func main() {
	// What the design doc says.
	const (
		claimedNodes = 4     // 8×H100 nodes
		peakRPS      = 200.0 // requests per second at peak
		inTok        = 2000.0
		outTok       = 400.0
		ttft, itl    = 0.5, 0.030 // seconds: the SLO targets
		cacheHit     = 0.0        // prefix-cache hit rate the doc assumes
	)
	// What we measured or know (23.c, 12.f).
	const (
		decodeTokS  = 8136.0  // output tok/s per node at batch ~96 (70B FP8, TP=8)
		prefillTokS = 50000.0 // input tok/s per node, prefill alone
		kvPerTokMB  = 0.16    // Llama-3-70B, FP8 KV: 80 layers × 8 heads × 128 × 2 × 1 B
		kvPerNodeGB = 480.0   // 640 GB HBM − 70 GB weights − activations and headroom
		targetUtil  = 0.70    // keep peak below 70% busy for latency headroom
	)

	// 1. Little's law: requests in flight = arrival rate × time in system.
	inSystem := ttft + outTok*itl
	concurrent := peakRPS * inSystem
	kvGB := concurrent * (inTok + outTok) * kvPerTokMB / 1000
	fmt.Printf("time in system %.1f s → %.0f requests in flight → %.0f GB of KV cache\n",
		inSystem, concurrent, kvGB)

	// 2. Work per second, in node-seconds per second (= nodes kept 100% busy).
	decodeNodes := peakRPS * outTok / decodeTokS
	prefillNodes := peakRPS * inTok * (1 - cacheHit) / prefillTokS
	memNodes := kvGB / kvPerNodeGB
	busy := decodeNodes + prefillNodes
	need := math.Ceil(busy/targetUtil) + 1 // +1 spare (23.e)
	fmt.Printf("decode %.1f + prefill %.1f = %.1f busy nodes; memory needs %.1f nodes\n",
		decodeNodes, prefillNodes, busy, memNodes)
	fmt.Printf("at %.0f%% target utilization plus one spare: %.0f nodes (doc claims %d)\n",
		targetUtil*100, need, claimedNodes)

	// 3. What would make the claim true?
	for _, hit := range []float64{0.5, 0.9} {
		p := peakRPS * inTok * (1 - hit) / prefillTokS
		fmt.Printf("  with %.0f%% prefix-cache hits: %.0f nodes\n", hit*100, math.Ceil((decodeNodes+p)/targetUtil)+1)
	}
	fmt.Printf("  to fit %d nodes at these rates, peak must be ≤ %.0f req/s\n", claimedNodes,
		float64(claimedNodes-1)*targetUtil/(outTok/decodeTokS+inTok/prefillTokS))
}

Output:

time in system 12.5 s → 2500 requests in flight → 960 GB of KV cache
decode 9.8 + prefill 8.0 = 17.8 busy nodes; memory needs 2.0 nodes
at 70% target utilization plus one spare: 27 nodes (doc claims 4)
  with 50% prefix-cache hits: 21 nodes
  with 90% prefix-cache hits: 17 nodes
  to fit 4 nodes at these rates, peak must be ≤ 24 req/s

How to read it:

  • Memory was never the problem. 960 GB of KV fits on two nodes. The doc’s author probably checked memory and stopped. Compute (prefill plus decode) needs nine times more.
  • Prefill is almost half the work. A 5:1 input-to-output ratio makes this an input-heavy workload. The single most valuable question in the review is “what is the prefix-cache hit rate?” (12.m, 21.h); the answer moves the design between 17 and 27 nodes.
  • The last line is the useful feedback. “Four nodes is right for 24 req/s” is a statement the author can act on, unlike “this seems low”.
  • Adding prefill and decode node-time is an approximation: with chunked prefill (12.k) they share steps and interfere slightly. For a design review, a factor-of-1.2 error is fine; a factor of 7 is not.

7. Performance implications#

  • A doc should state the operating point: the batch size, context length and latency at which throughput was measured. Throughput without latency is meaningless (2.c, 22.g).
  • The review should ask for the bottleneck: memory-bound decode, compute-bound prefill, network for multi-node, or the CPU front end (22.c, 22.i). The design should be shaped around it.
  • Ask for one benchmark before the review on the real model, hardware and a replay of real traffic. It replaces pages of debate.

8. Production implications#

  • Keep docs where people search. A doc nobody can find was never written.
  • Revisit after launch. Thirty to ninety days in, compare the doc’s numbers with production: traffic, hit rate, cost per token. The gaps teach the next author more than any template.
  • Make the template the default, so new engineers write good docs without being told.
  • Review your own docs harder. A principal’s design gets less pushback because of the title; ask a sceptic to review it.

9. Common mistakes#

  1. Only one option. It is a decision looking for approval.
  2. Average traffic instead of a distribution. The p99 prompt and the 09:00 burst break designs.
  3. Checking memory and forgetting compute (or the reverse). Both must close.
  4. Copying throughput from a vendor or a paper instead of measuring at the SLO.
  5. No quality section for a change that alters outputs.
  6. No rollback plan. “We will fix forward” is not a plan for a model rollout.
  7. Reviews that block on style. People stop asking for reviews.
  8. No decision record. The same debate returns in six months.

10. Hands-on exercise#

  1. Run napkin.go. Change the workload to 500-token prompts and 1,500-token answers (a generation-heavy workload). Which term dominates now? How many nodes?
  2. Set the time in system to 60 s (a reasoning model, Module 27). What happens to KV memory? Is memory now the bottleneck?
  3. Take a design doc you have written or read. Apply the checklist in section 5. List the load-bearing assumptions and how you would test each one in a week.
  4. Write a one-page decision record for “self-host vs API for our support assistant”, with three options, using numbers from 23.c.

11. Interview questions#

  1. What sections must an inference design doc have that a typical backend design doc might skip?
  2. A design claims a 70B model at 200 req/s on 32 H100s. How do you check it in two minutes?
  3. Why must “do nothing” and “buy it” appear among the options?
  4. What makes an assumption load-bearing, and what do you do about one?
  5. How do you run a design review that improves the design without slowing the team down?
  6. How should the rigour of a review depend on whether the decision is reversible?

12. Further reading#

Checked on 13 November 2026.

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in