Slides · Inference engineering

Inference engineering: interview drills

Inference engineering: interview drills

Turning the module into spoken answers: ninety-second explanations, whiteboard arithmetic, a forty-minute platform design and symptom diagnosis.

By the end you can explain the core serving ideas aloud, work the standard derivations with stated assumptions, structure a platform design in seven parts, and name likely causes of a serving symptom with the fix and its price.

Concept

How to use these drills

  • Answer aloud, under a clock, before opening the answer. Reading a drill teaches little.
  • Provenance: every question or drill slide carries its own label, Common industry pattern or Generated practice; the worked derivations use invented numbers and are labelled Generated practice. None is verified as asked by a named company, and this deck makes no such claim.
  • The lesson notes that serving interviews tend to probe whether you start from bytes and FLOPs, separate the two phases, put numbers on claims and raise failure modes unprompted. That is the lesson’s observation, not measured data.
  • Numbers marked illustrative are invented to make the arithmetic concrete. Hardware and engine facts are as read on 24 October 2026.

Diagram

The order of a strong design answer

Diagram: A forty-minute design answer goes through seven steps in a fixed order: clarify the targets, estimate from model size and traffic, choose...

1 Clarify targets

2 Estimate

3 Choose the stack

4 Draw the architecture

5 Evaluate and roll out

6 Name failure modes

7 Cost and trade-offs

Diagram summary: A forty-minute design answer goes through seven steps in a fixed order: clarify the targets, estimate from model size and traffic, choose the stack, draw the architecture, plan evaluation and rollout, name the failure modes, then cost and trade-offs. The fixed order keeps the speaker calm and lets the listener follow.

Worked example

A ninety-second answer: why batching and paging help decode

Provenance: Common industry pattern.

“Decode makes one token per step and reads every weight each time, so at small batch the arithmetic units wait on memory. A bigger batch reuses each weight read for more sequences, so throughput rises while a step costs about the same. The limit is the KV cache: every sequence holds keys and values for its past tokens. PagedAttention allocates that cache in blocks on demand, so little memory is wasted and more sequences fit. Batching and paging raise throughput; they do not shrink the bytes or make one sequence faster.”

Claim in the answerSupport
Paging cuts KV wasteThe PagedAttention abstract aims for near-zero waste in KV cache memory and reports 2 to 4 times the throughput of the systems it compares against
A bigger batch reuses weight readsLesson 1 derivation: operations per byte grow with batch size
Batching does not shrink bytesCourse reasoning, not a sourced claim

Source1 Efficient Memory Management for Large Language Model Serving with PagedAttention

Compare

Six explanations to rehearse, with the number and the trade-off

Provenance: Common industry pattern.

TopicSay this, with one numberThe trade-off to name
Prefill and decodePrefill handles the prompt in parallel and sets time to first token; decode makes one token per stepDifferent bottlenecks need different levers
KV cache2×layers×KV heads×head dimension×bytes2 \times \text{layers} \times \text{KV heads} \times \text{head dimension} \times \text{bytes} per token; pool after weights divided by bytes per sequenceLonger context means fewer concurrent users
Batching with pagingBatch re-formed every step; blocks allocated on demandRaises batch size, not speed of one sequence
QuantizationWeight-only helps memory-bound decode; validate on your tasksQuality risk, so canary it
Speculative decodingDraft, verify, accept or resample; the vLLM page says it targets memory-bound, low-to-medium loadGains shrink at high batch or low acceptance
FlashAttentionAn exact attention algorithm that cuts reads and writes between memory levelsNo accuracy trade-off; the gain is less memory traffic

Sources2 Speculative Decoding3 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness

Math

The derivations on one slide

