continuous-batching -- refill the slot the moment a sequence stops

A busy server answers many people at once by working on a group of requests together, producing one word for each of them per pass over the model. The simple version fixes that group at the start and holds every place in it until the slowest reply is finished, so a request that stopped after ten words keeps its seat warm while a neighbour writes a thousand. Refilling each place the instant it frees lets someone waiting in the queue start immediately, which keeps the hardware busy and shortens how long people wait to be served. It makes no single reply arrive faster — it makes far more of them happen at the same time.

Interactive page: how a serving runtime schedules a batch of generation requests, and why it admits a waiting request the instant a slot frees instead of at the end of the batch. Anchor: A4 KV cache / runtime shape (Family J, serving time). Companion to prefill-vs-decode, which shows the two regimes this page schedules, and kv-cache, which shows what a slot actually holds.

What it shows

Two Gantt charts of the same workload -- same arrivals, same output lengths, same number of batch slots -- sharing one x axis (x = decode step, y = batch slot, one coloured bar per request):

Three counters recompute live for each scheduler: steps to drain the queue, slot utilisation (busy slot-steps ÷ slots × steps) and per-request latency split into wait + generate. A queue-depth strip under each timeline shows the backlog draining, and a per-request latency strip at the bottom makes the honest tradeoff visible: the generate segment is identical under both schedulers. Continuous batching buys throughput and queueing delay -- it does not make any single sequence produce one token faster.

The schedules are really simulated in-page from the request list, so every number in the readout and every tooltip is derived, not annotated.

Press play (or scrub) and both schedulers advance together, so the step where they diverge is visible; drag any bar sideways to restretch that request's output length -- one long sequence is ruinous on the static timeline and nearly free on the continuous one; hover a bar for its arrival / wait / output length / occupied steps, or a hatched cell for which sequence that slot is waiting on.

Render tier

T1 (Canvas2D throughout -- the lesson is schedule geometry, not pixel scale).

Wiring

layout.mount + controls (slots, nreq, gap, seed, and a lens free-text field holding per-request output-length overrides) + a max(makespan)-step Transport that both timelines read, onPointer bar-drag for the output length, hover-to-inspect, two challenges, and an A/B compare over batch-slot count. URL hooks: ?step, ?slots, ?nreq, ?gap, ?seed, ?lens=id:len,id:len (the headless stand-in for a drag), ?hover=x,y. Source: page.js.