A serving engine is a loop: every iteration the scheduler picks which tokens go into the next forward pass, the GPU runs it, and every request in the batch advances. The roofline gives the cost of one iteration; the KV cache bounds how many requests can be in flight. This lesson is about the choice in between, and why it is a three-way trade between TTFT, TBT and throughput (metric definitions).
The cost of one iteration
From the roofline, an iteration that prefills prompt tokens and decodes one token for each of running sequences (total context ) takes roughly
For an 8B model in bf16 on an H100-class GPU ( = 60% of peak, our assumption) the weight read alone is ~4.8 ms, so a decode-only step of a few dozen sequences costs ~6–8 ms. A 3,000-token prefill is compute-bound: ~82 ms. One prefill costs as much as ten or more decode steps. Everything below follows from where those 82 ms are placed.
From static to continuous batching
Static batching (request-level): collect requests, prefill them together, decode until the longest finishes. Short answers sit in the batch as padding, and new requests wait for the whole batch — TTFT includes waiting for strangers.
Continuous batching (Orca’s iteration-level scheduling): re-form the batch every iteration; finished sequences leave, new ones join. The obstacle was that requests in a batch have different lengths; Orca’s selective batching batches the token-wise operations (the GEMMs, which do not care which request a token came from) across all tokens and runs attention per request. On GPT-3 175B it reported 36.9× the throughput of FasterTransformer at the same latency.
Prefill–decode interference
Continuous batching opens a new question: when new requests arrive, do we prefill them now or keep decoding? Prefill-first (early vLLM) runs a prefill-only iteration whenever requests are waiting: TTFT is good, but every running sequence sees an 82 ms gap instead of 7 ms. Sarathi-Serve calls these generation stalls and shows ones lasting seconds under load. Decode-first keeps TBT smooth but lets the queue — and TTFT — grow. Averages hide the problem: one 0.5 s stall in a 200-token answer moves TPOT by only 2.5 ms, which is why Etalon looks at TBT tails and deadline-based fluidity.
Chunked prefill: stall-free batching
Sarathi-Serve’s fix: split prompts into chunks and build every iteration as all running decodes + as many prefill tokens as fit in a token budget . Decodes never wait; prefills progress a chunk per step. The budget comes straight from the cost model: choose the largest with TBT target. In our model, with 32 decodes running, a 20 ms target allows a budget of ~670 tokens and 50 ms ~1,800 (computed below). The price is a little TTFT (a prompt is spread over several steps, and each chunk re-reads the KV of the earlier chunks) and slightly less efficient GEMMs for small chunks. The paper reports 2.6× higher serving capacity for Mistral-7B on one A100 and up to 5.6× for Falcon-180B, versus vLLM.
Disaggregating prefill and decode
The other fix is to stop sharing GPUs. DistServe and Splitwise run prefill on one pool and decode on another and ship each request’s KV between them. Interference vanishes, and each phase can choose its own parallelism and even its own hardware (Splitwise: compute-heavy GPUs for prefill, memory-heavy ones for decode). Costs:
- KV transfer. bytes per request: a 3,000-token prompt of the 8B model is 393 MB, ~16 ms at an effective 25 GB/s (our assumption). It must be pipelined layer by layer to stay off the critical path.
- The P ratio. Prefill and decode pools are sized separately, so the ratio must match the workload. Prefill load is (rate × prompt tokens × ); decode load is (rate × output tokens). Get it wrong and one pool saturates while the other idles — the simulator below shows a 1P + 1D split collapsing on a prompt-heavy trace that two colocated chunked replicas handle easily.
DistServe reports 7.4× more requests, or a 12.6× tighter SLO, than colocated systems while keeping over 90% of requests within both TTFT and TPOT limits. Splitwise reports 1.4× throughput at 20% lower cost, or 2.35× throughput at the same cost and power. At the largest scale the two phases even differ in parallelism: DeepSeek-V3’s prefill unit is 32 GPUs with 32-way expert parallelism, its decode unit 320 GPUs with EP320 (why decode wants such a large EP group). Mooncake combines disaggregation with a shared KV store (previous lesson).
서빙 엔진은 하나의 loop다. 매 iteration 스케줄러가 다음 forward에 들어갈 토큰을 고르고, GPU가 그것을 돌리고, 배치의 모든 요청이 한 칸 전진한다. roofline은 iteration 하나의 비용을, KV cache는 동시에 처리할 수 있는 요청 수의 상한을 준다. 이 레슨은 그 사이의 선택에 대한 것이고, 그것이 왜 TTFT, TBT, 처리량 사이의 삼자 거래인지에 대한 것이다(지표 정의).
iteration 하나의 비용
roofline에서, 프롬프트 토큰 개를 prefill하고 실행 중인 시퀀스 개(문맥 합 )에 대해 토큰 하나씩 decode하는 iteration은 대략
가 걸린다. H100급 GPU에서 bf16 8B 모델( = peak의 60%, 우리의 가정)이면 가중치 읽기만 ~4.8 ms이므로, 시퀀스 수십 개의 decode-only step은 ~6–8 ms다. 3,000토큰 prefill은 compute-bound로 ~82 ms다. prefill 한 번이 decode step 열 번 이상의 값이다. 아래 내용은 모두 그 82 ms를 어디에 두느냐에서 나온다.
정적 배칭에서 continuous batching으로
정적 배칭(요청 단위): 요청 개를 모아 함께 prefill하고 가장 긴 것이 끝날 때까지 decode한다. 짧은 답은 padding으로 배치에 남아 있고, 새 요청은 배치 전체를 기다린다. TTFT에 남의 요청을 기다리는 시간이 들어간다.
Continuous batching(Orca의 iteration 단위 스케줄링): 매 iteration 배치를 다시 짠다. 끝난 시퀀스는 나가고 새 시퀀스가 들어온다. 걸림돌은 배치 안 요청들의 길이가 다르다는 것이었다. Orca의 selective batching은 토큰 단위 연산(어느 요청의 토큰인지 상관없는 GEMM)은 모든 토큰에 걸쳐 배치하고, attention은 요청별로 돌린다. GPT-3 175B에서 같은 지연으로 FasterTransformer의 36.9배 처리량을 보고했다.
Prefill–decode 간섭
continuous batching은 새 질문을 연다. 새 요청이 오면 지금 prefill할까, decode를 계속할까? Prefill 우선(초기 vLLM)은 대기 요청이 있으면 prefill만 하는 iteration을 돌린다. TTFT는 좋지만, 실행 중인 모든 시퀀스가 7 ms 대신 82 ms 간격을 본다. Sarathi-Serve는 이것을 **생성 멈춤(generation stall)**이라 부르고, 부하가 걸리면 몇 초짜리 멈춤이 생김을 보인다. Decode 우선은 TBT를 매끄럽게 유지하지만 대기열과 TTFT가 자란다. 평균은 문제를 숨긴다. 200토큰 답변 중 0.5초 멈춤 한 번은 TPOT를 2.5 ms만 움직인다. Etalon이 TBT 꼬리와 마감 기반 fluidity를 보는 이유다.
Chunked prefill: 멈춤 없는 배칭
Sarathi-Serve의 해법: 프롬프트를 chunk로 나누고, 모든 iteration을 실행 중인 decode 전부 + token budget 에 들어가는 만큼의 prefill 토큰으로 구성한다. decode는 결코 기다리지 않고, prefill은 step마다 chunk 하나씩 나아간다. budget은 비용 모델에서 바로 나온다. TBT 목표를 만족하는 가장 큰 를 고른다. 우리 모델에서 decode 32개가 돌고 있으면 20 ms 목표는 ~670토큰, 50 ms는 ~1,800토큰의 budget을 허용한다(아래에서 계산). 대가는 약간의 TTFT(프롬프트가 여러 step에 퍼지고, chunk마다 앞 chunk들의 KV를 다시 읽는다)와 작은 chunk에서 조금 덜 효율적인 GEMM이다. 논문은 vLLM 대비 A100 한 장의 Mistral-7B에서 serving capacity 2.6배, Falcon-180B에서 최대 5.6배를 보고한다.
Prefill과 decode 분리
다른 해법은 GPU를 공유하지 않는 것이다. DistServe와 Splitwise는 prefill을 한 pool에서, decode를 다른 pool에서 돌리고 요청마다 KV를 그 사이로 옮긴다. 간섭이 사라지고, 각 단계가 자기 병렬화와 심지어 자기 하드웨어를 고를 수 있다(Splitwise: prefill에는 계산이 강한 GPU, decode에는 메모리가 강한 GPU). 비용은 다음과 같다.
- KV 전송. 요청당 바이트. 8B 모델의 3,000토큰 프롬프트는 393 MB이고, 유효 25 GB/s(우리의 가정)로 ~16 ms다. critical path에서 빼려면 층 단위로 pipeline해야 한다.
- P 비율. prefill pool과 decode pool의 크기를 따로 정하므로 비율이 작업 부하와 맞아야 한다. prefill 부하는 (도착률 × 프롬프트 토큰 × ), decode 부하는 (도착률 × 출력 토큰)이다. 틀리면 한 pool은 포화하고 다른 pool은 논다. 아래 시뮬레이터는 프롬프트가 무거운 trace에서 1P + 1D 분할이 무너지는 것을, 같은 trace를 chunked 동거 replica 두 개는 쉽게 처리하는 것을 보여 준다.
DistServe는 동거형 시스템 대비 7.4배 많은 요청, 또는 12.6배 빡빡한 SLO를, 요청의 90% 이상이 TTFT·TPOT 한계를 모두 지키는 상태로 처리한다고 보고한다. Splitwise는 20% 낮은 비용으로 1.4배 처리량, 또는 같은 비용·전력으로 2.35배 처리량을 보고한다. 가장 큰 규모에서는 두 단계의 병렬화마저 다르다. DeepSeek-V3의 prefill 단위는 32-way expert parallel의 GPU 32장, decode 단위는 EP320의 GPU 320장이다(decode가 왜 그렇게 큰 EP 그룹을 원하는지). Mooncake는 분리와 공유 KV 저장소(이전 레슨)를 결합한다.
The simulator behind both figures uses the step-cost model above (8B, bf16, H100-class, 1.5 ms per-step overhead, 25 GB/s KV link — all our assumptions) and gives every policy two GPUs: two colocated replicas with requests alternating, or one prefill and one decode GPU. Things to try in the timeline: under continuous (prefill-first) the blue decode bars are broken by red stalls each time someone else’s prompt is prefilled; switch to chunked and they disappear while TTFT barely moves; set the budget to 4,096 and the stalls partially return (a big chunk is a stall). Under P/D disaggregated the decode bars are clean, the violet KV transfer is visible, and at 20+ req/s the prefill GPU’s queue grows without bound.
두 그림 뒤의 시뮬레이터는 위의 step 비용 모델(8B, bf16, H100급, step당 1.5 ms 오버헤드, 25 GB/s KV 링크, 모두 우리의 가정)을 쓰고 모든 정책에 GPU 2장을 준다. 요청을 번갈아 받는 동거 replica 두 개, 또는 prefill GPU 하나와 decode GPU 하나다. timeline에서 해 볼 것: **continuous(prefill 우선)**에서는 남의 프롬프트를 prefill할 때마다 파란 decode 막대가 빨간 멈춤으로 끊긴다. chunked로 바꾸면 TTFT는 거의 그대로인 채 멈춤이 사라진다. budget을 4,096으로 올리면 멈춤이 일부 돌아온다(큰 chunk는 그 자체가 멈춤이다). P/D 분리에서는 decode 막대가 깨끗하고 보라색 KV 전송이 보이며, 20 req/s 이상에서는 prefill GPU의 대기열이 끝없이 자란다.
Read the goodput numbers off the left plot. With the default SLOs (TTFT ≤ 1 s, TPOT ≤ 50 ms) and 3,000-token prompts, static batching is hopeless (its TTFT includes waiting for a whole batch), and the 1P + 1D split comes below both colocated continuous policies: its single prefill GPU saturates near 12 req/s ( GFLOP ≈ 580 TFLOP/s, the assumed effective peak) while the decode GPU is mostly idle. Shorten the prompts to ~500 tokens and the picture flips toward decode-bound load. Tighten TPOT to ~15 ms and prefill-first continuous batching drops out first. This is the practical content of the disaggregation papers: disaggregation wins when the P
ratio is tuned to the workload and the SLO punishes interference — not unconditionally.SLO-aware scheduling in practice
Real schedulers add policies on top of the batch composition:
- Admission and preemption. When the KV pool runs out, a running sequence must be evicted: either its blocks are dropped and its prefix recomputed later (cheap with prefix caching), or swapped to host memory (offload).
- Priorities and deadlines. Order the queue by SLO slack instead of arrival (e.g. interactive vs batch traffic); Etalon’s per-token deadlines are a natural objective.
- Prefix-aware ordering and routing. Schedule requests that share a prefix together and route sessions to the replica that holds their cache.
Implementing it
The Python block derives the token budget from a TBT target and reruns a compact version of the simulator for three policies at two load levels (same model, same two GPUs, SLO TTFT ≤ 1 s and TPOT ≤ 25 ms).
import numpy as np
# step-time model (8B dense bf16, H100-class: 60% of 989 TFLOP/s, 3.35 TB/s, 128 KiB KV/token, 1.5 ms overhead)
N, WB, BW, PEAK, KAPPA, C0, XFER = 8e9, 16e9, 3.35e12, 989e12 * 0.6, 131072, 1.5e-3, 25e9
def step(pref, dec, ctx):
return C0 + max(2 * N * (pref + dec) / PEAK, (WB + ctx * KAPPA) / BW)
# 1) Sarathi-style token budget: the largest chunk whose step still meets a TBT target with 32 decodes running
for slo_ms in [20, 30, 50]:
budget = max(b for b in range(32, 16384, 32) if step(b - 32, 32, 32 * 3000) * 1e3 <= slo_ms)
print(f"TBT target {slo_ms} ms -> token budget ~{budget} (a whole 3000-token prompt takes {step(3000, 0, 0) * 1e3:.0f} ms)")
def trace(rate, n=160, P=3000, O=200, seed=1):
r = np.random.default_rng(seed)
arr = np.cumsum(r.exponential(1 / rate, n))
Ps = np.maximum(16, (P * np.exp(0.5 * r.normal(size=n) - 0.125)).astype(int))
Os = np.maximum(2, (O * np.exp(0.7 * r.normal(size=n) - 0.245)).astype(int))
return [dict(arr=float(a), P=int(p), O=int(o), pre=0, gen=0, first=None, end=None, last=None, maxgap=0.0, ready=a) for a, p, o in zip(arr, Ps, Os)]
def emit(q, t):
if q["last"] is not None:
q["maxgap"] = max(q["maxgap"], t - q["last"])
q["last"] = t; q["gen"] += 1
if q["first"] is None: q["first"] = t
if q["gen"] >= q["O"]: q["end"] = t
def engine(reqs, mode, budget=512):
todo = sorted(reqs, key=lambda q: q["ready"]); i = 0; t = 0.0; queue, run = [], []
while i < len(todo) or queue or run:
while i < len(todo) and todo[i]["ready"] <= t: queue.append(todo[i]); i += 1
if not queue and not run: t = todo[i]["ready"]; continue
if mode in ("cont", "prefill") and queue: # prefill-first: whole prompts, no decodes
batch, tok = [], 0
while queue and (tok == 0 or tok + queue[0]["P"] <= 8192): tok += queue[0]["P"]; batch.append(queue.pop(0))
t += step(tok, 0, 0)
for q in batch:
emit(q, t); q["pre"] = q["P"]
if mode == "prefill": q["ready"] = t + q["P"] * KAPPA / XFER # KV shipped to the decode GPU
else: run.append(q)
continue
if mode == "prefill": continue
if mode == "decode": run += queue; queue = []
pref, done, room = 0, [], max(0, budget - len(run)) if mode == "chunk" else 0
for q in queue if mode == "chunk" else []: # stall-free: fill leftover budget with chunks
if room <= 0: break
k = min(room, q["P"] - q["pre"]); q["pre"] += k; pref += k; room -= k
if q["pre"] >= q["P"]: done.append(q)
if not run and not pref: t = todo[i]["ready"]; continue
t += step(pref, len(run), sum(q["P"] + q["gen"] for q in run))
for q in run: emit(q, t)
for q in done: queue.remove(q); emit(q, t)
run = [q for q in run + done if q["end"] is None]
def simulate(policy, rate):
reqs = trace(rate)
if policy == "disagg":
engine(reqs, "prefill"); engine(reqs, "decode")
else:
for g in (0, 1): engine(reqs[g::2], policy) # two colocated replicas
return reqs
print("\npolicy rate TTFT p90 TPOT p90 max-TBT p99 SLO(1s, 25ms)")
for rate in [8, 16]:
for pol in ["cont", "chunk", "disagg"]:
R = simulate(pol, rate)
ttft = np.array([q["first"] - q["arr"] for q in R]); tpot = np.array([(q["end"] - q["first"]) / (q["O"] - 1) for q in R])
mg = np.array([q["maxgap"] for q in R]); ok = np.mean((ttft <= 1.0) & (tpot <= 0.025))
print(f"{pol:<9} {rate:5d} {np.quantile(ttft, .9) * 1e3:8.0f}ms {np.quantile(tpot, .9) * 1e3:7.1f}ms {np.quantile(mg, .99) * 1e3:9.0f}ms {ok:10.0%}")At 16 req/s prefill-first continuous batching misses the TPOT SLO for 13% of requests (its p99 worst gap is close to a second), chunked prefill meets it for all with a 15 ms worst gap, and the 1P + 1D split saturates its prefill GPU (TTFT p90 ≈ 1.9 s). Note that the disaggregated worst gap is ~60 ms: the first inter-token gap includes the KV transfer.
With chunked prefill, what sets the token budget per iteration?
Every iteration emits one token for each running decode, so the iteration time is their TBT. Choose so that stays under the TBT target; a larger budget improves prefill efficiency and TTFT but lengthens every decode’s inter-token gap.
A 1-prefill + 1-decode GPU deployment serves a workload with 3,000-token prompts and 200-token outputs and misses its TTFT SLO, while the decode GPU sits mostly idle. What is the fix?
Prefill load per request is FLOPs versus 200 decode tokens — prefill-heavy. The prefill pool saturates and TTFT grows without bound. Disaggregated serving must size the two pools to the load; with few GPUs, colocating with chunked prefill avoids the provisioning problem altogether.
Summary
- An iteration costs ; one long prefill costs as much as many decode steps.
- Continuous batching (Orca) re-forms the batch every iteration; selective batching makes mixed lengths possible.
- Prefill-first scheduling causes generation stalls; decode-first hurts TTFT; averages (TPOT) hide stalls, TBT tails do not.
- Chunked prefill (Sarathi-Serve) caps each iteration with a token budget derived from the TBT target.
- Disaggregation (DistServe, Splitwise, Mooncake) removes interference at the cost of KV transfer and P provisioning; it wins when the ratio is tuned.
- Measure policies by goodput under explicit SLOs, not by raw throughput.
왼쪽 그림에서 goodput 수치를 읽어 보라. 기본 SLO(TTFT ≤ 1 s, TPOT ≤ 50 ms)와 3,000토큰 프롬프트에서 정적 배칭은 가망이 없고(TTFT에 배치 전체를 기다리는 시간이 들어간다), 1P + 1D 분할은 두 동거형 continuous 정책보다 아래다. 하나뿐인 prefill GPU가 12 req/s 근처에서 포화하고( GFLOP ≈ 580 TFLOP/s, 가정한 유효 peak), decode GPU는 대부분 논다. 프롬프트를 ~500토큰으로 줄이면 그림이 decode 쪽 부하로 뒤집힌다. TPOT를 ~15 ms로 조이면 prefill 우선 continuous batching이 가장 먼저 떨어진다. 분리 논문들의 실질적 내용이 이것이다. 분리는 P
비율을 작업 부하에 맞추고 SLO가 간섭을 벌할 때 이긴다. 무조건은 아니다.실전의 SLO 인지 스케줄링
실제 스케줄러는 배치 구성 위에 정책을 더한다.
- 입장과 선점. KV pool이 바닥나면 실행 중인 시퀀스를 내보내야 한다. 블록을 버리고 나중에 prefix를 재계산하거나(prefix caching이 있으면 싸다), host 메모리로 swap한다(offload).
- 우선순위와 마감. 대기열을 도착 순서가 아니라 SLO 여유로 정렬한다(예: 대화형 대 배치 트래픽). Etalon의 토큰별 마감은 자연스러운 목적함수다.
- prefix 인지 정렬과 라우팅. prefix를 공유하는 요청을 함께 스케줄하고, 세션을 그 cache를 가진 replica로 보낸다.
구현하기
Python 블록은 TBT 목표에서 token budget을 유도하고, 시뮬레이터의 축소판을 세 정책·두 부하 수준에서 다시 돌린다(같은 모델, 같은 GPU 2장, SLO는 TTFT ≤ 1 s, TPOT ≤ 25 ms).
import numpy as np
# step-time model (8B dense bf16, H100-class: 60% of 989 TFLOP/s, 3.35 TB/s, 128 KiB KV/token, 1.5 ms overhead)
N, WB, BW, PEAK, KAPPA, C0, XFER = 8e9, 16e9, 3.35e12, 989e12 * 0.6, 131072, 1.5e-3, 25e9
def step(pref, dec, ctx):
return C0 + max(2 * N * (pref + dec) / PEAK, (WB + ctx * KAPPA) / BW)
# 1) Sarathi-style token budget: the largest chunk whose step still meets a TBT target with 32 decodes running
for slo_ms in [20, 30, 50]:
budget = max(b for b in range(32, 16384, 32) if step(b - 32, 32, 32 * 3000) * 1e3 <= slo_ms)
print(f"TBT target {slo_ms} ms -> token budget ~{budget} (a whole 3000-token prompt takes {step(3000, 0, 0) * 1e3:.0f} ms)")
def trace(rate, n=160, P=3000, O=200, seed=1):
r = np.random.default_rng(seed)
arr = np.cumsum(r.exponential(1 / rate, n))
Ps = np.maximum(16, (P * np.exp(0.5 * r.normal(size=n) - 0.125)).astype(int))
Os = np.maximum(2, (O * np.exp(0.7 * r.normal(size=n) - 0.245)).astype(int))
return [dict(arr=float(a), P=int(p), O=int(o), pre=0, gen=0, first=None, end=None, last=None, maxgap=0.0, ready=a) for a, p, o in zip(arr, Ps, Os)]
def emit(q, t):
if q["last"] is not None:
q["maxgap"] = max(q["maxgap"], t - q["last"])
q["last"] = t; q["gen"] += 1
if q["first"] is None: q["first"] = t
if q["gen"] >= q["O"]: q["end"] = t
def engine(reqs, mode, budget=512):
todo = sorted(reqs, key=lambda q: q["ready"]); i = 0; t = 0.0; queue, run = [], []
while i < len(todo) or queue or run:
while i < len(todo) and todo[i]["ready"] <= t: queue.append(todo[i]); i += 1
if not queue and not run: t = todo[i]["ready"]; continue
if mode in ("cont", "prefill") and queue: # prefill-first: whole prompts, no decodes
batch, tok = [], 0
while queue and (tok == 0 or tok + queue[0]["P"] <= 8192): tok += queue[0]["P"]; batch.append(queue.pop(0))
t += step(tok, 0, 0)
for q in batch:
emit(q, t); q["pre"] = q["P"]
if mode == "prefill": q["ready"] = t + q["P"] * KAPPA / XFER # KV shipped to the decode GPU
else: run.append(q)
continue
if mode == "prefill": continue
if mode == "decode": run += queue; queue = []
pref, done, room = 0, [], max(0, budget - len(run)) if mode == "chunk" else 0
for q in queue if mode == "chunk" else []: # stall-free: fill leftover budget with chunks
if room <= 0: break
k = min(room, q["P"] - q["pre"]); q["pre"] += k; pref += k; room -= k
if q["pre"] >= q["P"]: done.append(q)
if not run and not pref: t = todo[i]["ready"]; continue
t += step(pref, len(run), sum(q["P"] + q["gen"] for q in run))
for q in run: emit(q, t)
for q in done: queue.remove(q); emit(q, t)
run = [q for q in run + done if q["end"] is None]
def simulate(policy, rate):
reqs = trace(rate)
if policy == "disagg":
engine(reqs, "prefill"); engine(reqs, "decode")
else:
for g in (0, 1): engine(reqs[g::2], policy) # two colocated replicas
return reqs
print("\npolicy rate TTFT p90 TPOT p90 max-TBT p99 SLO(1s, 25ms)")
for rate in [8, 16]:
for pol in ["cont", "chunk", "disagg"]:
R = simulate(pol, rate)
ttft = np.array([q["first"] - q["arr"] for q in R]); tpot = np.array([(q["end"] - q["first"]) / (q["O"] - 1) for q in R])
mg = np.array([q["maxgap"] for q in R]); ok = np.mean((ttft <= 1.0) & (tpot <= 0.025))
print(f"{pol:<9} {rate:5d} {np.quantile(ttft, .9) * 1e3:8.0f}ms {np.quantile(tpot, .9) * 1e3:7.1f}ms {np.quantile(mg, .99) * 1e3:9.0f}ms {ok:10.0%}")16 req/s에서 prefill 우선 continuous batching은 요청의 13%가 TPOT SLO를 놓치고(p99 최악 간격이 1초 가까이), chunked prefill은 최악 간격 15 ms로 모두 지키며, 1P + 1D 분할은 prefill GPU가 포화한다(TTFT p90 ≈ 1.9 s). 분리형의 최악 간격이 ~60 ms인 것은 첫 토큰 간격에 KV 전송이 들어가기 때문이다.
chunked prefill에서 iteration당 token budget을 정하는 것은?
iteration마다 실행 중인 decode 각각에 토큰 하나를 내보내므로, iteration 시간이 곧 그들의 TBT다. 가 TBT 목표 아래에 머물도록 를 고른다. budget이 크면 prefill 효율과 TTFT는 좋아지지만 모든 decode의 토큰 간격이 길어진다.
prefill GPU 1장 + decode GPU 1장 배치가 프롬프트 3,000토큰, 출력 200토큰인 작업 부하에서 TTFT SLO를 놓치고, decode GPU는 대부분 논다. 해법은?
요청당 prefill 부하는 FLOPs이고 decode는 200토큰이다. prefill이 무거운 부하다. prefill pool이 포화해 TTFT가 끝없이 자란다. 분리형 서빙은 두 pool의 크기를 부하에 맞춰야 한다. GPU가 적으면 chunked prefill로 동거시키는 편이 이 용량 산정 문제 자체를 피한다.
정리
- iteration 비용은 다. 긴 prefill 한 번은 decode step 여러 번의 값이다.
- continuous batching(Orca)은 매 iteration 배치를 다시 짜고, selective batching이 서로 다른 길이를 가능하게 한다.
- prefill 우선 스케줄링은 생성 멈춤을 만들고, decode 우선은 TTFT를 해친다. 평균(TPOT)은 멈춤을 숨기고 TBT 꼬리는 숨기지 않는다.
- chunked prefill(Sarathi-Serve)은 TBT 목표에서 유도한 token budget으로 iteration의 상한을 정한다.
- 분리(DistServe, Splitwise, Mooncake)는 KV 전송과 P 용량 산정을 대가로 간섭을 없앤다. 비율을 맞췄을 때 이긴다.
- 정책은 단순 처리량이 아니라 명시적 SLO 아래의 goodput으로 잰다.
더 읽을거리Further reading
- Yu et al., Orca: A Distributed Serving System for Transformer-Based Generative Models (OSDI 2022) — iteration 단위 스케줄링과 selective batching. continuous batching의 원전.Iteration-level scheduling and selective batching. The origin of continuous batching.
- Agrawal et al., Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Serve (OSDI 2024) — chunked prefill과 stall-free batching. 생성 멈춤(generation stall)을 정의하고 없앤다.Chunked prefill and stall-free batching. Defines generation stalls and removes them.
- Zhong et al., DistServe: Disaggregating Prefill and Decoding for Goodput-optimized LLM Serving (OSDI 2024) — prefill과 decode를 다른 GPU에 두고 goodput을 최적화한다.Puts prefill and decode on different GPUs and optimises goodput.
- Patel et al., Splitwise: Efficient Generative LLM Inference Using Phase Splitting (ISCA 2024) — 단계별로 다른 기계(심지어 다른 GPU 세대)를 쓰는 비용 분석.A cost analysis of using different machines (even GPU generations) per phase.
- Qin et al., Mooncake: A KVCache-centric Disaggregated Architecture for LLM Serving (2024) — 분리형 prefill/decode 클러스터와 공유 KV 저장소를 함께 운영한 사례.Disaggregated prefill/decode clusters run together with a shared KV store.
- Agrawal et al., Etalon: Holistic Performance Evaluation Framework for LLM Inference Systems (2024) — TBT 꼬리와 fluidity-index. 평균이 멈춤을 숨기는 이유.TBT tails and the fluidity-index; why averages hide stalls.
- DeepSeek-AI, DeepSeek-V3 Technical Report §3.4 (2024) — prefill(32 GPU, EP32)과 decode(320 GPU, EP320)를 분리한 실제 배치.A real deployment with separate prefill (32 GPUs, EP32) and decode (320 GPUs, EP320) units.