Reference · from Lessons 1–2

Latency metrics

The numbers that describe how fast a model feels, on one page.

Every streamed answer has this shape: a wait (TTFT), then a rhythm (ITL).

Definitions

MetricDefinitionFormulaMostly driven by
TTFT
time to first token · ms
Request sent → first non-empty token receivedmeasured directlyqueueing + prefill + network
ITL
inter-token latency · ms
Average gap between consecutive tokens, first token excluded(E2E − TTFT) / (N − 1)one decode step
Decode TPS
per user · tok/s
Speed of the stream after the first token1000 / ITLmsdecode speed
E2E
end-to-end latency · ms
Request sent → last token receivedTTFT + (N − 1) × ITLeverything, including client and network
Throughput
system TPS · tok/s
Output tokens per second across all concurrent requeststotal output tokens / wall timebatching, concurrency (see Under load)

Naming in this course: say ITL, not TPOT ("time per output token", same idea). Say decode TPS for the per-user stream speed and throughput for the system total. NVIDIA's "TPS per user" is N ÷ E2E, which includes TTFT, so always state your definition.Definitions and the caveat "tool implementations vary, so compare results only when definitions align": NVIDIA, "Metrics".

Formulas you'll use constantly

TPS = 1000 ÷ ITL(ms)   ·   ITL(ms) = 1000 ÷ TPS
E2E ≈ TTFT + (N − 1) × ITL
largest affordable ITL = (deadline − TTFT) ÷ (N − 1)
per-user TPS ≈ throughput ÷ concurrent users   (if shared evenly)

What moves what

You change…TTFTITLE2EWhy
Longer prompt↑↑≈ (slight ↑)↑more prefill before the first token
Longer answer==↑ linearmore decode steps, same cost each
Cold model↑↑↑=↑weights must load into memory first
Repeated prompt prefix↓↓=↓the server reuses cached prefill work (Lesson 19)
More users, one slot (queueing)↑↑↑=↑↑requests wait in line; throughput flat
More users, more slots (batching)↑↑↑each step serves several users; throughput ↑

Measuring honestly

Under load

Latency is what one user feels; throughput is what the server delivers in total. Serving more users from the same hardware usually raises the first and lowers the second's cost per token.

TermMeaning
p50 / p95 / p99the value that 50% / 5% / 1% of requests exceed. Means hide the tail; with N requests, p99 needs N well over 100.
SLOa target written as a percentile, e.g. "95% of requests have TTFT below 200 ms"
Goodputrequests per second completed while meeting the SLO
Queueingone slot: extra requests wait. TTFT ↑↑, ITL =, throughput flat
Batchingseveral slots decode in the same step. Throughput ↑, every user's ITL ↑
Closed loopC users, each waits for its reply before sending again (--concurrency). Load backs off when the server slows: coordinated omission.
Open looprequests arrive at a set rate regardless (--rate). Like real users; shows honest tails.
Online / offline / asynca person waits now (latency) / nobody waits (throughput, cost) / a queue + webhook with a deadline
Little's law: L = λ × W   (in system = arrival rate × time in system)
queued TTFT ≈ (requests ahead) × (time per request) + own prefill
P(at least one of n calls is slower than p99) = 1 − 0.99n
One slot makes requests take turns; four slots let them share each step.

Teacher's Lab 2 run on your Mac (llama3.2 3B, Ollama 0.6.8, 128 output tokens, 24 requests per level, closed loop):

SlotsLoadTTFT p50TTFT p99ITLE2E p50Throughput
1C=1145 ms181 ms18.9 ms2.5 s50 tok/s
1C=817,553 ms18,813 ms19.0 ms19.9 s50 tok/s
4C=4527 ms647 ms51.3 ms7.0 s73 tok/s
4C=87,131 ms7,261 ms49.1 ms13.3 s77 tok/s

On a datacenter GPU, batching is far cheaper: Databricks saw batch 64 give 14× throughput for 4× latency. Run it yourself: python3 labs/tools/load_test.py --label np1 --csv.

Your baseline

Your own Lab 1 numbers (M1 Pro, llama3.2 3B Q4_K_M via Ollama 0.6.8, 15 Oct 2026, from portfolio/LOG.md).

ConditionTTFTITLDecode TPS
~80-token prompt, warm≈ 145 ms≈ 18.5 ms≈ 55 tok/s
~1,420-token prompt, warm≈ 2,620 ms≈ 22.9 ms≈ 44 tok/s
Same long prompt, repeated (cached)≈ 36–49 ms
Cold start (load 2,019 ms + prefill 531 ms)≈ 2,570 ms

Sources