vLLM

LLM inference looks complicated.
It mostly comes down to 4 runtime tricks.
๐ญ) ๐๐ผ๐ป๐๐ถ๐ป๐๐ผ๐๐ ๐ฏ๐ฎ๐๐ฐ๐ต๐ถ๐ป๐ด
Old batching waits for the slowest request.
Continuous batching swaps in a new request the moment another one finishes.
That keeps the GPU busy instead of leaving slots idle.
๐ฎ) ๐ฃ๐ฎ๐ด๐ฒ๐ฑ๐๐๐๐ฒ๐ป๐๐ถ๐ผ๐ป
KV cache is the memory bottleneck.
Instead of reserving one huge contiguous block, PagedAttention splits it into small pages and allocates them only when needed.
That cuts waste and lets more requests fit on the same GPU.
๐ฏ) ๐ฃ๐ฟ๐ฒ๐ณ๐ถ๐
๐ฐ๐ฎ๐ฐ๐ต๐ถ๐ป๐ด
A lot of requests share the same prompt start:
- system prompts
- few-shot examples
- RAG context
- conversation history
Prefix caching computes that shared prefix once, then reuses the KV cache.
Less recomputation. More throughput.
๐ฐ) ๐ฆ๐ฝ๐ฒ๐ฐ๐๐น๐ฎ๐๐ถ๐๐ฒ ๐ฑ๐ฒ๐ฐ๐ผ๐ฑ๐ถ๐ป๐ด
Generation is still sequential by default.
Speculative decoding speeds it up by:
- proposing several tokens with a small drafter
- verifying them in one pass with the main model
If the guess is right, you accept multiple tokens at once.
The result:
- lower latency
- higher throughput
- better GPU utilisation
Originally published on LinkedIn.
Turn your expertise into LinkedIn posts like this one.
Try Postars free โ