← Inference From First Principles

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.

At a light offered load, set to three tenths of a measured capacity reference, statically batched GPT-2 requests had median time-to-first-token (TTFT) between 1.0 and 1.5 seconds. With iteration-level continuous batching on the same GPU and model, the range was 55 to 60 milliseconds. Near the reference capacity, static batches of 8 recorded 4.8 to 6.6 seconds of median TTFT, and static batches of 32 recorded 1.4 to 1.7 seconds; continuous batching recorded 60 to 67 milliseconds. These are local replay measurements that include simulated arrival-to-service waiting and synchronised model computation, not network or client-rendering time.

Under an objective of TTFT no greater than one second and mean time per output token after the first (TPOT) no greater than 100 milliseconds, every completed continuous-scheduler request passed in these runs. The corresponding fraction for static batching ranged from 6 to 52 per cent. This is an SLO pass fraction, not a goodput rate in requests per second, and it does not say that every interval between consecutive tokens was shorter than 100 milliseconds. We will examine the worst intervals separately.

The schedulers use the same GPT-2 checkpoint, the same hand-written paged-KV forward path and the same deterministic per-request prompt construction. Small-model regression tests confirm that static, continuous and chunked schedules produce the same greedy token sequences as independent decoding. The scheduling policy changes when a request runs, not its intended computation. This chapter measures the consequence on a single GPU, while distinguishing a replayed serving timeline from measurements at a real network endpoint. The static implementation also runs prefills one request at a time; the comparison is between these particular scheduling implementations, not a claim about every possible static-serving system.

I also have a confession about the harness that produced these numbers. It had a bug that made two experiment runs hang, one for 38 minutes and one for about two hours, with no output at all. The bug was a floating-point comparison at a scheduling deadline, described near the end. It exposes why progress and termination are part of the correctness contract for a replay harness, 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 toy alternation of two streams that one request’s prefill stalls another’s decode. Memory Bandwidth and Compute Bottlenecks found that decoding up to about 32 sequences together costs only 7 to 20 per cent more per step than decoding one. PagedAttention built a paged KV-cache reference with a gather-based attention path and showed how its memory policy and execution cost must be evaluated separately. This chapter assembles them into a server: requests arrive over time, and a scheduler decides at each step who runs.

The Inference Lab piece added here is the serving-loop experiment, examples/ch15/serving_loop.py: a seeded Poisson-arrival generator; StaticScheduler and ContinuousScheduler over the PagedAttention paged cache and decode function; two waiting-queue policies; a per-iteration prefill-token budget; and the Prefill and Decode latency metrics. A virtual timeline jumps over idle gaps, while model work is timed with synchronised calls on the local machine. This produces a controlled replay of compute and queueing time, not a measurement of real network delivery, HTTP overhead or client rendering. The helper reports the fraction of completed requests meeting an objective; an SLO-qualified throughput rate must be calculated separately.

For the Pi series, this is the chapter that turns an engine into something with a service level. An agent that waits seconds for the first token of each step is a slow agent, whatever the model’s quality, and subsequent API and serving designs must preserve that service-level accounting. These measurements are a starting workload, not an SLO promise for a deployed Pi agent.

Two ways to share a batch

Two ways to share a batch

Static batching. The reference scheduler collects up to \(B\) requests, or proceeds after a waiting deadline, and processes that group until its longest requested output is complete. It calls prefill separately for each request rather than performing a single padded batched prefill. At every subsequent decode iteration it sends all original batch slots through the common decoder, even after some requests have completed, and discards the surplus tokens. A new arrival cannot join until the current group drains. This is an intentionally straightforward baseline, with head-of-line delay and wasted decode slots, not an optimised implementation of all static-batching techniques.

Continuous batching (iteration-level scheduling). At each iteration this implementation admits waiting requests up to a sequence-count cap and a conservative KV reservation budget. It advances admitted prefills, either in full or in bounded chunks, and generates one further token for each already-active request. Completed requests release their slots and cache blocks, so newcomers may join at a later iteration. Logical admission reservation is for each request’s entire declared prompt-plus-output capacity, even though physical KV blocks are populated as tokens are processed. The PagedAttention watermark and preemption policies are not exercised here.

