server: a control_vector request field, its admin switch and the Model-view panel

The field is per request, with the deployment's runtime default when absent, and a deployment with
no vector refuses 'true' by name rather than serving the stock model. Strata's
`experimental_speed_projection` is accepted as an alias.

The dashboard's Model view carries a "Control vectors" panel with the switch for that default;
GET/POST /admin/control-vector is its endpoint, behind the API key like every other route. The state
is in /stats and /server_info. Nothing here reloads the model: the directions are uploaded once and
each step carries a per-request mask.

The panel stays visible when the page has no API key, with the reason, instead of disappearing --
a control that vanishes because the page has not signed in reads exactly like a build without the
feature.
This commit is contained in:
C_Tamas authored and StillDeadcode committed 2026-10-21 09:26:17 +02:00
1 parent 66c6d71254
commit 6f26cdb5f4
7 files changed
+312 -3

No files matched your search

+12
View File
@@ -240,6 +240,7 @@ const char* kAcceptedCommon[] = {
"dry_sequence_breakers", "samplers",
"grammar", "json_schema", "priority", "logprobs", "ignore_eos",
"timings_per_token", "return_progress", "session_id", "n_probs",
"control_vector", "experimental_speed_projection",
};
const char* kAcceptedChat[] = {
@@ -842,6 +843,17 @@ static int parse_sampling(const json& b, const OaiLimits& lim, OaiRequest* r, Ap
/* ignore_eos: generate to max_tokens whatever the model emits. See Request::ignore_eos. */
if (!get_bool(b, "ignore_eos", &r->ignore_eos, err)) return RAD_E_INVAL;
/* The control vector (core/cvec.h): an opt-in per request, and the only place an API client
* turns it on when the deployment's default is off. `control_vector` is the field's name;
* `experimental_speed_projection` is Strata's spelling of the same switch, kept as an alias so
* a client written against that reports what it means. */
for (const char* key : { "control_vector", "experimental_speed_projection" }) {
if (!b.contains(key)) continue;
bool on = false;
if (!get_bool(b, key, &on, err)) return RAD_E_INVAL;
r->control_vector = on ? 1 : 0;
}
/* stop: a string or an array of strings. Bounded in count and length because every stop
* string is searched in each piece of generated text (by the decoder and the server's scan),
* so per-token cost is count x longest. OpenAI allows four; the bounds are far above that