step_floor_s=weight_bytesbandwidth\text{step\_floor\_s} = \frac{\text{weight\_bytes}}{\text{bandwidth}}kv_per_token=2×layers×kv_heads×head_dim×bytes_per_value\text{kv\_per\_token} = 2 \times \text{layers} \times \text{kv\_heads} \times \text{head\_dim} \times \text{bytes\_per\_value}sequences=pool_byteskv_per_token×tokens_per_sequence\text{sequences} = \frac{\text{pool\_bytes}}{\text{kv\_per\_token} \times \text{tokens\_per\_sequence}}spec_tokens=1−ag+11−a\text{spec\_tokens} = \frac{1 - a^{g+1}}{1 - a}spec_speedup=spec_tokensgc+1\text{spec\_speedup} = \frac{\text{spec\_tokens}}{g c + 1}cost_per_M=price_per_hourfull_tps×utilization×3600×106\text{cost\_per\_M} = \frac{\text{price\_per\_hour}}{\text{full\_tps} \times \text{utilization} \times 3600} \times 10^{6}replicas=⌈rps×tokens_eachreplica_tps×target_util⌉+spares\text{replicas} = \left\lceil \frac{\text{rps} \times \text{tokens\_each}}{\text{replica\_tps} \times \text{target\_util}} \right\rceil + \text{spares}
SymbolMeaning
aaChance the target accepts each drafted token, assumed the same for every token
ggDraft length, tokens proposed per step
ccCost of one draft step as a fraction of one target step
full_tps\text{full\_tps}Output tokens per second at full load

The speedup formula is Theorem 3.8 of Leviathan et al. (ICML 2023). It assumes one acceptance chance for every token and long generations, and it ignores batching effects.

Source4 Fast Inference from Transformers via Speculative Decoding

Worked example

Worked: the batch-1 decode ceiling and the cache

Provenance: Generated practice (invented model; hardware figure from the cited page).

A 30B model stored in 8-bit weights (30 GB), batch 1, on an H100 SXM at 3.35 TB/s (NVIDIA product page, read 24 October 2026).

StepArithmeticResult
Step floor30 GB/3,350 GB/s30\ \text{GB} / 3{,}350\ \text{GB/s}8.96 ms
Ceiling1/0.008961 / 0.00896about 112 tokens/s

For the cache, take an illustrative model with 48 layers, 8 KV heads, head dimension 128 and a 16-bit cache, and a 40 GB pool.

StepArithmeticResult
Bytes per token2×48×8×128×22 \times 48 \times 8 \times 128 \times 2196,608
One 6,000-token sequence6,000×196,6086{,}000 \times 196{,}6081.18 GB
Sequences in the pool40/1.1840 / 1.1833

The ceiling counts only weights. Cache reads, communication and overhead lower it.

Source5 NVIDIA H100 Tensor Core GPU

Worked example

Worked: when speculation pays and when it does not

Provenance: Generated practice (invented numbers; the formula is from the paper).

Casea,g,ca, g, cTokens per stepSpeedup
Good draft0.75, 4, 0.05(1−0.755)/0.25=3.05(1 - 0.75^{5}) / 0.25 = 3.053.05/1.2=2.543.05 / 1.2 = 2.54
Poor draft0.1, 4, 0.2(1−0.15)/0.9=1.11(1 - 0.1^{5}) / 0.9 = 1.111.11/1.8=0.621.11 / 1.8 = 0.62

In the poor case each step yields barely more than one token but pays for four draft steps, so the result is slower than not speculating. The paper’s Corollary 3.9 says that if the acceptance chance exceeds the cost ratio, some draft length gives an improvement. The poor draft sits below that line (0.1 against 0.2), so no promise applies; the paper does not say the reverse direction, so test any case near the line. The vLLM speculative-decoding page, dated 23 October 2026, says the technique aims to cut inter-token latency for memory-bound workloads at medium-to-low request rates.

Source4 Fast Inference from Transformers via Speculative Decoding

Worked example

Worked: cost per million tokens and replicas

Provenance: Generated practice.

All figures illustrative. A GPU rents at 5.00 dollars an hour and makes 3,000 output tokens per second at full load, but runs at 35 percent utilization.

StepArithmeticResult
Effective rate3,000×0.353{,}000 \times 0.351,050 tokens/s
Cost per million5.00/(1,050×3,600)×1,000,0005.00 / (1{,}050 \times 3{,}600) \times 1{,}000{,}0001.32 dollars
Full-load cost5.00/(3,000×3,600)×1,000,0005.00 / (3{,}000 \times 3{,}600) \times 1{,}000{,}0000.46 dollars

