Pidoku

Sarathi-Serve (2024)

Module 30 Lesson 30.t 35 min Difficulty 3/5

Prerequisites 12.c, 12.j, 30.g


Before you start: words you need#

WordPlain meaning
Chunked prefillSplitting a long prompt’s prefill into pieces (chunks) processed over several iterations instead of one (12.k).
PiggybackingPutting decode tokens of running requests into the same batch as a prefill chunk, so decodes ride along on a compute-heavy step.
Token budgetThe most tokens (prefill chunk tokens plus decode tokens) allowed in one iteration. In vLLM: max_num_batched_tokens (17.b).
Generation stallA pause of hundreds of milliseconds to seconds in a user’s token stream, because the server is busy with someone else’s long prefill.
TBTTime between tokens: the gap a user sees between consecutive streamed tokens. Its tail (P99) is what users notice.
Prefill-prioritising / decode-prioritisingSchedulers that admit new prompts eagerly (better throughput, worse TBT) or finish running decodes first (better TBT, worse throughput).
Pipeline bubbleIdle time in pipeline parallelism when one stage waits for another (14.d).
Serving capacityThe highest request rate a system sustains while meeting its latency SLOs.

1. The paper#

  • Title: “Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Serve”
  • Authors: Amey Agrawal, Nitin Kedia, Ashish Panwar, Jayashree Mohan, Nipun Kwatra, Bhargav S. Gulavani, Alexey Tumanov, Ramachandran Ramjee (Microsoft Research India, Georgia Tech)
  • Venue: OSDI 2024 (arXiv March 2024).
  • Link: arXiv:2403.02310 · code: microsoft/sarathi-serve

It builds on the same group’s earlier SARATHI (2023, arXiv:2308.16369), which introduced chunked prefills with piggybacked decodes for throughput. Sarathi-Serve turns that into a latency-aware serving scheduler.


2. The problem#

Continuous batching (30.g) forces a choice every iteration:

  • Prefill-prioritising (vLLM and Orca at the time): when a new request arrives, run its whole prefill now. Throughput is high, because decode batches fill up fast. But every running user’s next token waits behind that prefill: a generation stall. The paper shows stalls of several seconds when Yi-34B on two A100s serves long arXiv-summarisation prompts.
  • Decode-prioritising (FasterTransformer and similar request-level systems): finish decodes before admitting new prefills. TBT is smooth, but batches shrink and throughput drops.

With pipeline parallelism it is worse: iterations of very different lengths (a long prefill next to short decodes) create pipeline bubbles.


3. The idea#

Two ideas together:

  1. Chunked prefills. Split each prompt’s prefill into chunks of near-equal size, processed over several iterations.
  2. Stall-free batching. Fix a token budget per iteration, chosen from the TBT target. Each iteration first includes all running decodes (one token each), then fills the rest of the budget with prefill chunks from new requests. Ongoing decodes are never paused for a prefill.

Every iteration now costs about the same and stays within the TBT target, while prefill work still fills the GPU’s spare compute. Decode steps alone are memory-bound (30.a), so adding a prefill chunk to them costs little extra time: the decodes ride along nearly for free.

flowchart LR
  Q["Waiting prompts"] --> B{"Token budget for this iteration"}
  R["Running decodes: 1 token each"] --> B
  B --> I["Iteration = all decodes + prefill chunk(s) up to budget"]
  I --> R
  I --> Q
  class Q,R queue
  class B neutral
  class I compute

4. How it works#

  • Choosing the budget. Profile the model on the hardware: how long does an iteration with N tokens take? Pick the largest N whose iteration time meets the TBT SLO. A strict SLO means a small budget (more chunks, more overhead); a relaxed SLO allows a big budget (closer to full throughput).
  • The cost of chunking. Each chunk must re-read the KV cache of earlier chunks in attention, and small chunks use the GPU less efficiently. The paper measures this overhead and finds it small for sensible chunk sizes, and recommends sizes that suit the GEMM tile shapes (avoiding wasted partial tiles).
  • Pipeline parallelism. Uniform iteration times keep micro-batches balanced, so bubbles shrink. That is where the biggest gain came from.
  • Implementation. Built on vLLM’s code base at the time, with FlashAttention and FlashInfer kernels that support mixed prefill/decode batches.

5. Results#

Baselines vLLM and Orca-style scheduling; capacity measured under P99 TBT SLOs on openchat-sharegpt4 and arxiv-summarisation traces:

Model and hardwareGain in serving capacity vs vLLM
Mistral-7B, one A1002.6×
Yi-34B, two A100s (TP-2)up to 3.7×
Falcon-180B, 8 A100s, TP-4 × PP-2 over commodity ethernetup to 5.6× end to end

The size of the gain depends on the SLO: under a strict TBT target the prefill-prioritising baseline must shrink its load a lot to avoid stalls, so Sarathi-Serve wins most there; with relaxed SLOs the gap narrows.


6. What held up and what did not#

Held up

  • Chunked prefill is on by default in vLLM (V1 engine), SGLang and TensorRT-LLM. The token budget is vLLM’s max_num_batched_tokens, which v0.32.0 sets from GPU memory (8,192 on H100/H200, 16,384 on B200/B300; 17.b).
  • Decodes first, then fill with prefill. This is exactly how vLLM’s scheduler builds a step (17.a).
  • Uniform iterations for pipeline parallelism: still the main reason PP works for serving.

Did not, or changed

  • Chunking does not remove all interference. Long prompts still raise TBT a little on every iteration they share. At large scale and strict SLOs, disaggregation (30.q) separates the phases entirely; chunked prefill and disaggregation are now used together (chunked prefill inside prefill workers).
  • The budget is often set by hand. Engines use static defaults; SLO-driven automatic budgets are less common than the paper proposed.
  • Long-context prefill (100k+ tokens) needs more than chunking: context parallelism and disaggregated prefill (14.f, 14.j).

7. Where it lives in 2026#

  • Taught in depth: chunked prefill in 12.k, vLLM’s token budget in 17.b, one scheduling step in 17.a, SLOs and TBT in 23.a, pipeline parallelism in 14.d.
  • The Microsoft repository is a research code base; the technique lives on inside the major engines.

Checked on 13 November 2026.


8. Questions#

  1. What is a generation stall, and which scheduling policy causes it?
  2. Explain how chunked prefill plus a token budget gives “stall-free” batches.
  3. Why does piggybacking decodes on a prefill chunk cost so little?
  4. How would you pick the token budget for a P99 TBT SLO of 50 ms?
  5. What does chunking cost? When would very small chunks hurt?
  6. Why did pipeline-parallel Falcon-180B gain the most?
  7. When would you add disaggregation on top of chunked prefill?

9. Further reading#

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in