Unit 6 of 12 · about 3 hours · measure

Measuring quantized memory, latency and throughput, including KV quantization

Quantization without measurement is a smaller file, not a faster service. Memory, latency and quality must be measured together on the workload that pays for them.

You'll be able to

  • Derive KV bytes per token for a stated attention shape and predict what FP8 KV quantization saves.
  • Measure weight and KV memory, TTFT, TPOT and throughput for a quantized path against its unquantized baseline.
  • Decide where KV quantization belongs in a long-context plan, with a quantized-attention condition.

Covers

Memory, latency and throughput measurementKV cache quantization under long context
1

Read

In this order, only the parts listed

0 of 3 done

  1. vLLM quantization support and quantized KV cachevLLM Speculative Decoding and Quantization (v0.31.0)

    Supported Hardware table (AWQ, GPTQ, Marlin, FP8 rows against Volta through Hopper) on the quantization page, then the Quantized KV Cache page: FP8 overview, per-tensor versus per-attention-head scales, the two scale-calibration approaches (default scales and dataset calibration with llm-compressor), and --kv-cache-dtype-skip-layers

    Read the pages against installed v0.31.0 only. Both flags named below are v0.31.0 flags; older releases differ. Bundled lab expectations for other GPUs are not your targets.

  2. Quantized serving behavior under concurrencyHands-On LLM Serving and Optimization - Quantization (Chapter 6) and Speculative Decoding (Chapter 7)

    Chapter 6: the concurrency charts comparing the original model with GPTQ W4A16 and FP8 W8A8 for TTFT and throughput, and KV cache quantization and attention quantization with the quantized-attention condition; then Chapter 9, Step 6 Benchmark the Quantized Qwen3 Model with vLLM (printed p. 304)

    Read the charts as the authors result on their hardware and model. Your unit reproduces the comparison shape, not their numbers.

  3. KV quantization and prefix cachingInference Engineering - Section 5.1, Quantization

    Section 5.1.2: the KV cache paragraphs (prefix caching and disaggregation gains, per-token reuse by later tokens)

2

Focus on

  • KV bytes per token are : two for keys and values, times layers, KV heads, head dimension and bytes per element. FP8 halves against FP16; per-head scales add a small metadata term.
  • Weight-only methods improve with concurrency differently from W8A8: GPTQ W4A16 still computes in 16-bit, so its TTFT can lag the baseline while FP8 pulls ahead on throughput.
  • Check your GPU row in the vLLM hardware table before planning a run. An unsupported path is not a slow path; it is absent.
  • KV quantization error persists across positions because every later token reads the stored values. Calibrate on long sequences and keep sensitive layers skippable.
Common mistakes · 3
  • Measuring throughput at one concurrency and generalizing. Weight-only and W8A8 cross over as concurrency rises; sweep it.
  • Comparing quantized quality without the engine contract. Keep prompts, output limits, sampling and cache state identical or the comparison is void.
  • Treating bundled B200 or GB200 expectation files as targets. They are another machine results; your numbers are labeled with your GPU, engine version and settings.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive KV bytes per token for , , in FP16, then state the FP8 saving and the maximum context that fits a stated KV budget in each precision.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.For , , , what are KV bytes per token in FP16 and FP8?Answer

    bytes in FP16, or 128 KiB, and half that, 64 KiB, in FP8 before scale metadata.

  2. 2.Why can GPTQ W4A16 lose on TTFT while winning on memory?Answer

    Prefill still computes in 16-bit after dequantization, adding conversion cost without compute savings. The win is weight capacity and decode bandwidth, visible under memory pressure.

  3. 3.When does FP8 KV cache need a quantized attention kernel to pay?Answer

    Whenever latency, not just capacity, is the goal. Without it the values are dequantized before the dot product; capacity still improves, arithmetic does not.

  4. 4.Which layers would you exempt first from KV quantization, and how?Answer

    Sliding-window or otherwise sensitive attention layers, via --kv-cache-dtype-skip-layers with layer indices or type names.

5

Practice

  • AI Systems Performance Engineering companion code Chapter 19: dynamic quantized cache

    baseline_dynamic_quantized_cache.py against optimized_dynamic_quantized_cache.py: the same refresh steps and cache footprint in FP32 versus adaptive INT8, INT6 and INT4 refresh. The harness only checks that the two outputs agree within output_tolerance=(0.05, 0.5), a loose cache-value check, not model quality

    Run on your GPU and report memory traffic beside your own quality check on a fixed workload; bundled B200 expectations are not targets.

You're done when

You derive KV bytes for a new shape without notes and produce a baseline-versus-quantized table with memory, TTFT, TPOT and quality on one fixed workload.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 10 more in the section
  • Hands-On LLM Serving and Optimization - Quantization (Chapter 6) and Speculative Decoding (Chapter 7)Chi Wang and Peiheng Hu (O'Reilly) · primary

    Read "Model Compression" in Chapter 6 for quantization and "Speculative Decoding" in Chapter 7, with its hands-on example. For each method write its correctness contract, the engine support it needs and a predicted winning and losing workload before running it.

  • vLLM Speculative Decoding and Quantization (v0.31.0)vLLM Project · required

    Use the speculative decoding page for the supported proposers (draft model, n-gram, EAGLE, MTP) and its losslessness notes, and the quantization page for the hardware support table. Check every method against your GPU's compute capability before planning a run.

  • Inference Engineering - Section 5.1, QuantizationPhilip Kiely (Baseten Books) · support

    Read 5.1.1 Number Formats for the format table and Precision/Type/Scale-factor with Dynamic range/Granularity, 5.1.2 for PTQ versus QAT and the what-to-quantize decisions, and 5.1.3 for the perplexity, benchmark and custom-eval quality checks.

Also in this section