Replicas for a peak of 9 requests per second at 500 output tokens, with 1,100 tokens per second per replica at target, utilization 0.7 and one spare: 9×500=4,5009 \times 500 = 4{,}500 tokens/s; 4,500/(1,100×0.7)=5.844{,}500 / (1{,}100 \times 0.7) = 5.84, so 6 serving and 7 in all. Then check the cache with Little’s law.

Code

The derivations as a short script

Python

import math

def spec_speedup(alpha, gamma, c):
    if not 0 <= alpha < 1:
        raise ValueError("alpha must be in [0, 1)")
    if isinstance(gamma, bool) or gamma < 1 or int(gamma) != gamma:
        raise ValueError("gamma must be a positive integer")
    if c < 0:
        raise ValueError("c must be non-negative")
    tokens = (1 - alpha ** (gamma + 1)) / (1 - alpha)
    return tokens, tokens / (gamma * c + 1)

def cost_per_million(dollars_per_hour, full_load_tps, utilization):
    if not 0 < utilization <= 1:
        raise ValueError("utilization must be in (0, 1]")
    if dollars_per_hour < 0 or full_load_tps <= 0:
        raise ValueError("price must be non-negative and throughput positive")
    return dollars_per_hour / (full_load_tps * utilization * 3600) * 1e6

def replicas(rps, tokens_per_request, replica_tps, target_util, spare=1):
    if min(rps, tokens_per_request, replica_tps) <= 0 or not 0 < target_util <= 1:
        raise ValueError("rates must be positive and target_util in (0, 1]")
    if spare < 0:
        raise ValueError("spare must be zero or more")
    serving = math.ceil(rps * tokens_per_request / (replica_tps * target_util))
    return serving, serving + spare
Call runResult
spec_speedup(0.75, 4, 0.05)3.05 tokens per step, speedup 2.54
spec_speedup(0.1, 4, 0.2)1.11 tokens per step, speedup 0.62
cost_per_million(5.0, 3000, 0.35)1.32
replicas(9, 500, 1100, 0.7)(6, 7)
Alpha of 1.0, gamma of 0, 2.5 or True, negative cValueError
Utilization of 0 or 1.5, zero target utilization, zero rate or a negative spareValueError

Check yourself

Check: choose the draft length

Provenance: Generated practice.

A draft model has an acceptance chance of 0.7 and costs 0.1 of a target step. Compute the speedup for draft lengths 2, 4 and 8, and say which you would deploy and why a longer draft is not always better.

Answer

Tokens per step are 2.19, 2.77 and 3.20, and the divisors are 1.2, 1.4 and 1.8, so the speedups are about 1.83, 1.98 and 1.78. Length 4 is best of the three. Each extra drafted token adds a full draft cost but is accepted with a shrinking probability (0.7 raised to the position), so past some length the added cost outweighs the added tokens. In production the right length also depends on batch size, which this formula ignores.

Source4 Fast Inference from Transformers via Speculative Decoding

Check yourself

Check: which deployment is cheaper per token

Provenance: Generated practice.

Option A: 4.00 dollars an hour, 2,000 tokens per second at full load, 40 percent utilization. Option B: 2.20 dollars an hour, 1,100 tokens per second at full load, 70 percent utilization. Which costs less per million tokens, and what other question belongs next to the price?

Answer

A: 4.00/(800×3,600)×1,000,000=1.394.00 / (800 \times 3{,}600) \times 1{,}000{,}000 = 1.39 dollars. B: 2.20/(770×3,600)×1,000,000=0.792.20 / (770 \times 3{,}600) \times 1{,}000{,}000 = 0.79 dollars. B is cheaper because its utilization is higher, even though its peak speed is lower. Next question: can B meet the latency target at 70 percent utilization with the traffic’s burstiness, and is there headroom for failure and deploys?

Check yourself

Check: how much traffic can this fleet carry

Provenance: Generated practice.

A fleet has 5 replicas, one of them held as a spare. Each sustains 1,300 output tokens per second at the latency target, the plan uses 0.65 target utilization, and requests average 350 output tokens. What peak request rate can it carry, and what happens to that figure if the spare is also used for traffic?

Answer

