research29 min studyLesson 741 in Engineering

Stage asymmetry: separate work before separating hardware

Analyze prompt processing and iterative generation with explicit client-visible latency boundaries and workload-dependent resource assumptions.

On this page

What you’ll understand

  • Distinguish prefill and decode work under a specified request mix.
  • Define client-visible first-token and subsequent-token measurements.
  • Explain both the interference benefit and new transfer costs of separation.

A long prompt and one additional generated token perform different work even when they use the same model weights. Disaggregating their execution can let each stage use a different batching and placement policy, but it also creates a cache-transfer and handoff dependency. DistServe and Splitwise study these tradeoffs under their particular workloads and systems. They do not establish a universal throughput gain for every serving stack. We use dense attention examples and hypothetical timings, with model, kernel, cache, and measurement assumptions stated explicitly.

Different shapes create different resource pressures

Prefill processes many prompt positions and constructs the key/value state needed for subsequent generation. Matrix operations can exploit substantial prompt-level parallelism, and long prompts may make arithmetic throughput important. Decode repeatedly extends active sequences, reading model and cache state while producing relatively few new positions per request. At some batch sizes its bandwidth and cache-capacity demands dominate. These are tendencies, not fixed labels: short prompts, large decode batches, attention variants, quantization, parallelism, and kernel implementation can move either stage to another bottleneck.

Colocation allows shared weight residency and avoids a remote cache handoff, but prompt work can delay the next decode iteration and distort streaming latency. Chunked prefill and other scheduling policies can reduce that interference without physically separating stages, with their own overhead and tradeoffs. Disaggregation introduces separate copies or placements of model state, a transfer path, destination capacity requirements, and another failure boundary. Compare complete useful service under a controlled resource budget instead of inferring an architectural winner from one isolated stage benchmark.

Tfirst=Qp+Cp+Xp→d+Qd+Cd,1T_{\rm first}=Q_p+C_p+X_{p\to d}+Q_d+C_{d,1}
This illustrative serial pipeline gates first visible output until decoder activation. Q,C,X are nonnegative durations in seconds for queues, compute, and handoff/transfer. If prefill emits the first token before handoff or operations overlap, the measurement and dependency equation must change.↔ Scroll wide equations horizontally.

Define latency at the client-visible boundary

Time to first token includes the chosen request-admission and output-delivery boundaries, not merely a prefill kernel duration. Some implementations sample and expose a first token from prefill; others gate output on successful decode handoff. Those designs place transfer cost differently relative to the first visible token and first streaming gap. State the convention and record both stage events and client timestamps. A faster prefill kernel can coexist with slower first response when destination admission or cache movement dominates.

Average time per output token and tail inter-token latency are also different metrics. A request can have an acceptable average while one long handoff or scheduling pause produces a visible stall. Measure output length, stop conditions, and the actual sequence of token arrival times. Streaming buffers and detokenization can coalesce arrivals, so server iteration timestamps alone do not describe the client experience. Count successful requests meeting the stated first-token and streaming objectives rather than promote total generated tokens per second to a complete service metric.

ITL⁡j=tj−tj−1,TPOT⁡=tm−t1m−1(m≥2)\operatorname{ITL}_j=t_j-t_{j-1},\qquad\operatorname{TPOT}=\frac{t_m-t_1}{m-1}\quad(m\ge2)
tj are client-observed arrival timestamps in seconds for one request’s m output tokens. ITL is a per-gap duration and TPOT its request-level mean here. Buffering, tokenization, and the definition of an arrival event must be consistent across systems.↔ Scroll wide equations horizontally.

Profile the asymmetry before sizing pools

Build a workload matrix across prompt length, generated length, cache reuse, concurrency, and model configuration. Profile each stage independently and then together, including transfer and admission. The same request can demand high prefill work but little decode residence, or the opposite. Scaling the prefill pool according to request rate alone can overproduce cache state for a memory-bound decode pool. Preserve workload classes and deadlines when evaluating a new split, and report rejected work and cache recomputation rather than hide them from latency statistics.

