- 523 µsaverage time to assemble a batch
- ~100%batch fill at the median, the ninetieth and the ninety-ninth percentile
- 4integers each GPU registers: batch size, tokens, input length, model
A batching broker is judged on its steady state, and its steady state is the easy part. The beginning and the end of a workload are where batches get small, caches get rebuilt and GPUs sit idle, and both needed their own mechanism.
The release gate
At the start of a run, items trickle in. A broker that dispatches the first trickle produces tiny batches and poor graph reuse, and the engine spends its first minutes doing badly what it could do well a moment later. So nothing is dispatched until staged and lane tokens together reach a release threshold.
Grey: staged and lane tokens building, nothing dispatched. Orange: the release threshold reached. Blue: dispatch from then on.
The backlog is already on disk, so the first batches can be full from the first tick.
Once open, the gate stays open for the life of the process; it is a start condition rather than a throttle.
Batches that fill to the budget
Packing follows the contract each GPU registered with. In memory mode the padded length of a batch is the longest item rounded up to eight tokens and the budget is counted in padded tokens; in disk mode it is counted in actual tokens. Input-length filtering was removed from the broker after it stranded items, and the runtime applies that limit itself. The ready-batch search scans lanes round-robin from the last lane served for an active lane holding at least the first consumer's batch size.
Each batch filled to its token budget before it reached its item count.
Work reclaimed from a dead consumer goes first, so recovered items are never starved behind new ones.
On a single host, no copies
For consumers on the same host, batches go through a shared-memory ring on two-megabyte huge pages rather than a socket: a lock-free allocator with cache-line alignment and a compare-and-exchange loop to claim space. Batches are offset-addressed with no pointers, written with alignment safe for ARM, and mapped read-only by the consumer.
Cleanup mode
At the end of a workload, staged shapes that never reached their activation threshold and lanes holding less than a full batch would otherwise sit forever.
Entries, duration, and batches and items dispatched in cleanup are metrics, so a run that spends too long in its tail is visible.
What this demonstrates
Engineering the edges of a workload as deliberately as its middle: a start condition that guarantees good first batches, packing measured against its own budget rather than its item count, and an end state that drains to zero rather than leaving a tail behind.
The gate, the packing rules and cleanup mode were my design; AI coding agents, a mix of frontier and open-source models, implemented them under my governance system.