Serving replicas: 4. Planned capacity: 4×1,300×0.65=3,3804 \times 1{,}300 \times 0.65 = 3{,}380 tokens/s. At 350 tokens each that is 3,380/350=9.663{,}380 / 350 = 9.66 requests per second. Using all five gives 5×1,300×0.65/350=12.15 \times 1{,}300 \times 0.65 / 350 = 12.1 requests per second, but a replica failure or a deploy then drops capacity below the plan with nothing to absorb it. The cache check still applies at either figure.

Worked example

Design drill 1, the estimate step

Provenance: Generated practice.

Prompt: serve a chat assistant for about 1,500 concurrent users on one fleet, with no external APIs, using a 34B model with 8-bit weights on single 80 GB GPUs. Each user sends a request every 90 s on average and a request takes about 10 s. Cache cost is 196,608 bytes per token (the illustrative configuration from the earlier slide), and sequences average 4,000 tokens.

StepArithmeticResult
Arrival rate1,500/901{,}500 / 9016.7 per second
In flight (Little’s law)16.7×1016.7 \times 10about 167
Cache budget per GPU0.9×80−34−40.9 \times 80 - 34 - 434 GB
Sequence size4,000×196,6084{,}000 \times 196{,}6080.79 GB
Sequences per replica34/0.7934 / 0.7943
Replicas for the cache167/43167 / 433.9, so 4

Throughput from an open-loop benchmark may ask for more. Prefix caching helps only when the leading tokens match exactly, because each block’s hash includes the blocks before it.

Source6 Automatic Prefix Caching

Diagram

Design drill 1, the architecture step

Provenance: Generated practice.

Diagram: Users reach a gateway and a router that sends interactive traffic and batch traffic to separate pools.

Users and services

Gateway: auth, quotas

Router: priority, affinity

Interactive pool

Batch pool

Metrics and traces

Autoscaler

Diagram summary: Users reach a gateway and a router that sends interactive traffic and batch traffic to separate pools. Both pools emit metrics, and an autoscaler uses queue and cache signals to add or remove replicas, so batch work cannot crowd out chat.

Compare

From a vague design answer to a strong one

What a weak answer saysHow a stronger answer says it
“It should scale well.”“Peak is 30 requests per second at about 8 s each, so roughly 240 in flight; that is my cache check.”
“One cluster handles everything.”“Chat and batch go to separate pools, so a nightly job cannot queue behind or in front of chat.”
“We add GPUs when it is busy.”“Scale on waiting requests and cache use, with a scheduled ramp for the known peak, because a new replica needs minutes.”
“Then we monitor it.”“Page on first-token and per-token latency against target; keep cache and queue graphs for diagnosis.”
“Quantize it to save money.”“Canary the quantized build against the current one with a task evaluation, and keep the rollback.”
(silence about failure)“If a replica dies mid-stream the user keeps the text so far; the retry applies only before the first token.”

The SRE book’s advice to spend much more effort on symptoms than causes sits behind the monitoring row. The rows are the lesson’s judgment about what reads as experienced, not measured data on what interviewers reward.

Source7 Chapter 6: Monitoring Distributed Systems

Check yourself

Check: the interviewer changes a constraint

Provenance: Generated practice.

In drill 1 the interviewer says peak traffic triples. Re-cost the cache plan aloud. Then offer one way to avoid tripling the fleet and its price.

Answer

In flight becomes about 500 (3×1673 \times 167). At 43 sequences per replica that is 500/43=11.6500 / 43 = 11.6, so 12 replicas for the cache, three times the earlier 4. One alternative: cut the context cap to 2,000 tokens, which halves the sequence size to 0.39 GB and doubles the pool’s capacity to about 86 sequences, so 500/86=5.8500 / 86 = 5.8, or 6 replicas. The price is that long conversations are truncated or summarized, which needs a quality check. Say that aloud, then name what you would measure.

Worked example

Design drill 2: the model doubles in size

Provenance: Generated practice.

Today a 70B model with 8-bit weights (70 GB) runs on two 80 GB H100 GPUs. The new model has 140B parameters.

