control vectors: load only when the deployment asks

The graph is declared once, so whether the projection op exists cannot follow a per-request
switch. It follows a startup flag instead:

  --control-vector off       load the vector found for this model, requests default off
  --control-vector on        the same, requests default on
  --control-vector disabled  load nothing (also the default with no flag)

`disabled` declares no op, so an unprojected request costs the stock model's launches rather
than 41 empty ones; a request that asks for the vector is refused by name and the admin route
answers 404. `off`/`on` keep the per-request switch and the dashboard default.

Measured four ways on one box (stock, disabled, off, on -- one boot each, six 4,096-token answers,
speculation off): decode 85.1 / 86.1 / 83.7 / 82.8 tok/s. `disabled` is the stock graph, so there
is nothing to pay; `off` pays the 41 launches, `on` pays the projection. KLD mode serves no
request to carry the switch, so `--control-vector on` is how the projection itself is scored;
config_test covers the three states and the absent default.
This commit is contained in:
C_Tamas authored and StillDeadcode committed 2026-10-21 09:26:17 +02:00
1 parent b15cbb546d
commit f9d80d6cac
6 files changed
+89 -20

No files matched your search

+14
View File
@@ -123,6 +123,11 @@ static const Flag g_flags[] = {
" adapters target. Needed with --max-loras and no --lora"},
{ "--placement", "MODE", "all_vram | layer_offload | expert_tiered | auto" },
{ "--control-vector", "MODE", "off | on | disabled: load the control-vector file found\n"
" for this model and start requests off (off) or on (on).\n"
" disabled -- the default, also with no flag at all -- loads\n"
" nothing: no projection op is declared, and a request that\n"
" asks for the vector is refused" },
{ "--deterministic", nullptr, "pin placement to the plan the loader made, so the resident\n"
" set cannot change under the heat engine. The sampler is\n"
" already order-independent and needs no pinning; note that\n"
@@ -578,6 +583,14 @@ int config_parse(int argc, char** argv, Config* c) {
}
c->placement = v;
}
else if (S("--control-vector")) {
if (!(v = need(i))) return RAD_E_INVAL;
if (std::strcmp(v, "off") && std::strcmp(v, "on") && std::strcmp(v, "disabled")) {
RAD_ERR("--control-vector takes off, on or disabled -- got '%s'", v);
return RAD_E_INVAL;
}
c->control_vector = v;
}
else if (S("--deterministic")) c->deterministic = true;
else if (S("--checkpoint-interval")) { if (!num(0, INT64_MAX, &c->checkpoint_interval)) return RAD_E_INVAL; }
else if (S("--prefill-span")) { if (!num(1, INT32_MAX, &c->prefill_span)) return RAD_E_INVAL; }
@@ -1036,6 +1049,7 @@ const ShowRow kShow[] = {
for (const std::string& t : c.lora.targets) o += (o.empty() ? "" : ",") + t;
return o.empty() ? std::string(c.lora.enabled() ? "the adapters' own" : "-") : o; } },
{ "--placement", [](const Config& c) { return c.placement; } },
{ "--control-vector", [](const Config& c) { return c.control_vector; } },
{ "--deterministic", [](const Config& c) { return onoff(c.deterministic); } },
{ "--checkpoint-interval", [](const Config& c) { return num(c.checkpoint_interval); } },
{ "--prefill-span", [](const Config& c) { return num(c.prefill_span); } },