Why can generation feel slow and expensive?
An autoregressive LLM generates one token after another. Each new token depends on the existing sequence, so serving has to manage model memory, repeated attention work, batching, hardware utilization, and user latency.
KV cache — reuse attention states from earlier tokens
Without reuse, later generation steps would repeatedly recompute attention Keys and Values for the same earlier tokens. A KV cache stores those previous attention Key/Value states so the model can reuse them while generating later tokens.
KV caching reuses past attention state during token-by-token decoding
Quantization — use fewer bits for weights
If a 1-billion-parameter model uses an idealized 8-bit representation, that is roughly one byte per parameter:
Lower bit width can reduce memory, but 4-bit does not automatically mean faster. Actual latency depends on hardware support, kernels, runtime implementation, batch size, and workload.
Compare the raw-weight bars while keeping the additional runtime allocations in view. Reducing the weight representation does not remove the cache or the work needed to serve each request.
Lower bit width can reduce raw model storage—but runtime memory is larger
Two latency measures answer different questions
Interactive serving metrics
Batching trades individual waiting time for throughput
Serving several requests together can improve accelerator utilization and total throughput. But requests may wait in a queue while a batch forms or while long sequences occupy resources.
Typical trade-off
Why the next lesson matters
Serving optimization makes one model endpoint efficient. How do we version prompts, retrieval, models, observability, releases, retries, and rollback as one production LLM application?
LLMOps →Summary / Key Takeaways
- Autoregressive generation creates repeated inference work as tokens are produced sequentially.
- KV cache stores prior attention Key/Value states so later tokens can reuse them.
- A 1B-parameter 8-bit model is about 1 GB of raw weights in the simplified estimate, before runtime overhead.
- Lower precision saves representation memory but does not guarantee faster latency on every hardware/runtime stack.
- Time to first token measures initial responsiveness; generation rate and end-to-end latency answer different questions.
- Batching can increase throughput while increasing queueing and per-request latency.