LayoutCache budgetWeights-only floorLoad time at 2 GB/s
70B on 2 GPUs0.9×160−70−8=66 GB0.9 \times 160 - 70 - 8 = 66\ \text{GB}70/6.7 TB/s=10.4 ms70 / 6.7\ \text{TB/s} = 10.4\ \text{ms}35 s
140B on 2 GPUs0.9×160−140−8=−4 GB0.9 \times 160 - 140 - 8 = -4\ \text{GB}does not fitn/a
140B on 4 GPUs0.9×320−140−16=132 GB0.9 \times 320 - 140 - 16 = 132\ \text{GB}140/13.4 TB/s=10.4 ms140 / 13.4\ \text{TB/s} = 10.4\ \text{ms}70 s

Four GPUs keep the step floor unchanged because aggregate bandwidth doubles with the bytes, but add the cost of two more GPUs per replica, more tensor-parallel messages, and a slower cold start. The vLLM parallelism page suggests tensor parallelism inside a node, so four GPUs in one node is the default. The load-time column assumes one serial stream at 2 GB/s; with four GPUs loading shards in parallel it may not double. The first measurement to take on real hardware is the open-loop goodput of one replica on your own traffic.

Sources5 NVIDIA H100 Tensor Core GPU8 Parallelism and Scaling (vLLM documentation)

Compare

Rapid-fire answers, part 1 (about twenty seconds each)

Provenance: Common industry pattern.

QuestionAnswer
Why does batching raise throughput at first without hurting latency?Each weight read is shared by the whole batch, and the arithmetic units were idle, so a step takes about the same
What do KV heads have to do with cost?Cache bytes per token scale with the number of KV heads, so they set concurrency
Why not add GPUs with tensor parallelism forever?Messages inside every layer grow with the degree; the vLLM tuning page warns of excessive synchronization overhead
Prompt caching versus semantic caching?Prompt caching reuses prefill for identical leading tokens (vLLM hashes blocks that include their prefix); semantic caching returns stored answers for similar queries, a course definition
Is FlashAttention approximate?No; its paper calls it an exact attention algorithm that reduces memory reads and writes

Sources3 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness9 Optimization and Tuning6 Automatic Prefix Caching

Compare

Rapid-fire answers, part 2

Provenance: Common industry pattern.

QuestionAnswer
When does speculative decoding backfire?At large batch, at low acceptance, or when the draft costs too much; the vLLM page frames it for memory-bound, low-to-medium load
Why is p99 time to first token worse than p50 for chat?Queueing, long prompts, preemption, cold replicas and cache misses hit a tail of requests
What must a replica health check do?Generate a token through the engine and GPU, not only return HTTP 200
What do you scale on?Queue depth, cache utilization and time to first token, not CPU or GPU utilization alone
Why can’t a single decode step use the GPU’s full compute?One token per sequence means each weight value feeds only about two operations (a multiply and an add), roughly one per byte at 16 bits, so at small batch the arithmetic units wait on memory (lesson 1)
A long shared system prompt is prefilled again for every request. What is the first fix?Prefix caching, so repeated blocks are reused; then check the hit rate
What is goodput?Output tokens per second from requests that met the latency target, not raw tokens per second

Source2 Speculative Decoding

Code

Why temperature 0 can still vary

Provenance: Generated practice.

Floating-point addition is not associative, so the order of a sum changes the result. GPU kernels may sum in different orders depending on batch composition and kernel choice, which is a plausible route to small output differences. This is the usual explanation, not something this deck measures on an engine.

Python

a = (0.1 + 0.2) + 0.3
b = 0.1 + (0.2 + 0.3)
print(a, b, a == b)
RunResult
Python 3 doubles0.6000000000000001 0.6 False

A tiny difference in a logit can flip which token is largest when two candidates are close, and every later token then follows a different path.

Diagram

Start every scenario with the symptom

Diagram: Name the symptom first: a slow first token, a slow stream, rising cost at flat traffic, or a quality drop.

Serving symptom

Slow first token

Slow stream

Cost up, flat traffic

Quality dropped

Diagram summary: Name the symptom first: a slow first token, a slow stream, rising cost at flat traffic, or a quality drop. Each points at its own short list of causes (queueing and prefix hit rate, batch growth or throttling, tokens per request or routing, a recent quantization or kernel change).

Compare

Scenarios, part 1: diagnose aloud, then read

Provenance: Generated practice.

