sched: an over-cap request would stall every queue behind it

A plugin that declared plugin_words gets a fixed carrier in the batch --
[max_seqs * plugin_words] rows, carved only because the program said how
many words a sequence may carry. The build stage already refuses a
sequence past that bound, but nothing at admission did, and a refused
build restages its step forever: one request carrying more words than the
plugin declared stalls every queue behind it, permanently.

add_locked now reads the same bound the batch carves by (BatchBuilder::
plugin_words_cap, the program's declaration) and refuses an over-cap
request with RAD_E_INVAL, where the server turns it into a clean 400.
The current route caps its own words already; this is the promise no
future route can miss, checked once at the gate every request passes.
This commit is contained in:
fl0l0u committed 2026-11-15 20:38:09 +00:00
1 parent 981cd1e4e1
commit b44f7a9bb1
2 files changed
+11

No files matched your search

+7
View File
@@ -388,6 +388,13 @@ int Scheduler::add_locked(std::unique_ptr<Request> r) {
/* An embedding input runs in one step or not at all (Request::embed); one longer than a step
* could never be admitted. */
if (r->embed && (int64_t)r->prompt.size() > cfg_.max_tok) return RAD_E_INVAL;
/* The words a request hands the plugin are bounded by the plugin's declaration. The batch
* stage refuses a sequence past it, and a refused build restages the step forever -- an
* over-cap request admitted here would stall every queue behind it. The server-side route
* caps its own words; this is the promise no future route can miss. */
if (!r->plugin_words.empty() &&
(int64_t)r->plugin_words.size() > builder_.plugin_words_cap())
return RAD_E_INVAL;
/* Every prompt id, tokenised or client-supplied, names a real vocabulary row: an id past the
* embedding table is refused at admission, never staged into a pass. Raw id arrays reach here
* straight from the request body, and an op failing mid-step is a device fault (spec §17) --