- 5states every prompt shape moves through
- 99.9%key-value hit rate in a five-minute two-GPU window
- 100batches: a shape that finishes sooner is flagged as thrashing
A shape, in my broker, is a set of prompts that share the same ordered prefixes, which is what makes them cacheable together on the GPU. Switching from one shape to another throws away the engine's prefix cache and may force a rebuild of its CUDA graphs. A broker that interleaves shapes freely therefore pays that price constantly, and the engine spends its time rebuilding rather than generating. So shapes in my broker have a lifecycle, and the lifecycle is a state machine with thresholds, not a heuristic.
Five states
A new shape is staged. Its items accumulate per signature, and nothing is dispatched, because opening lanes for a handful of items wastes structure the engine could use. Items that arrive for a shape that is already active are merged into its existing lanes one by one; an early version created a fresh shape object instead and orphaned the old lanes with their data.
Draining shapes never take new items, which is the invariant the whole design rests on.
Warming the next shape
The expensive moment is the switch, so the broker prepares for it. When an active shape's pending tokens drop below a pre-warm threshold, the broker picks the staged shape with the most tokens above the activation threshold and marks it warming. Only one shape warms at a time. Consumers receive a pre-warm signal naming the shape and lane, and can build the CUDA graphs for it ahead of time in a cache keyed by lane and shape epoch. Every packed batch carries its shape epoch and a homogeneous output-token limit, so the engine can size its key-value allocation for the batch before it arrives.
The thrashing alarm
A shape that finishes after fewer than a hundred batches did not run long enough to pay for its own switch. The broker logs that as a critical event and feeds a batches-per-shape histogram, so a workload whose shapes are too small to amortise shows up on the dashboard as a pattern rather than as mysteriously low throughput.
What the lifecycle replaced
The first design cut static lane boundaries from a per-shape token histogram: 512 piecewise bins, percentile splits with interpolation, gap detection over runs of empty bins. It worked and it was rigid; rolling lanes replaced the static boundaries, and the histogram survives as per-shape statistics copied onto the shape at activation. Lanes themselves are recycled when they stop earning their slot.
What this demonstrates
Treating the GPU's cache behaviour as a first-class scheduling constraint: the broker knows what a switch costs, stages work until the switch is worth it, prepares the engine before the switch happens, and reports when a workload defeats the design. The two-GPU result is told in From 44K to 163K tokens per second.
The lifecycle and its thresholds were my design; AI coding agents, a mix of frontier and open-source models, implemented them under my governance system.