SymptomLikely cause and first checkFix and its price
Throughput rose 30 percent after a 4-bit build, and tickets about wrong tool arguments doubledAn average hides a capability loss; run task evaluations on tool-call accuracy against the baseline, sliced by tool8-bit or mixed precision costs memory; keep a rollback
Streaming stutters whenever someone pastes a huge documentBig prefills share steps with decodes; check prompt length and step timesChunked prefill, input caps or a separate long-prompt pool; the price is complexity and some rejected input
GPU utilization reads 90 percent but throughput fellA full cache causing preemption and recompute; the vLLM tuning page says preempted requests are recomputed, and the counter is exposedCap concurrency or context, add replicas, or shrink the cache with quantization

Source9 Optimization and Tuning

Compare

Scenarios, part 2: slice the evidence

Provenance: Generated practice.

SymptomLikely cause and first checkFix and its price
After a kernel upgrade the overall evaluation score is flat, but support tickets from one language doubleAn average hides a segment loss; rerun the evaluation sliced by language, input length and task type against the old buildRoll back or fix the kernel; the price is delay and a larger evaluation set to maintain
p99 inter-token latency spikes for a minute whenever a new replica joins the poolThe replica takes full traffic before it is warm; check how readiness is decidedGate traffic until a health check generates a token, then ramp it; the price is slower scale-up

The first row splits the metric into the segments users belong to before judging a change. The second holds traffic back until the replica is ready.

Source9 Optimization and Tuning

Worked example

Worked: a model that thinks before it answers

Provenance: Generated practice.

Traffic is flat at 30 requests per second. The old model wrote 250 output tokens. A replacement writes hidden reasoning first and then the answer; assume 2,000 reasoning tokens plus 250 answer tokens (invented numbers), at 30 ms per token on the 70B configuration (327,680 bytes of cache per token, worked out in the scenario slide below, and a 66 GB pool).

QuantityOldNew
Output tokens per request2502,250
Decode time at 30 ms per token7.5 s67.5 s
Output tokens per second at 30 requests per second7,50067,500
Cache per finished sequence (1,200 input tokens plus output)0.475 GB1.13 GB
Sequences in the pool13858

Cost and latency rise together because decode work grew ninefold while prompts did not change, and each sequence holds the cache longer and larger. The checks are output-length percentiles per request and the replica arithmetic redone at the new length. Options include a cap on reasoning length, a router that sends easy requests to the cheaper model, and more replicas, each with a quality or cost price.

Worked example

Worked scenario: a 64k-context feature runs replicas out of memory

Provenance: Generated practice.

A 70B model with 80 layers, 8 KV heads and head dimension 128 in a 16-bit cache costs 2×80×8×128×2=327,6802 \times 80 \times 8 \times 128 \times 2 = 327{,}680 bytes per token. A replica on two 80 GB GPUs has a 66 GB cache pool.

StepArithmeticResult
One 64k sequence65,536×327,68065{,}536 \times 327{,}68021.5 GB
Sequences in the pool66/21.566 / 21.53
For comparison, 4,000 tokens4,000×327,6804{,}000 \times 327{,}6801.31 GB, so 50 fit

Three sequences per replica explains the out-of-memory errors under load. Options: cap and tier the context, send long requests to a dedicated pool, use chunked prefill, quantize the cache once quality is validated at long lengths, or retrieve instead of stuffing. Each has a cost in quality, complexity or hardware.

Check yourself

Check: adapters arrive, hit rate falls

Provenance: Generated practice.

A team begins serving one LoRA adapter per customer on a shared base model. Time to first token and cost rise, inter-token latency is flat, and the prefix-cache hit rate drops. Give the likely cause, one check and one fix with its price.

Answer

The vLLM prefix-caching page lists LoRA ids among the extra values in a block’s hash, so blocks cached under one adapter are not reused under another, and the shared system prompt is now prefilled once per adapter. Check the hit rate split by adapter and the share of traffic per adapter. Fixes: route each adapter’s traffic to replicas that already hold its cache (adapter-aware routing), at the price of hot spots for popular adapters; or shorten the shared prompt. Decode is unchanged, which matches the flat inter-token latency.

Source6 Automatic Prefix Caching

Check yourself

Check: bigger weights, slower stream

Provenance: Generated practice.

