DEV Community

gxqwb
gxqwb

Posted on

Prefill vs Decode Disaggregation: Why LLM Serving Split Itself in Two

An inference request has a beginning and a long tail. The beginning is the prompt: thousands of tokens arrive at once and the model processes them in parallel, doing the dense matrix work that training also does. The tail is generation: one token at a time, each step rereading the same weights and the same growing cache of previous keys and values. Those two phases are so different in appetite that treating them as one job is a design choice, not a neutral default.

Monolithic serving makes prefill and decode compete for the same GPU, while disaggregation gives each phase its own pool, so the real decision is whether you want a simple scheduler or high utilization.

Part One: Two phases, two bottlenecks

Prefill is compute-bound. The prompt tokens are packed into a wide matrix of work with high arithmetic intensity, and the GPU's tensor cores stay busy multiplying large matrices. It behaves like a short training step: the more tokens in the batch, the better the hardware utilization, and the latency is roughly proportional to the number of prompt tokens divided by available throughput.

Decode is memory-bound. Each output token triggers a forward pass over the whole model with a batch dimension of one, which means reading billions of weight parameters and the entire KV cache from high-bandwidth memory just to produce a single token. The arithmetic units sit mostly idle; the limiting resource is bytes per second. Continuous batching helps by grouping many users' decode steps together, but it does not change the fundamental profile: prefill wants FLOPs, decode wants bandwidth.

That mismatch is why a mixed queue is awkward. When a long prompt arrives, the GPU spends its compute capacity on prefill while decode-bound requests wait for their next token. When the queue is decode-heavy, the same GPU has idle tensor cores that nothing can use. Either way, half the machine is underused.

Part Two: The numbers behind the split

Take an order-of-magnitude estimate for a 70B model with 80 layers, grouped-query attention over 8 KV heads, a head dimension of 128, and fp16 weights. KV state is roughly 0.3 MB per token. A four-thousand-token prompt therefore creates about 1.2 GB of cache that a disaggregated design must ship from the prefill pool to the decode pool before generation can begin.

The transport time depends entirely on the fabric. Across NVLink at several hundred gigabytes per second, 1.2 GB moves in a few milliseconds and is nearly invisible. Across a 100 Gb per second RDMA link, the same transfer takes around a tenth of a second; on a 25 Gb connection it is closer to half a second. If a cluster starts a thousand such prompts per second, the aggregate KV traffic is on the order of a terabyte per second, more than many production networks can carry. The interconnect, not the GPU, becomes the design constraint.

Now price the other side. A cluster of a thousand accelerators at a few dollars per GPU-hour costs on the order of twenty million dollars a year. If phase separation lifts utilization by even a fifth, that is several million dollars of recovered capacity annually. The global market for large-model inference infrastructure is measured in the tens of billions of dollars per year, which is why a few percentage points of utilization attract serious engineering effort.

A 70B model produces roughly 0.3 MB of KV state per token, so a four-thousand-token prompt is about 1.2 GB of data that a disaggregated design must move before decode can start.

That number explains the shape of real deployments: the split works best when the cache is small relative to the compute saved, when prompts are long enough to amortize the transfer, and when the two pools sit on a fabric built for the traffic.

Part Three: Latency, scheduling, and failure

Monolithic serving fails on tail latency rather than averages. A burst of long prompts stalls token generation for everyone, so time per output token spikes even though the mean looks fine. A busy decode queue, conversely, delays time to first token for new arrivals. The two metrics are coupled through a single scheduler, and tuning for one tends to hurt the other.

Disaggregation decouples them. The prefill pool can be sized for bursty arrivals and the decode pool for steady-state generation, each with its own batching policy and autoscaling rule. A decode worker never waits behind a prompt. But the design introduces new failure modes: if a decode worker dies, its cached sessions vanish and must be recomputed elsewhere; if the prefill pool is overloaded, the decode pool starves; and cache-aware routing becomes a real scheduling problem rather than a local decision. Systems built around this idea, such as Splitwise, DistServe, and Mooncake, differ mostly in how they manage that cache pool and where they place the transport boundary.

There is also a subtle cost at the start of every request: the time to first token now includes prefill plus transfer plus the first decode step. A design that saves twenty milliseconds of queueing but adds a hundred milliseconds of network time is a regression, and only measurement on the actual fabric will tell you which case you are in.

Part Four: An everyday analogy

Think of a restaurant with one cook who both prepares ingredients and carries plates to tables. When a big order arrives, the cook stops delivering everyone's food to chop vegetables; when the dining room is full, the cooking station sits half idle while the cook walks back and forth. That is monolithic serving: one worker doing two kinds of work, with each kind wasting the other's capacity.

A disaggregated kitchen has a prep station and a pass. The prep station chops and sears in bulk, then sends finished dishes down a conveyor belt to the pass, where a runner plates and delivers them one at a time. Each station can be staffed to its own workload. But the conveyor matters: a fast belt makes the whole room flow, while a slow belt means dishes pile up warm and the pass waits. A good restaurant also keeps a few dishes at the pass already prepared, just as a serving system keeps hot KV cache where the next token will need it.

What is actually transferable

Measure time to first token and time per output token separately, and watch their tails, not their means. If the two move together under load, you have a coupling problem; if they move independently already, the split may buy little.

Before splitting anything, calculate the cache traffic from tokens per second and sequence length, then compare it with the measured bandwidth between your pools. A design that looks elegant on a slide can fail on a 25 Gb link.

The split also has a scale threshold. Small models, short prompts, and low request rates rarely generate enough KV traffic or enough contention to justify a second scheduler. Large models with long prompts and high concurrency are where it pays.

Disaggregated serving trades a simple scheduler for a bandwidth budget, and the trade is worthwhile only when the utilization gained on each pool exceeds the time and money spent moving the cache between them.

Treat the KV cache as a first-class data product with a location, an owner, and a transport cost. Once you do, the choice between one pool and two becomes an engineering calculation instead of a matter of taste.

SOL: HCqPmPJM3NVtS6YrmVaTZYnuP8XZ2PFgQZKT94VK1LkS
Creating this takes real effort — thank you for the support.

Top comments (0)