If you work with LLMs and can explain attention, KV cache and quantization, but cannot clearly explain prefix caching, continuous batching, PagedAttention, chunked prefill, speculative decoding and prefill/decode disaggregation, there is still a large part of inference you have not learned yet.
These are not six names for making inference faster. They remove different kinds of waste in an LLM serving system.
1/ Prefix caching
If requests share the same token prefix, its KV states may already have been computed. Prefix caching reuses those states instead of repeating prefill over the shared prefix.
The uncached suffix still has to be processed, and generation of new tokens still runs normally.
2/ Continuous batching
Autoregressive requests rarely finish together. Instead of keeping one fixed batch until every request ends, the scheduler can remove finished requests and admit waiting ones between iterations.
GPU capacity is reused sooner.
3/ PagedAttention
KV cache grows with sequence length, while final length is unknown in advance. Large contiguous reservations can waste memory through fragmentation and over-reservation.
PagedAttention divides KV states into blocks and lets logical blocks map to non-contiguous physical GPU blocks. It is a KV-cache memory-management technique, not an approximation of attention.
4/ Chunked prefill
A long prefill can delay decode iterations for requests already being served.
Chunked prefill breaks prompt processing into smaller pieces so the scheduler can mix prefill and decode work. Chunk size becomes part of the latency/throughput trade-off.
5/ Speculative decoding
Ordinary autoregressive decoding requires repeated serial target-model steps.
A cheaper draft model proposes several tokens, and the target model evaluates those positions together. With the classic acceptance/correction procedure, accepted tokens can be emitted while preserving the target model’s sampling distribution.
Its benefit depends on draft cost, verification cost and acceptance rate.
6/ Prefill/decode disaggregation
Prefill and decode have different execution characteristics. Prefill is often more compute-intensive, while decode is often more sensitive to memory bandwidth.
Disaggregated serving places them on separate worker pools. Prefill builds the KV cache, that state is transferred, and decode continues elsewhere. The transfer itself has a cost.
What I find interesting about all six is that the model itself can remain exactly the same.
Prefix caching, batching, KV-cache allocation, scheduling, speculative execution and phase separation all change what happens around the model.
That is where a surprising amount of LLM serving performance is won or lost.
Happy Learning!!!
An article for everyone who ships, buys, or signs off on software built on large language models (LLMs): engineers, product managers, and the CEO. Written in plain language, from the big picture down to the details. https://t.co/YaP414vR0u
𝘃𝗟𝗟𝗠 𝘃𝘀 𝗦𝗚𝗟𝗮𝗻𝗴
If you’re self-hosting an LLM, you will hit this choice sooner or later.
vLLM or SGLang?
Both are open source. Both batch requests on the fly, cache memory, and give you an OpenAI-style API. On paper they look almost the same. The difference is in what each one cares about most.
vLLM started with PagedAttention. It splits the model’s memory into small blocks and places them anywhere on the GPU, so very little space goes to waste. Over time it has grown into the safe, broad choice: lots of models, lots of hardware, many LoRA adapters, and the biggest community.
SGLang started with RadixAttention. It keeps past requests in a tree. When a new request shares the same start, like the same system prompt or the same chat history, it reuses that work and only computes what is new. That makes a real difference for chat apps, agents, and RAG, where many requests begin the same way.
So my simple rule:
Lots of repeated prompts and multi-step flows? Try SGLang. Need wide model and hardware support with less friction? Start with vLLM.
And please don’t pick based on someone else’s benchmark chart. Both take one command to start. Run your own traffic through both and look at your own numbers.
I made this visual to break down the differences side by side.
𝗞𝗩 𝗖��𝗰𝗵𝗶𝗻𝗴 𝗘𝘅𝗽𝗹𝗮𝗶𝗻𝗲𝗱
Ever wondered how LLMs remember thousands of tokens without processing everything from scratch every time?
That's where KV Caching comes in.
When an LLM generates a response, it doesn't need to recompute the Key and Value representations of all previous tokens at every step.
Instead, it stores them in a cache and reuses them while generating the next token.
Sounds simple, but this makes a huge difference in inference speed and computational efficiency.
Here's what happens:
- During prefill, the model processes the prompt and stores the Keys and Values.
- During decoding, it computes Q, K and V only for the new token.
- The new K and V are added to the existing cache.
- Previous KV values are reused instead of being recomputed.
But there's one important thing to understand: KV Caching doesn't eliminate attention over previous tokens. It eliminates the need to recompute their Keys and Values.
As context grows, KV cache memory can become a major bottleneck.
That's why techniques like:
- MQA (Multi-Query Attention)
- GQA (Grouped-Query Attention)
- PagedAttention
- Prefix Caching
play an important role in making LLM inference more efficient.
Understanding KV Caching is essential if you're learning how LLM inference actually works or building systems that serve LLMs at scale.
learn dsh day1 :
it is a harness written by Typescript,
it is designed by the idea " Everything is a Plugin";
it makes agent internals replaceable plugins, emphasizing
- configurable composition,
- event logs,
- and interchangeable backends beyond typical agent extensions.