Orca introduced iteration-level scheduling as a serving-system technique, together with selective batching rather than simply replacing a static batch loop. Its abstract describes a scheduler that runs “one iteration” of the model at a time on the batch, lets early-finishing requests return, and lets newly arrived requests 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, a figure about a system and model far from this one, which I have not tried to reproduce.

In ContinuousScheduler.run, an iteration first admits requests whose arrivals are visible and for which the configured batch and reservation limits allow space. It then executes eligible prefill chunks one request at a time, using a shared prompt-token budget when chunking is enabled. Next it performs a ragged decode step for the already-active requests and records completions. First tokens obtained from completed prefills and tokens obtained from decode are both timestamped at the end of the entire iteration. Consequently, another request’s prefill contributes to the recorded inter-token delay of active requests. This is a useful coarse service model, but not an instrumented per-token network emission trace or Sarathi-Serve’s fused prefill/decode scheduling kernel.

What is being compared

Both schedulers run the same deterministic model and cache mathematics. The CPU tests use a small, randomly initialised GPT-2 configuration and check each request’s generated tokens against independent greedy decoding, including a chunked-prefill case. These tests establish functional parity for the tested shapes, not a mathematical guarantee for every backend, precision, model length or production kernel. The full-GPT-2 GPU runs below are performance experiments; they are not an independent exhaustive output-equivalence suite.

The experiment

Continuous batching: TTFT by offered load

Workload. Each load cell replays 64 requests, with inter-arrival times sampled from an exponential distribution (a Poisson arrival process). Prompt lengths come from a log-normal distribution centred on a median of 60 tokens and capped at 300 for the default workload. Requested output lengths have a median parameter of 40, an observed mean of about 51 in the capacity trace and a cap of 128, subject also to the context limit. Prompt token IDs are deterministic pseudo-random values generated by request ID. The harness runs for the requested output length rather than reproducing application-specific stop conditions; token content is needed for real model computation but does not represent a production text mix.

Capacity reference. I first replayed 96 requests at a very high arrival rate against the continuous scheduler and measured completed output tokens divided by replay makespan. The near-simultaneous arrival experiment is a useful short-run saturation reference, not a steady-state capacity proof:

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

I used 543 output tokens per second (the measured maximum for these three batch caps), divided by the 96-request trace’s mean of 51.18 output tokens, to define a reference arrival rate of about 10.6 requests per second. I then replayed new traces at 0.3, 0.6, 0.9 and 1.2 times that reference arrival rate. Because the baseline is finite and the new traces are short, a nominal offered load of 1.2 must not be interpreted as a demonstrated steady-state overload threshold.

Schedulers. Static batch sizes of 8 and 32, each using a nominal 100 ms wait deadline to form a batch, versus continuous iteration-level scheduling capped at 32 concurrent requests. The static scheduler may proceed sooner when no future arrivals remain; it also performs per-request prefills sequentially. These choices are part of the benchmark configuration.

Objective. Each completed request passes if its TTFT is at most 1.0 second and its average TPOT after the first token, \((t_{\mathrm{last}}-t_{\mathrm{first}})/(n-1)\), is at most 0.100 seconds. The numerator is elapsed replay time, including stalls between output tokens; it is not a bound on the largest individual inter-token gap. The implementation’s goodput_fraction is the proportion that passes both predicates. In common serving terminology, SLO-qualified goodput is often a rate (for example, passing requests per second); that quantity is not the metric printed in the results table. The two thresholds were specified before these recorded runs.

Repeats. Three arrival/workload seeds per scheduler-and-load cell; the tables give the observed minimum-to-maximum range, not confidence intervals. The chunking and fairness comparisons later have only two seeds each.

What the clock is. Request arrival timestamps are generated synthetically. When there is no work, the server advances its simulated now to the next arrival rather than sleeping. During an iteration it adds elapsed time from a host perf_counter interval that encompasses synchronised CUDA work and Python scheduling/prefill/decode operations within that timed region. Request timestamps are applied at iteration boundaries. The resulting TTFT and completion times combine synthetic queueing with measured local execution under this replay, not an end-to-end client measurement. 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%

