Skip to content

๐Ÿ”ญ Chapter 3 โ€” Observability: What to Measure โ€‹

Episodes 14 โ€“ 16

๐Ÿชœ The instrument ladder (cheapest first) โ€‹

Each instrument sees out to a certain distance and then stops, and it won't tell you it stopped. It just answers.


1. ๐Ÿ“Š A dashboard built on four questions โ€‹

Each panel should answer one question you'd ask at 2 a.m. Build panels around the questions, not around metric names, because names change between vLLM, SGLang and TRT-LLM versions.

Q1. Is anything waiting, and why? โ€‹

Q2. Where did the time go? โ€‹

E2E = queue + prefill + decode. (TTFT includes the queue.)

  • Queue โ†‘ โ†’ capacity (back to Q1)
  • Prefill โ†‘ โ†’ longer prompts or batching changed
  • Decode โ†‘ (others flat) โ†’ memory bandwidth

๐Ÿ“‰ Histogram percentiles are estimates

The buckets are coarse and fixed, so a percentile is interpolated inside a wide bucket. Fine for trends, not for customer SLAs. Measure SLAs at the client.

Q3. Is the server redoing work? โ€‹

  • Preemption counter rising under steady traffic โ†’ admitting more than it can hold, so prompts get paid for twice.
  • Prefix cache hit rate: vLLM gives raw token counters (hits รท queries over any window). SGLang gives a lifetime rate, which barely moves when efficiency drops today. Window it yourself.
  • Eviction age vs reuse gap: if blocks are evicted faster than the typical reuse gap, the reuse is real and the cache is too small. Take that number to whoever owns the budget.

Q4. Am I filling the batch? โ€‹

  • vLLM: tokens per engine step histogram. Read the distribution, not the mean.
  • Triton: inference_count รท execution_count = average batch size.

๐Ÿซฅ A blank panel looks the same as a healthy one

vLLM renamed the KV-usage gauge and the prefix-cache counters between major versions and removed some outright. No error, the panel just draws nothing. Put metric names in dashboard variables so a rename is a one-place fix.


2. ๐Ÿ”ฌ Hardware counters (DCGM) โ€‹

CounterQuestion it answers
SM activeWas the whole card busy? (a job using โ…• of the SMs reads 20%, where nvidia-smi would show 100%)
Tensor pipe activeAre you using the tensor cores you paid for?
DRAM / memory interface activeHow close are you to the bandwidth limit?
NVLink bytesAre GPUs talking instead of computing?

The verdict card (cross the counters) โ€‹

SMTensorMemoryNVLinkVerdict
busyquietbusyโ€”๐ŸงŠ Bandwidth-bound (normal for decode)
busybusyโ€”โ€”๐Ÿ”ฅ Compute-bound (normal for long prefill)
lowlowlowhigh๐Ÿ“ก Communication-bound โ†’ check parallelism / link
lowlowlowlowโ“ Nothing saturated โ†’ go to the profiler

๐Ÿช‘ Occupancy โ‰  good usage

Occupancy counts resident warps (how full the seats are), not useful work. DCGM: higher occupancy does not necessarily indicate better GPU usage. It helps when you're memory-bound (it hides latency) but not when you're compute-bound. Read tensor-pipe + memory-interface instead.

๐Ÿ”ฅ The cheapest alert you don't have: clock throttle reasons โ€‹

Field values: SW power cap ยท SW thermal slowdown ยท HW slowdown (cuts clocks โ‰ฅ 2ร—; caused by heat, PSU brake, or fast power cut).

Everything slows down in proportion. Batches still form, cache still fills, every ratio looks normal, so there's no software symptom to find. Alert on throttle reason โ‰  0, and add XID (GPU fault) and PCIe replay counters.

โœ… This afternoon's job

The DCGM exporter's default metrics file ships with SM-active and occupancy commented out, and the clock-throttle field isn't in it at all. Uncomment them, add the clock + XID fields, restart the exporter.

NVIDIA has renamed these counters (the ratio names are current). Old names are deprecated aliases that still work for now.


3. โฑ๏ธ Profiling with Nsight Systems โ€‹

Counters are averages over a window, so they lose ordering. "Memory 40% busy" can mean 40% steady, or 4 s flat-out then 6 s idle. A profiler puts kernels on a time axis.

Two flags that matter:

  • --cuda-graph-trace=node: vLLM/TRT-LLM capture decode as a CUDA graph, and without this flag the whole step shows up as one opaque block. (Adds significant overhead, so turn it off afterwards.)
  • Python GIL trace: GIL contention is an easily missed cause of gaps.

Reading the gaps โ€‹

โš ๏ธ vLLM: end users should never enable profiling. 100 requests of a 70B trace on an H100 take about 10 minutes just to flush. Nsight Compute replays and serializes kernels, so never point it at a live server. On Trainium: neuron-monitor (counters) + Neuron Profiler (traces); a growing scratchpad means spilling off the chip.


4. ๐Ÿฉบ Clinic: every instrument is right and none of them helps โ€‹

#SymptomWhat's actually happeningFix
1Dashboard p99 TTFT = 280 ms (SLO 300), users say it's slowโ‘  The vLLM bucket runs 250โ€“500 ms, so a 250 ms-wide range vs a 20 ms margin. โ‘ก The server clock starts at arrival; LB, network and client time are invisibleTime at the client and compare with the dashboard for the same window
2Occupancy ~80%, is the GPU used well?Occupancy = seats filled, not work doneRead tensor-pipe + memory-interface. Both low โ†’ profiler
3Profiler clean, traffic unchanged, ยฝ the tokens/s of last weekHW slowdown clock throttlingThrottle-reason field; alert on โ‰  0

๐Ÿง  The rule

Software bugs make one number move while the others don't. A slow clock drags everything down together. If nothing moved relative to anything else, check the hardware first.

Order of investigation: hardware at full speed? โ†’ client timing โ†’ server metrics (which stage) โ†’ counters (which resource) โ†’ profiler (why nobody is busy).

<<>> with โ™ฅ๏ธ by S@Nchit