A team moves a 70B model from 8-bit to 16-bit weights on the same two GPUs of 3.35 TB/s each. Time to first token is not the complaint, but the stream is slower. Predict the new weights-only step floor and say why.

Answer

Weights double from 70 GB to 140 GB, and decode reads them all every step. Floor: 70/6.7 TB/s=10.4 ms70 / 6.7\ \text{TB/s} = 10.4\ \text{ms} before, 140/6.7=20.9 ms140 / 6.7 = 20.9\ \text{ms} after. Bytes read per step, not arithmetic, set the decode pace, so inter-token latency roughly doubles at small batch.

Check yourself

Check: critique this explanation

Provenance: Generated practice.

A candidate says: “Speculative decoding uses a smaller model to write the answer, so it is faster but the answers are a bit worse.” Name the error, then give a repaired ninety-second answer in three sentences.

Answer

The error is that the output quality is unchanged: the paper’s abstract says the method speeds up sampling without changing the distribution. The small model only proposes tokens, and the large model checks them in one pass, accepting or resampling. Repair: “A cheap draft proposes a few tokens, the target model scores them all in one pass and keeps the ones it would have produced, so outputs are the same in distribution. The speedup is the expected tokens per step divided by the extra draft cost, and it falls when acceptance is low or the batch is large. I would turn it on for low-concurrency, latency-sensitive traffic and measure acceptance in production.”

Source4 Fast Inference from Transformers via Speculative Decoding

Summary

Recap

  • Explain each core idea in about ninety seconds with one number and one trade-off: phases, cache, batching with paging, quantization, speculation, levers.
  • Know the derivations: batch-1 ceiling, cache bytes and concurrency, speculative speedup, cost per million tokens with utilization, replicas with Little’s law.
  • Design in seven parts: clarify, estimate, stack, architecture, evaluation and rollout, failure modes, cost and trade-offs; re-cost aloud when a constraint changes.
  • Diagnose by symptom first, then cause, then a fix with its price.

References

References & Sources (1 of 2)

  1. Efficient Memory Management for Large Language Model Serving with PagedAttention (opens in a new tab)

    Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, et al.2023Preprint

    Used for PagedAttention and vLLM aiming for near-zero waste in KV cache memory, and the reported 2 to 4 times throughput over the compared systems at similar latency.

  2. Speculative Decoding (opens in a new tab)

    vLLM project2026Documentation

    Used for Speculative decoding aims to cut inter-token latency for memory-bound workloads at medium-to-low request rates. Page dated 23 October 2026.

  3. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness (opens in a new tab)

    Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra, et al.2022NeurIPS 2022Paper

    Used for FlashAttention as an IO-aware exact attention algorithm that uses tiling to reduce memory reads and writes.

  4. Fast Inference from Transformers via Speculative Decoding (opens in a new tab)

    Yaniv Leviathan, Matan Kalman, Yossi Matias2023ICML 2023 (PMLR 202)Paper

    Used for Sampling speed-up without changing the distribution, the expected tokens per step, the walltime improvement factor with a draft cost ratio (Theorem 3.8) and Corollary 3.9, which says that if acceptance exceeds the cost ratio some draft length gives an improvement.

  5. NVIDIA H100 Tensor Core GPU (opens in a new tab)

    NVIDIA2026Documentation

    Used for H100 SXM memory bandwidth of 3.35 TB/s, read 24 October 2026.

References

References & Sources (2 of 2)

  1. Automatic Prefix Caching (opens in a new tab)

    vLLM project2026Documentation

    Used for Only full blocks are cached, a block's hash includes its prefix, and LoRA ids are among the extra values in the hash.

  2. Chapter 6: Monitoring Distributed Systems (opens in a new tab)

    Rob Ewaschuk2017Book

    Used for Spend much more effort on catching symptoms than causes when paging.

  3. Parallelism and Scaling (vLLM documentation) (opens in a new tab)

    vLLM project2026Documentation

    Used for Tensor parallelism inside a node, fast links such as InfiniBand for multi-node tensor parallelism, and how to check the transport. Page dated 15 October 2026.

  4. Optimization and Tuning (opens in a new tab)

    vLLM project2026Documentation

    Used for Excessive synchronization overhead from large tensor-parallel sizes, and preemption with recomputation when the KV cache runs short. Page read 24 October 2026.