The large separation in first-token time comes from the control flow of these implementations. A static group must drain before a new one starts, and its first-token timestamps are assigned only after all per-request prefills in that group complete. A later arrival can therefore wait behind the preceding group’s remaining decode steps and behind the next group’s prefills. Continuous batching can admit and prefill a waiting request at an iteration boundary, so in these short traces its median TTFT remained in the tens of milliseconds. That is a recorded outcome for the model, pool, reservation policy and arrival trace—not a guarantee that the median remains low after a long sustained queue forms.

The median end-to-end time is 1 to 7 seconds. The typical request still needs dozens of sequential decode steps, so eliminating queueing cannot eliminate its full generation time. End-to-end latency also includes prefill and any waiting; the exact ratio depends on the scheduler, seed and offered load. Completed greedy tokens match in the small-model parity tests, but the step schedule, amount of discarded work and elapsed time differ.

Throughput, and a caution

Completed requested output tokens divided by the replay makespan (which includes the generated arrival timeline, idle gaps, ramp-up and drain), shown as 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

The continuous implementation delivered higher completed-token throughput than either static implementation on these matched short traces. But it did not approach the 543-token/s high-arrival reference: 64 requests produce a ramp-up and drain, and the recorded mean active-sequence counts in the continuous load experiments were only about 3.0 to 12.7, versus 20.2 in the high-arrival reference. The table therefore characterises how these schedulers behave for identical finite workloads. It is not a stable capacity curve, a guarantee of throughput under indefinite overload or evidence that a nominal 1.2 reference load is sustainable.

Where static batching loses

Two mechanisms are visible in the data.

Wasted decode slots. The static decoder continues to run all members of its original group until its longest output is complete. useful_fraction_of_decode_slots counts useful post-prefill decode positions divided by all post-prefill decode positions executed for that group; first tokens produced by prefill are not included in either count. Across the recorded static runs it was about 0.38 to 0.59. Thus 41 to 62 per cent of those decode slots produced surplus tokens that the scheduler discarded. This is avoidable work for this baseline, but it is not a direct measurement of the same percentage of GPU FLOPs, energy or wall-clock time.

Head-of-line waiting. A request that arrives just after a batch starts waits for that batch’s longest member. With variable requested output lengths, the longest member often runs longer than a typical member. The magnitude of the effect depends on the sampled mix, and the experiment measures that mix rather than proving a universal batch-size rule.

Across the presented seed ranges the larger static batch generally reduced first-token delay compared with batch 8, particularly at higher load, but was still far slower than continuous batching. This result includes the static implementation’s per-request-prefill and fixed-slot costs; batch size alone is not the isolated causal variable.

What continuous batching costs

Wasted slots and trade-offs

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

The recorded average TPOT was somewhat higher under continuous batching, while its 95th percentile of the largest per-request inter-token gap was also higher. In this scheduler, a prefill is processed in the same iteration as ongoing decodes, so its execution can lengthen an active request’s gap. Static groups run their prefills before their decode loop, producing smoother within-group decode under these conditions. The larger average active batch in continuous scheduling is a plausible contributor to TPOT, but the experiment does not isolate batch size from prefill interference, dispatch overhead and differing arrival schedules. The table contains two different aggregations: mean of request-level averages, and a percentile of request-level maxima.

Whether users prefer a shorter first-token delay or more uniform streaming depends on the application. The chosen pass condition checks mean TPOT, so a request can pass while having one gap longer than 100 ms; indeed the recorded 95th percentile of worst gaps under continuous batching reaches 157 ms. Therefore the 100 per cent pass result and the observed streaming hiccups are consistent, not contradictory. A requirement that every gap remain below 50 or 100 ms would be a different SLO and must be evaluated from the per-token timestamps, not inferred from mean TPOT. A production service should report both first-token and per-gap tail constraints when they matter.

Chunked prefill

Prefill and Decode isolated how prefill could delay another stream’s decode. Here I tested an iteration-level prompt-token budget, not a fused stall-free serving implementation. In the modified workload, about 10 per cent of requests have 700-token prompts. The scheduler processes admitted prefills in dictionary/arrival order until it exhausts a 256-, 128- or 64-token budget for that iteration, and separately decodes requests already active. Shorter budgets mean more prefill iterations; without a distinct fairness rule for those pending prefills, a short prompt can wait behind chunks of a longer one. The budget does not reserve decode compute in advance or reproduce Sarathi-Serve’s balanced batches.