The roofline lab illustrates a synthetic bottleneck change. Reset, explicitly set intensity eight and bandwidth 80, predict the ceiling, then Play or Step. Compare a fresh Reset with intensity sixteen and bandwidth 80 explicitly set. The fixed 1,000-GFLOP/s compute roof gives ceilings 640 and 1,000. These are hypothetical intensity choices, not measured prefill or decode phases. The instrument has no batching, cache handoff, queues, or model weights and cannot establish that either real stage always belongs to one resource regime.

A stage improvement must survive the new dependency path

In a hypothetical serial design that exposes the first token only after decoder activation, use prefill queue 20 ms, prefill compute 40 ms, transfer/handoff ten ms, decode queue fifteen ms, and first-token compute five ms. A matched colocated path has queue fifty ms, prefill 45 ms, and first-token compute five ms.

  1. The disaggregated first-token path totals 20+40+10+15+5=90 ms under the stated serial dependencies. The transfer and destination queue are part of the visible boundary in this design.

  2. The colocated comparison totals 50+45+5=100 ms. The modeled improvement is ten ms, or ten percent of this comparison’s first-token time; it is not a claim about all streaming gaps or cluster throughput.

  3. If destination queueing rises by twenty ms, the disaggregated path becomes 110 ms and loses this comparison. Preserve admission, resource, and workload conditions before attributing a measured gain to stage separation.

The result

The initial model favors separation by ten ms, but a destination backlog can reverse it. Stage-local timings are insufficient to decide the end-to-end result.

Explore the model

Interactive lab

Interactive lab · roofline

A synthetic intensity change is not a stage classifier

Use independent Reset → explicitly set BOTH I and B → predict → Play/Step runs for (8,80) and (16,80). The fixed synthetic compute roof gives 640 and 1000 GFLOP/s. No prefill, decode, KV movement, or service latency is simulated.

A synthetic intensity change is not a stage classifierSynthetic roofline ceiling min(1000, B·I), in GFLOP/s, with B in decimal GB/s and I in FLOP/byte. Playback traces the roof without changing the selected kernel. This upper-bound model is not a measured throughput prediction, hardware comparison or price model. Current readings: Attainable ceiling: 640 GFLOP/s; Ridge intensity: 12.5 FLOP/byte; Ceiling regime: Memory-bound ceiling. All parameters are adjustable with the labeled controls below.Hypothetical roofline upper bound: 640 GFLOP per second at operational intensity 8 FLOP per byte and bandwidth 80 gigabytes per second.0.1110641101001000Operational intensity · FLOP/byte · log scaleCeiling · GFLOP/s · log scalePeak: 1000
Attainable ceiling / kernelBandwidth roof / traceCompute ceiling
Attainable ceiling
640 GFLOP/s
Ridge intensity
12.5 FLOP/byte
Ceiling regime
Memory-bound ceiling
t = 0 s

Synthetic roofline ceiling min(1000, B·I), in GFLOP/s, with B in decimal GB/s and I in FLOP/byte. Playback traces the roof without changing the selected kernel. This upper-bound model is not a measured throughput prediction, hardware comparison or price model. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forMeasure each real stage and the dependency between them instead of assuming an architectural bottleneck from its name.

Check your understanding

Why can a faster prefill kernel fail to reduce client-visible first-token latency after disaggregation?

Try it yourself

Use the same gated serial first-token convention with durations 10,30,8,12,4 ms for prefill queue, prefill compute, handoff, decode queue, and initial decode compute. Calculate total latency. If the first token were exposed before handoff, why would the same sum no longer define TTFT?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Add only the durations on the stated causal path, then identify where the first visible event occurs.

Compare with the solution

The gated total is 64 ms. If prefill exposes the first token before handoff, transfer and later decode queueing may instead affect the next visible gap rather than that first-token timestamp. Record the actual sampling, transmission, and client-arrival events before rewriting the dependency model. Neither convention makes transfer free; it changes which observed service metric includes it. Compare both first response and subsequent gaps under the same workload and output-delivery rules.

Take it with you

  • Treat stage bottlenecks as workload-dependent measurements.
  • Define first-token and streaming metrics at explicit visible boundaries.
  • Include transfer, destination admission, and resource duplication in the comparison.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.