The scheduler decides at every step, which sequences run and which wait; based on this the throughput, tail latency, and fairness are actually determined.

The step loop

while True:
    finished = reap(running)                          # 1. free KV blocks of done sequences
    admitted = admit(waiting, kv_budget, tok_budget)  # 2. pull in new work if it fits
    batch    = running + admitted                     # 3. mix prefill + decode in one batch
    logits   = model.step(batch)                      # 4. one forward pass
    running  = sample_and_append(batch, logits)       # 5. each sequence gets 1 new token
    if kv_free < watermark:                           # 6. out of memory headroom?
        preempt(running, policy)                      #    → evict something

A new request is admitted only if it fits both:

= sequence length as KV usage grows as sequences get longer Watermark = safety buffer that allows running sequences to keep growing without immediatly triggering preemption

Chunked Prefill

Preemption: swap vs recompute

When you run out of KV memory, there are two options:

  • Swap: copy KV to CPU Memory and back later
  • Recompute: drop KV and re-run prefill later

Because both scale linearly with , the choice is length-independent.

In general, swapping is better when:

  • you have a fast D2D fabric (higher bandwidth than PCIe)
  • When the prefix is significantly cached (recomputing it would be a lot of extra work)

In general, the choice on which sequence to evict is usually just based on the most recently arrived one (LIFO), as it has the least progress so far, so the least amount of work is lost.

Backpressure

The queue is the only unbounded term in end-to-end latency.

  • Cap queue depth.
  • admission-time SLO check: reject if
  • propagate the signal upstream so the load balancer stops sending, and to the Autoscaler.

Estimated wait time .

Priority and fairness

  • FCFS maximizes throughput but is unfair to short requests if it gets stuck behind a long one. Practical policies:
  • Shortest-remaining-first (by predicted output length) minimizes mean latency, starves long generations: needs aging.
  • Multi-level / weighted fair queueing per tenant with a token-bucket rate limit, so one tenant cannot consume the KV budget.
  • Priority classes (interactive vs batch) with batch admitted only from spare token budget.
  • Route on cache locality where possible (KV Cache-Aware Routing, Prefix Caching). A hit skips prefill entirely.