For short requests, the 95th percentile across requests of each request’s longest inter-token gap (not the 95th percentile of individual gaps), together with short-request p95 TTFT and long-request median TTFT; all are in milliseconds, and each cell shows two separate seeds:

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

The two-seed result does not establish a reliable improvement in streaming stalls: the worst-gap statistic is not monotonic with the budget, and seed 2 makes the 64-token budget look worse than unchunked execution. The cost to TTFT is clearer within these traces. Short-request p95 TTFT grew from 47–64 ms unchunked to 413–765 ms at a budget of 64; median TTFT for long requests also increased. This is a scheduler-policy result, not a demonstration that chunking intrinsically worsens short-request latency. In this implementation, a long queued prefill can consume the available token budget before a shorter one gets a turn. With seven to nine long requests per run, the data cannot identify the best prefill-chunk policy.

The earlier two-stream Prefill and Decode experiment exposed an obvious isolated stall. Here, prefill and decode are interleaved among many requests, and both execution variation and queue order matter. The recorded unchunked 700-token prefill is approximately 35–45 ms against iterations often lasting tens of milliseconds, so a two-seed tail comparison has little power to establish the benefit. Sarathi-Serve is not simply this scheduler with a smaller integer budget: it constructs compute-balanced batches and explicitly aims to avoid decode stalls. Its reported A100 results concern larger models and different workloads and were not reproduced here. The defensible conclusion is that this particular FIFO-prefill-budget implementation, on these GPT-2 traces, increased TTFT without consistently lowering the measured worst-gap statistic; the wider benefit of properly scheduled chunked prefill remains open.

Fairness

Admission order expresses a priority policy. First-come-first-served (FCFS) selects the oldest waiting request; shortest_prompt selects the smallest prompt among requests that have already arrived. Neither rule preempts a request that has been admitted, and both are also constrained by the number of active/prefilling requests and the memory reservation budget. To expose class differences I reduced the continuous batch cap to 8 and made roughly 25 per cent of requests have 600-token prompts. Queue wait is arrival-to-admission, not arrival-to-first-token; prefill time comes later. The experiment is a finite synthetic trace, so it can demonstrate tail-wait trade-offs 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. The corresponding completed-token rates were 391 and 442 tokens/s for FCFS versus 398 and 474 for SPF. Two runs are insufficient to decide whether those small rate differences are systematic. The strongest supported observation is the redistribution of queue wait between short and long prompts, not a causal claim that neither policy affects capacity.

At load 0.9 the two seeds disagreed, with SPF helping in one and hurting both classes in the other. These results do not isolate whether the difference came from queue depth, memory reservation or the interaction of arrival order with prompt length. I report the disagreement rather than averaging it away.

A policy is a claim about whom to make wait, and a fairness claim needs a metric per class. A single average wait would have called SPF a clear win here. A deployment should track the queue-wait distribution by request class and consider aging or a bounded-wait admission rule. The present shortest-prompt-first implementation has no anti-starvation bound, and the finite trace does not prove one is needed at the tested rates or supply an optimal aging parameter.

The bug

Twice, an experiment run produced nothing and never ended: once for 38 minutes before I stopped it, then for about two hours. The process was alive and using one processor core. Existing tests had not exercised that floating-point deadline case, so their passing status did not imply progress under all arrival sequences.

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. The following fragment is historical buggy code, not the corrected implementation: When the scheduler had a partly filled batch and had to decide 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)

If the next arrival was far off, now was set to oldest + max_wait. The test now - oldest >= max_wait should then be true. In floating point it can be false: for oldest = 4.222109257625241, (oldest + 0.1) - oldest is 0.09999999999999964. When the next arrival lay beyond that horizon, the scheduler could assign the same value to now repeatedly and enter a livelock. This failure depends on the specific floating-point inputs and scheduling path, not on a general inability to represent 0.1 seconds.

