- 4failed engine loads in a row, each one passing admission
- ~503 MiBthe CUDA context the admission arithmetic had left out
- 2,740MiB, the engine's whole allowance beside a 30B serving model
The tool-discovery engine lives on a GPU beside a 30-billion-parameter serving model, in a fixed allowance and no more. An admission check compares the engine's requirement with the card's free memory before anything is allocated, and refuses with the shortfall if it does not fit. That check once passed every time while the engine failed to load every time, and the card drained.
What went wrong
Engine creation allocated its buffers in sequence, and when a later allocation failed, the earlier ones were not freed before the error returned. Each retry therefore started with less free memory than the last, passed admission because the arithmetic looked only at the engine's own total, and failed further along. A larger serving model was sharing that card.
Four attempts, each stranding its partial buffers.
Every allocation before the failure is released before the error returns.
Three fixes
A failed load leaves the card as it found it.
Admission in the batched engine
The batched engine extends the same discipline to each request: admission reserves cache pages for the prompt and the maximum output before a sequence is admitted, and refuses with a typed reason when the pages are not there. The daemon's contract in Every request accounted for rests on that refusal being exact.
What this demonstrates
Memory discipline on shared hardware: a failure path that restores the state it found, an admission check that is proven to match the allocation it predicts, and the overhead the driver adds counted rather than assumed away.
The crash-safe rule and the mirrored arithmetic were my requirements; AI coding agents, a mix of frontier and open-source models, implemented and tested them under my governance system.