Continuous Batching
A real GPT-2 server under static and continuous scheduling: latency, goodput and wasted work at four offered loads, plus what chunked prefill and queue policy do to fairness.
This chapter compares two ways of sharing a GPU between requests that arrive over time. At a light offered load (three tenths of a measured capacity reference), statically batched GPT-2 requests waited a median of 1.0 to 1.5 seconds for their first token. With iteration-level continuous batching, on the same GPU and model, the median was 55 to 60 milliseconds. Near the reference capacity, static batches of 8 recorded 4.8 to 6.6 seconds of median time to first token (TTFT), static batches of 32 recorded 1.4 to 1.7 seconds, and continuous batching recorded 60 to 67 milliseconds.
The objective was a TTFT of at most one second and a mean time per output token after the first (TPOT) of at most 100 milliseconds. Every completed continuous-scheduler request met it in these runs; for static batching the fraction ranged from 6 to 52 per cent.
Three qualifications belong with those numbers from the start:
- What the clock measures. These are local replay measurements: simulated waiting from arrival to service, plus synchronised model computation on this machine. There is no network, streaming transport or client rendering.
- What “met the objective” means. It is the fraction of requests meeting both TTFT at most one second and average TPOT at most 100 ms. It does not say every gap was under 100 ms; we look at the worst gaps separately, and they tell a different story. Nor is it a goodput rate in requests per second.
- What is being compared. These two particular scheduler implementations. The static one, for instance, runs prefills one request at a time. This is not a claim about every possible static-serving system.
Both schedulers use the same GPT-2 checkpoint, the same hand-written paged-KV forward path and the same deterministic prompts. Small-model tests confirm that static, continuous and chunked schedules produce the same greedy tokens as decoding each request alone. Scheduling changes when a request runs while targeting the same intended computation; the parity evidence above is limited to the tested models and shapes.
One more thing to admit up front. The harness that produced these numbers had a bug that made two runs hang, one for 38 minutes and one for about two hours, with no output at all. The cause was a floating-point comparison at a scheduling deadline, explained near the end. It shows why progress and termination are part of a replay harness’s correctness, not just details of its timing code.
Where this sits
Prefill and Decode split a request into prefill and decode, defined the latency metrics, and showed in a two-stream toy that one request’s prefill can stall another’s decode. Memory Bandwidth and Compute Bottlenecks found that decoding up to about 32 sequences together cost only 7 to 20 per cent more per step than decoding one. PagedAttention built a paged KV-cache reference and showed that memory policy and execution cost must be evaluated separately. This chapter puts those pieces together into a server: requests arrive over time, and at every step a scheduler decides who runs.
The Inference Lab gains a serving-loop experiment, examples/ch15/serving_loop.py. It has a seeded Poisson arrival generator; StaticScheduler and ContinuousScheduler built on the PagedAttention paged cache and decode function; two waiting-queue policies; a per-iteration prefill-token budget; and the latency metrics from Prefill and Decode. Its clock jumps over idle gaps and times model work with synchronised calls on the local machine. So it is a controlled replay of compute and queueing time, not a measurement of network delivery, HTTP overhead or client rendering. Its metric helper reports the fraction of completed requests meeting an objective; a throughput rate of compliant requests would have to be calculated separately.
For the Pi series, this is where an engine acquires a service level. An agent that waits seconds for the first token of every step is slow, whatever the model’s quality, and the API and serving designs that follow must keep this accounting. These measurements are a starting workload, not an SLO promise for a deployed Pi agent.
Two ways to share a batch
Static batching
The reference static scheduler collects up to \(B\) requests, or stops waiting after a deadline, and then works on that group until its longest requested output is finished:
- It runs prefill separately for each request, not as one padded batched prefill.
- At every decode iteration it sends all of the group’s original slots through the decoder, even those whose requests have already finished, and throws away the surplus tokens.
- A newly arrived request cannot join until the whole group has drained.
This is a deliberately straightforward baseline, with head-of-line delay and wasted decode slots, not an optimised version of every static-batching technique.
Continuous batching
Continuous batching, also called iteration-level scheduling, reconsiders who runs at every iteration. In ContinuousScheduler.run, each iteration does four things in order:
- Admit waiting requests that have arrived, up to a cap on concurrent sequences and a conservative KV reservation budget.
- Prefill the admitted requests, one request at a time, either in full or in bounded chunks under a shared prompt-token budget when chunking is on.
- Decode one more token for every request already active, as a ragged batch.
- Release completed requests’ slots and cache blocks, so newcomers can join at a later iteration.
Two details of this implementation matter for interpreting the results:
- Admission reserves a request’s whole declared prompt-plus-output capacity, even though physical KV blocks fill only as tokens are processed. The watermark and preemption policies from PagedAttention are not exercised here.
- Every token produced in an iteration is timestamped at the end of the iteration, whether it came from a finishing prefill or from decode. So when one request’s prefill runs in an iteration, it lengthens the recorded gap between tokens of every active request in that iteration. That is a useful coarse model of a service, not an instrumented per-token emission trace, and not Sarathi-Serve’s fused prefill/decode scheduling.
Where the idea comes from
Orca introduced iteration-level scheduling as a serving-system technique, together with selective batching; it was not simply a replacement for a static batch loop. Its abstract describes a scheduler that runs “one iteration” of the model at a time, lets early-finishing requests return, and lets new arrivals avoid waiting for the whole current batch. The same abstract reports a 36.9-fold throughput advantage over FasterTransformer on a 175-billion-parameter model at the same latency. That figure concerns a system and model far from this one, and I have not tried to reproduce it.
What the tests establish
The CPU tests use a small, randomly initialised GPT-2 configuration and check every request’s generated tokens against independent greedy decoding, including a chunked-prefill case. That establishes functional parity for the tested shapes, not a guarantee for every backend, precision, model length or production kernel. The full-GPT-2 GPU runs below are performance experiments, not an exhaustive output-equivalence suite.
The experiment
The workload
Each load setting replays 64 requests. Arrival gaps are drawn from an exponential distribution, which makes arrivals a Poisson process.
- Prompt lengths: log-normal around a median of 60 tokens, capped at 300 (default workload).
- Requested output lengths: median parameter 40, observed mean about 51 in the capacity trace, capped at 128 and by the context limit.
- Prompt content: deterministic pseudo-random token ids generated from the request id.
Each request runs for its requested output length; application stop conditions are not reproduced. The token content is needed for real model computation but does not represent production text.
Calibrating offered load
To say “light load” or “near capacity”, we need a capacity reference. I replayed 96 requests at a very high arrival rate against the continuous scheduler, and measured completed output tokens divided by the time from first arrival to last completion (the makespan). With near-simultaneous arrivals this is a useful short-run saturation reference, not a proof of steady-state capacity:
| Maximum batch | Output tokens per second | Makespan | Mean active sequences |
|---|---|---|---|
| 8 | 262 | 18.8 s | 7.3 |
| 16 | 415 | 11.8 s | 12.6 |
| 32 | 543 | 9.1 s | 20.2 |
Taking the best of these, 543 output tokens per second, and dividing by that trace’s mean of 51.18 output tokens per request gives a reference arrival rate of about 10.6 requests per second. New traces were then replayed at 0.3, 0.6, 0.9 and 1.2 times that rate. Because the reference comes from one finite trace and the load traces are short, a nominal load of 1.2 must not be read as a demonstrated overload threshold.
Schedulers, objective and repeats
- Schedulers. Static batches of 8 and of 32, each with a nominal 100 ms deadline for forming a batch (the scheduler may proceed sooner when no more arrivals remain), against continuous scheduling capped at 32 concurrent requests.
- Objective. A completed request passes if its TTFT is at most 1.0 s and its average TPOT after the first token, \((t_{\mathrm{last}}-t_{\mathrm{first}})/(n-1)\), is at most 0.100 s. That average includes any stalls between tokens, but it does not bound the largest single gap. The code calls the pass fraction
goodput_fraction; in common serving terminology goodput is a rate (passing requests per second), which this table does not report. Both thresholds were fixed before these runs. - Repeats. Three arrival and workload seeds per cell; tables show the observed minimum to maximum, not confidence intervals. The chunking and fairness experiments later use only two seeds each.
What the clock is
Arrival times are synthetic. When there is no work, the server moves its simulated now forward to the next arrival instead of sleeping. During an iteration it adds the elapsed time of a host perf_counter interval that covers the synchronised CUDA work and the Python scheduling, prefill and decode code inside it. Timestamps are assigned at iteration boundaries. So TTFT and completion times combine synthetic queueing with measured local execution under this replay. There is no network, streaming transport, client rendering or real-time external arrival pressure.
Results
| Offered load | Scheduler | Median TTFT | 95th percentile TTFT | Median end-to-end | Request SLO pass fraction |
|---|---|---|---|---|---|
| 0.3 | static, batch 8 | 1.0 – 1.5 s | 2.6 – 4.2 s | 1.8 – 2.6 s | 36 – 52% |
| 0.3 | static, batch 32 | 1.0 – 1.2 s | 2.4 – 2.8 s | 1.9 – 2.3 s | 41 – 52% |
| 0.3 | continuous | 55 – 60 ms | 80 – 96 ms | 1.0 – 1.2 s | 100% |
| 0.6 | static, batch 8 | 3.0 – 4.8 s | 6.8 – 10.3 s | 3.9 – 5.7 s | 11 – 12% |
| 0.6 | static, batch 32 | 1.3 – 1.7 s | 2.5 – 4.6 s | 2.5 – 2.9 s | 23 – 31% |
| 0.6 | continuous | 58 – 73 ms | 97 – 151 ms | 1.2 – 1.4 s | 100% |
| 0.9 | static, batch 8 | 4.8 – 6.6 s | 9.7 – 14.5 s | 5.5 – 7.9 s | 6 – 11% |
| 0.9 | static, batch 32 | 1.4 – 1.7 s | 2.9 – 3.8 s | 2.3 – 2.8 s | 22 – 33% |
| 0.9 | continuous | 60 – 67 ms | 95 – 120 ms | 1.2 – 1.3 s | 100% |
| 1.2 | static, batch 8 | 5.3 – 6.1 s | 10.7 – 13.3 s | 6.3 – 7.7 s | 8 – 12% |
| 1.2 | static, batch 32 | 2.1 – 2.4 s | 3.4 – 3.7 s | 2.9 – 3.3 s | 16 – 19% |
| 1.2 | continuous | 63 – 73 ms | 115 – 141 ms | 1.3 s | 100% |
Why first tokens differ so much. The gap comes from how these two implementations control the flow of work. A static group must drain before the next one starts, and its first-token timestamps are assigned only after all of that group’s per-request prefills have finished. So a request that arrives just after a group starts waits behind that group’s remaining decode steps, and then behind the next group’s prefills. Continuous batching can admit and prefill a waiting request at the next iteration boundary, so in these short traces its median TTFT stayed in the tens of milliseconds. That is the recorded outcome for this model, pool, reservation policy and arrival trace. It is not a guarantee that the median stays low once a long queue has built up.
Why end-to-end time stays at seconds. The median end-to-end time is 1 to 7 seconds, because a typical request still needs dozens of sequential decode steps; removing queueing cannot remove generation time. End-to-end time also includes prefill and any waiting, so the exact proportions depend on scheduler, seed and load. (In the small-model parity tests the generated tokens match; what differs between schedulers is the step schedule, the discarded work and the elapsed time.)
Throughput, and a caution
Completed requested output tokens divided by the replay makespan (which includes the arrival timeline, idle gaps, ramp-up and drain), ranges across three seeds:
| Offered load | Static, batch 8 | Static, batch 32 | Continuous |
|---|---|---|---|
| 0.3 | 117 – 143 | 119 – 145 | 129 – 166 |
| 0.6 | 149 – 175 | 167 – 235 | 219 – 286 |
| 0.9 | 144 – 161 | 242 – 339 | 315 – 379 |
| 1.2 | 161 – 171 | 284 – 355 | 387 – 472 |
On these matched short traces, continuous batching delivered more completed tokens per second than either static implementation. But it never approached the 543 tokens per second of the high-arrival reference. Sixty-four requests mean a ramp-up and a drain, and the mean number of active sequences in these continuous runs was only about 3.0 to 12.7, against 20.2 in the reference. So this table shows how these schedulers behave on identical finite workloads. It is not a stable capacity curve, a guarantee of throughput under sustained overload, or evidence that a nominal load of 1.2 can be sustained.
Where static batching loses
Two mechanisms are visible in the data.
Wasted decode slots. The static decoder keeps running every member of its group until the longest output is complete. The metric useful_fraction_of_decode_slots divides the useful decode positions after prefill by all decode positions executed after prefill (first tokens from prefill are counted in neither). Across the static runs it was about 0.38 to 0.59, so 41 to 62 per cent of those decode slots produced tokens that were thrown away. That is avoidable work for this baseline, though not a direct measure of the same percentage of GPU FLOPs, energy or time.
Head-of-line waiting. A request that arrives just after a batch starts must wait for that batch’s longest member, and with variable output lengths the longest member often runs well beyond a typical one. How large this effect is depends on the sampled mix of lengths; the experiment measures that mix rather than establishing a general rule about batch size.
Across the seed ranges, the larger static batch generally gave shorter first-token delays than batch 8, especially at higher load, but was still far slower than continuous batching. Those results include the static implementation’s per-request prefills and fixed slots, so batch size is not the isolated cause.
What continuous batching costs
The advantage is not free. Two measures went the other way:
| Metric | Static | Continuous |
|---|---|---|
| Mean per-request TPOT after the first token | 20 – 22 ms | 23 – 28 ms |
| 95th percentile across requests of each request’s largest inter-token gap | 28 – 69 ms | 65 – 157 ms |
(Note the two rows aggregate differently: the first is a mean of per-request averages, the second a percentile of per-request maxima.)
Under continuous batching, average TPOT was somewhat higher, and so was the tail of each request’s worst gap. In this scheduler a prefill runs in the same iteration as ongoing decodes, so it can lengthen an active request’s gap. Static groups run their prefills before their decode loop, which gave smoother decoding within each group under these conditions. A larger average active batch is a plausible further contributor to TPOT, but the experiment does not separate batch size from prefill interference, dispatch overhead and differing arrival schedules.
This explains the apparent paradox from the opening. The objective checks average TPOT, so a request can pass while having one gap well over 100 ms, and under continuous batching the 95th percentile of worst gaps reached 157 ms. The 100% pass rate and the visible streaming hiccups are consistent. A requirement that every gap stay under 50 or 100 ms would be a different SLO, and would have to be evaluated from per-token timestamps, not inferred from mean TPOT. Whether users prefer a short first-token wait or smoother streaming depends on the application; a production service should report both first-token and per-gap tail constraints when they matter.
Chunked prefill
Prefill and Decode showed in isolation how one request’s prefill can delay another’s decode. Does limiting how much prefill runs per iteration help?
What was tested. An iteration-level prompt-token budget, not a fused stall-free serving implementation. In a modified workload, about 10 per cent of requests have 700-token prompts. Each iteration, the scheduler processes admitted prefills in dictionary/arrival order until a budget of 256, 128 or 64 tokens is used up, and separately decodes the requests already active. A smaller budget means more iterations of prefill. There is no separate fairness rule among pending prefills, so a short prompt can wait behind chunks of a long one. The budget does not reserve decode compute in advance or reproduce Sarathi-Serve’s balanced batches.
Results in milliseconds, two seeds per cell. “Worst gap” is the 95th percentile, across short requests, of each request’s longest inter-token gap (not the 95th percentile of individual gaps):
| Prefill budget per iteration | Worst gap, seed 1 / seed 2 | Short TTFT p95, seed 1 / seed 2 | Long TTFT median, seed 1 / seed 2 |
|---|---|---|---|
| Unchunked | 70 / 57 | 64 / 47 | 61 / 66 |
| 256 tokens | 88 / 62 | 251 / 118 | 136 / 132 |
| 128 tokens | 64 / 38 | 274 / 167 | 182 / 152 |
| 64 tokens | 42 / 84 | 765 / 413 | 237 / 302 |
Streaming stalls: no reliable improvement. The worst-gap figure does not fall steadily as the budget shrinks, and with seed 2 the 64-token budget looks worse than unchunked.
First-token time: a clear cost, within these traces. Short-request p95 TTFT rose from 47–64 ms unchunked to 413–765 ms with a budget of 64, and long requests’ median TTFT rose too. This is a result about this scheduling policy, not proof that chunking inherently hurts short requests: here, a long queued prefill can consume the whole budget before a short one gets a turn. With only seven to nine long requests per run, the data cannot identify the best chunking policy.
Why might the stall benefit not show? In Prefill and Decode, one long prefill produced an obvious isolated stall. Here prefill and decode are interleaved among many requests, and both execution variation and queue order matter. An unchunked 700-token prefill took roughly 35–45 ms, while iterations often last tens of milliseconds anyway, so a two-seed tail comparison has little power to detect the benefit.
Sarathi-Serve is not this scheduler with a smaller number. It builds compute-balanced batches and aims explicitly to avoid decode stalls, and its reported A100 results concern larger models and other workloads; they were not reproduced here. The defensible conclusion is narrow: this FIFO prefill-budget implementation, on these GPT-2 traces, raised TTFT without consistently lowering the worst-gap statistic. Whether well-scheduled chunked prefill helps remains open.
Fairness
The order in which waiting requests are admitted is a priority policy. Two were tested:
- First-come-first-served (FCFS): admit the oldest waiting request.
- Shortest-prompt-first (SPF),
shortest_prompt: admit the waiting request with the smallest prompt.
Neither preempts an admitted request, and both remain constrained by the number of active and prefilling requests and by the memory reservation budget.
The set-up. To expose differences between classes, the continuous batch cap was reduced to 8, and about 25 per cent of requests were given 600-token prompts. Queue wait here means arrival to admission, not arrival to first token; prefill comes afterwards. It is a finite synthetic trace, so it can show trade-offs in tail waiting but cannot prove indefinite starvation.
At offered load 1.2, two seeds:
| Policy | Short requests: median wait | Long requests: median wait | Long requests: maximum wait |
|---|---|---|---|
| FCFS | 143 / 672 ms | 52 / 414 ms | 673 / 1,103 ms |
| Shortest-prompt-first | 43 / 80 ms | 163 / 1,143 ms | 1,110 / 3,794 ms |
SPF cut short requests’ median wait by a factor of 3 to 8, and raised the worst wait of a long request by a factor of 1.6 to 3.4. Completed-token rates were 391 and 442 tokens per second for FCFS, against 398 and 474 for SPF; two runs cannot show whether those small differences are systematic. The supported finding is that SPF moved waiting from short prompts to long ones, not that either policy changes capacity.
At load 0.9 the two seeds disagreed: SPF helped in one and hurt both classes in the other. The data do not show whether queue depth, memory reservation or the interaction of arrival order with prompt length caused the difference, so I report the disagreement rather than averaging it away.
A policy is a decision about whom to make wait, and a fairness claim needs a metric for each class. A single average wait would have called SPF a clear win here. A deployment should track the distribution of queue wait by request class, and consider ageing or a bounded-wait admission rule. The SPF implementation has no anti-starvation bound; the finite trace neither proves one is needed at these rates nor suggests an ageing parameter.
The bug
Twice, an experiment run produced nothing and never ended: once for 38 minutes before I stopped it, and once for about two hours. The process was alive and using one processor core. The existing tests had not exercised this floating-point deadline case, so their passing did not imply progress for every arrival sequence.
Finding it. I reproduced the hang on a single configuration and set a watchdog (faulthandler.dump_traceback_later) to print where the process was when a timer expired. It was in the static scheduler’s wait logic, before the current deadline fix. Here is that historical, buggy code (not the corrected implementation). With a partly filled batch, deciding whether to keep waiting, it computed:
ready = len(waiting) >= batch_size or not pending or now - oldest >= max_wait
if not ready:
now = min(oldest + max_wait, pending[0].arrival)
The failure. If the next arrival was far away, now was set to oldest + max_wait, so on the next pass now - oldest >= max_wait ought to be true. In floating point it can be false. For oldest = 4.222109257625241, (oldest + 0.1) - oldest is 0.09999999999999964, just under 0.1. When the next arrival lay beyond that horizon, the scheduler could set now to the same value again and again: a livelock. The failure depends on particular floating-point inputs and the scheduling path, not on any general inability to represent 0.1 seconds.
The fix. The current code computes horizon = oldest + max_wait, tests now >= horizon directly, and refuses any proposed time advance that does not actually increase now. The regression suite has the constructed deadline case plus 30 random arrival patterns. The two stalled runs happened before this change; the reported performance runs use the repaired code. The regression test shows that the fixed loop terminates for these cases. It does not prove termination for every possible timestamp, or that earlier successful results would be bit-for-bit identical after the fix.
Why it matters beyond tidiness. A simulation whose time advances in jumps is only as sound as its comparisons between times, and equality of computed floating-point times is fragile. This failure was loud. A version that silently skipped a deadline, or advanced time by the wrong amount, could have produced plausible-looking latency tables. A trustworthy harness should check termination, that virtual time never goes backwards, timestamp ordering and that every request completes exactly once, and it should keep raw per-request records for replay.
Inference Lab increment
The Lab now has:
make_workload,StaticScheduler,ContinuousScheduler, queue policiesfcfsandshortest_prompt,Server,summarise,pick_nextandpercentile, including a configurable prompt-token prefill budget. The focused serving-loop tests cover small-model token parity, cache release, timestamp consistency, constrained admission, deterministic workloads, request-level metrics and the static-deadline livelock regression. They do not run the full recorded GPT-2 GPU experiment in CI.- The
capacity,loads,chunkingandfairnesscommands, with recorded outputs inresearch/ch15/results.jsonand related raw evidence. The command-line defaults differ from the published experiment (64 requests, three seeds); reproducing it needs an exact command or workload manifest beyond these defaults. That command provenance remains to be recovered; the defaults alone do not reproduce the published experiment.
The rule this adds: a scheduler is judged by its distributions of queueing and latency, its objective pass fraction and its qualified throughput, at explicitly calibrated offered loads, with per-request output parity verified where practical. These results show much lower TTFT for iteration-level scheduling on finite traces; they do not show the same advantage under every load, kernel or policy.
Limits of this chapter’s evidence
About the implementations
- Specific reference schedulers. Both use GPT-2 and the gather-based, unfused paged forward pass from PagedAttention; the static scheduler prefills requests one at a time rather than in one optimised batch. Nothing here ranks production serving engines.
- Conservative KV admission. Continuous scheduling reserves each request’s whole declared prompt-plus-output allowance at admission; the grow-on-demand watermark, eviction and preemption policies of PagedAttention are not exercised.
About the measurements
- A hybrid clock. Arrivals and idle time are simulated; local GPU execution is timed with synchronisation. No network, streaming delivery, tokenisation, request parsing or client-observed latency.
- Finite traces. Each load setting is 64 requests, including ramp-up and drain, at multiples of a 96-request high-arrival reference. Not a steady-state stability or queue-capacity test.
- Few seeds. Three for the main comparison, two for chunking and fairness; ranges are observations, not confidence intervals.
- Synthetic demand. Poisson arrivals and log-normal lengths, not production traces; pseudo-random prompt ids; no EOS stopping, text quality or application behaviour.
- An average-TPOT objective. The 100% pass fraction limits average gaps, not each gap, and it is not a requests-per-second rate.
- Model and execution specificity. Launch and dispatch overhead was large and varied between sessions. A larger model, different kernels, another precision or longer prompts could shift every trade-off.
About fairness
- No multi-tenant fairness guarantee. Shortest-prompt-first was measured on small two-seed traces, without ageing, priorities or any starvation analysis.
What you should now be able to do
- Describe static and continuous batching, and say what changes from one iteration to the next.
- Compute the useful fraction of decode slots in a static batch.
- Define offered load relative to a measured capacity reference, and design a replay that uses a virtual clock for idle time.
- Report TTFT, average TPOT, worst inter-token gap and request SLO pass fraction by scheduler and load, and distinguish that fraction from goodput expressed as a rate.
- Say what continuous batching costs in smoothness, and what this chapter’s chunked-prefill experiment did and did not show.
- Explain how an admission policy moves waiting between classes of request, and what to measure to see it.
- Find a non-terminating loop in a simulation with a watchdog traceback.
The schedulers in this chapter never reuse computation across requests: every request’s prompt is prefilled from scratch, even though, in a real service, many requests could begin with the same system prompt. Prefix Caching examines what can safely be shared between requests, and what that sharing gives away.
Key terms
- Static batching: running a fixed group of requests until its longest member has finished; the baseline here performs prefills individually and retains finished decode slots.
- Continuous batching / iteration-level scheduling: reconsidering admission and active decode membership at each model iteration.
- Offered load: requested arrival rate divided by a stated reference request-completion rate; a finite-trace capacity reference is not a stability limit.
- TTFT: simulated request-arrival time to its first recorded token, including local queuing and computation in this harness.
- TPOT: the average interval between output tokens after the first, computed per request as \((t_{\mathrm{last}}-t_{\mathrm{first}})/(n-1)\).
- Worst inter-token gap: the largest gap within a request; a tail percentile of these maxima differs from average TPOT.
- Request SLO pass fraction: proportion of completed requests meeting both the TTFT and average-TPOT thresholds; the implementation currently labels this
goodput_fraction. - SLO-qualified goodput rate: count of compliant completed requests divided by an explicitly defined observation duration, in requests per second; not reported in the results table.
- Useful decode fraction: post-prefill decode slots that contributed a requested token, divided by all post-prefill decode slots executed.
- Queue wait: arrival-to-admission time, not including the request’s later prefill or decode.
- Starvation: unbounded postponement of a waiting class under ongoing arrivals; not demonstrated by a finite trace.
- Virtual clock: synthetic scheduling time that skips idle gaps and advances by measured local compute time.
Reader exercises
- For static batches of eight requests, calculate the post-prefill useful decode-slot fraction from their output lengths. Explain why this is not the percentage of GPU time wasted.
- Add aging to shortest-prompt-first, then test its maximum and p95 queue wait under sustained arrivals. Does a finite trace suffice to establish a bounded-wait guarantee?
- Repeat
loadswith 400 or more requests and several arrival seeds. Plot achieved throughput, p95 TTFT, queue depth and number of active sequences against offered load; compare with the 543-token/s finite saturation reference. - Replace admission-time reservation with on-demand blocks and a tested watermark (PagedAttention). What changes in admission, preemption risk and achieved throughput?
- Give a constrained prefill budget first to oldest requests, then to shortest remaining prompts. Report short-request and long-request TTFT as well as p95 worst inter-token gaps. Does chunking alone still appear to explain the result?
- Recalculate the main objective with an additional requirement that every inter-token gap be at most 50 ms, then 100 ms. Report both the compliant-request fraction and the compliant-request rate.
- Insert the historical floating-point deadline into the static scheduler. Add monotonic-clock, termination and request-accounting invariants that would detect a regression even when a run exits.
- Replace sequential static prefills with a genuinely batched prefill of padded, masked requests. Hold weights, traces, token outputs and cache budgets fixed; measure how much of the original scheduling difference remains.
References
- Orca: A Distributed Serving System for Transformer-Based Generative Models — Yu et al., OSDI 2022. Establishes iteration-level and selective batching. Its reported 36.9× throughput result comes from a different distributed system and 175B-parameter model; it is not reproduced here.
- Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Serve — Agrawal et al., OSDI 2024. Explains chunked prefills together with stall-free, compute-balanced scheduling. The chapter’s simple FIFO chunk budget is not equivalent to that implementation.
- DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Serving — clarifies why TTFT and TPOT objectives must be assessed together and motivates scheduling/prefill-decode separation. Its system measurements are not reproduced here.
All three are primary research on serving policy, not external validation of this chapter’s 64-request GPT-2 replay.
Evidence in this chapter
| Claim | Category |
|---|---|
| Iteration-level batching lets finished requests leave and new ones join at successive model iterations | Established background (Orca); implemented in the reference scheduler |
| Static, continuous and chunked schedules preserve greedy tokens relative to independent decoding | Book test result on a small CPU model and sampled workloads; not exhaustive GPU parity |
| Main TTFT comparison: approximately 989–6,582 ms static against 55–73 ms continuous | Book result, GPT-2 GPU replay, three seeds and 64 requests per load cell; synthetic arrivals |
| 100% of continuous requests pass TTFT ≤ 1 s and mean TPOT ≤ 100 ms; static 6–52% | Book result as a request-level SLO pass fraction, not a per-gap guarantee or requests/s goodput rate |
| 38–59% of static post-prefill decode slots are useful | Book result for the specified static baseline; not a direct FLOP/energy ratio |
| Continuous delivers more completed output tokens per replay second | Book result for matched finite traces; no steady-state capacity comparison |
| Continuous has average request-level TPOT 23–28 ms and p95 per-request maximum gap 65–157 ms | Book result; definitions differ and some recorded worst gaps exceed 100 ms |
| The 543-token/s reference determines the true stable capacity under indefinite Poisson load | Not established; obtained from 96 near-simultaneous arrivals |
| This FIFO-prefill-budget chunking increases TTFT and does not consistently improve worst gaps | Book result, two seeds; not a test of Sarathi-Serve’s complete algorithm |
| Shortest-prompt admission trades lower short-request waits for higher long-request tail waits at load 1.2 | Book result, two seeds; no starvation guarantee or confidence interval |
| Floating-point deadline arithmetic caused a historical static-scheduler livelock | Book investigation; current implementation has a targeted regression and progress guard |
| Production traces, dynamic preemption, client latency, stable goodput rate, fair scheduling guarantees | Not measured |