The current implementation computes horizon = oldest + max_wait, checks now >= horizon directly and refuses a proposed time advance that does not actually increase now. The regression suite contains the constructed deadline case plus 30 random arrival patterns. The historical investigation recorded two stalled runs before this change; the reported performance runs use the repaired implementation. A regression test demonstrates that the fixed loop terminates for these cases. It does not establish termination for every possible timestamp, nor that all earlier successful results would be bit-for-bit invariant to the fix.

It matters here for a reason beyond tidiness. A simulation in which time advances in jumps is only as sound as its comparisons of times, and equality of computed floating-point times is fragile. This particular failure was loud, but a version that skipped a deadline or advanced time by the wrong increment could have produced plausible latency tables. A trustworthy harness should check termination, monotonic virtual time, timestamp ordering and conservation of completed requests, and it should retain raw per-request records for replay.

What the numbers do not show

  • A specific reference implementation. Both schedulers use GPT-2 and the PagedAttention gather-based, unfused paged forward; static prefills requests sequentially rather than as one optimised batched operation. None of this ranks production serving engines.
  • A hybrid virtual clock. Arrivals and idle waiting are simulated; local GPU execution is timed with synchronisation. Network transport, streaming delivery, tokenisation, request parsing and client-observed latency are absent.
  • Finite traces. The four offered loads are multipliers of a 96-request high-arrival throughput reference. Each load run contains 64 requests, including ramp-up and drain, and is not a steady-state stability or queue-capacity test.
  • Small sample counts. Three seeds for the main comparison, two for chunking and fairness. The presented ranges are observations, not confidence intervals.
  • Synthetic demand. Poisson arrivals and log-normal prompt/output lengths are not production traces. Prompt IDs are pseudo-random; EOS-triggered stopping, text quality and application behaviour were not evaluated.
  • Conservative KV admission. The continuous scheduler reserves the whole declared prompt-plus-output allowance at admission. It does not exercise PagedAttention’s grow-on-demand watermark, eviction or preemption policy.
  • An average-TPOT SLO. The reported 100% pass fraction is not a limit on each inter-token gap, nor is it an SLO-qualified requests-per-second rate.
  • Model and execution specificity. Launch/dispatch overhead was substantial and varied between sessions. A larger model, faster or different kernel, changed precision or longer prompts can shift all of these trade-offs.
  • No real multi-tenant fairness guarantee. Shortest-prompt-first was measured on small two-seed traces, without aging, priorities or starvation proofs.

Inference Lab increment

The Lab now has:

  • make_workload, StaticScheduler, ContinuousScheduler, queue policies fcfs and shortest_prompt, Server, summarise, pick_next and percentile, including a controlled prompt-token prefill budget. The focused serving-loop test file covers small-model token parity, cache release, timestamp consistency, constrained admission, deterministic workloads, request-level metric calculations and static-deadline livelock regression. It does not run the full recorded GPT-2 GPU experiment in CI.
  • The capacity, loads, chunking and fairness CLI commands, with recorded outputs in research/ch15/results.json and related raw evidence. CLI defaults differ from the published 64-request, three-seed main experiment; reproduce that comparison with the explicit arguments documented below.

The rule this adds: a scheduler is judged by queueing and latency distributions, objective pass fraction and qualified throughput, at explicitly calibrated offered loads, with per-request output parity verified where practical. The present results show much lower TTFT for iteration-level scheduling on finite traces; they do not prove the same advantage under every load, kernel or policy.

What you should now be able to do

  • Describe static and continuous batching and say what changes between iterations.
  • Compute the useful fraction of decode slots in a static batch.
  • Define offered load relative to measured capacity 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 offered load; distinguish that fraction from goodput expressed as a rate.
  • Say what continuous batching costs in smoothness, and when chunked prefill is likely to repay its cost.
  • Explain how an admission policy moves waiting between classes, and what to measure to see it.
  • Find a non-terminating loop in a simulation with a watchdog traceback.

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_{\rm last}-t_{\rm 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

  1. 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.
  2. 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?
  3. Repeat loads with 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.
  4. Replace admission-time reservation with on-demand blocks and a tested watermark (PagedAttention). What changes in admission, preemption risk and achieved throughput?
  5. 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?
  6. 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.
  7. 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.
  8. 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

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