Archived
sched: refuse a prompt id that names no vocabulary row
The scored-prompt path (Request::token_scores) has always vetted its ids against the
vocabulary; the prompt itself never was. Raw id arrays arrive at admission verbatim from
the request body -- /v1/completions, /v1/embeddings and the generator take them -- and an
id past the embedding table is gathered by the step, fails it, and a failed step is a
device fault (spec 17): one request, {"prompt":[2147483647]}, ended every session on the
server. The check belongs at admission, where a refusal is a 400, not mid-pass, where it
is an exit.
The sched fixture's model declares 512 vocabulary rows and its requests spell prompts
from 1000 up; admission now refuses those, so the fixture's vocabulary moves above the
ids it uses.
This commit is contained in:
1 parent
ed5f990d92
commit
a28221eb6a
2 files changed
+39
-1
No files matched your search
@@ -263,6 +263,17 @@ 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;
|
||||
/* 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) —
|
||||
* the whole engine would die for one bad number. Same bound as the scored-prompt check below.
|
||||
*/
|
||||
for (int32_t t : r->prompt)
|
||||
if (t < 0 || t >= prog_->meta.n_vocab) {
|
||||
RAD_WARN("request %llu refused: prompt token id %d is outside the vocabulary [0, %lld)",
|
||||
(unsigned long long)r->id, t, (long long)prog_->meta.n_vocab);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
/* Nor could a prompt the KV pool cannot hold even alone: admission takes only what the pool
|
||||
* holds, so it would wait at the head of the queue, and everything behind it, forever. The
|
||||
* prompt is the least a request needs: its first token comes from the prefill's last row.
|
||||
|
||||
Reference in new issue
Block a user