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

+23
View File
@@ -437,6 +437,7 @@ const std::map<std::string, std::vector<std::string>>& legal_values() {
{ "--num-speculative-tokens", { "2" } }, { "--draft-window", { "fixed" } },
{ "--host", { "127.0.0.1" } }, { "--port", { "8001" } }, { "--api-key", { "k" } },
{ "--served-model-name", { "m" } }, { "--mm-max-patches", { "1024" } },
{ "--control-vector", { "off" } },
{ "--generation-config", { "/g.json" } }, { "--override-chat-template", { "/t.jinja" } },
{ "--temp", { "0.7" } }, { "--top-k", { "40" } }, { "--top-p", { "0.9" } },
{ "--min-p", { "0.05" } }, { "--reasoning-effort", { "low" } },
@@ -603,6 +604,28 @@ TEST(the_placement_is_one_of_the_planners_four) {
}
}
/* Three states, and the absent one is the zero-cost default: off and on load the module, disabled --
* or no flag -- does not, so no projection op is declared. */
TEST(the_control_vector_flag_is_off_on_or_disabled) {
for (const char* ok : { "off", "on", "disabled" }) {
Config c;
CHECK_EQ(parse({ "--control-vector", ok }, &c), RAD_OK);
CHECK_EQ(c.control_vector, std::string(ok));
}
{
Config c;
CHECK_EQ(parse({}, &c), RAD_OK);
CHECK_EQ(c.control_vector, std::string("disabled"));
}
for (const char* bad : { "auto", "OFF", "", "1", "true" }) {
Config c;
int st = RAD_OK;
const std::string log = stderr_of([&] { st = parse({ "--control-vector", bad }, &c); });
CHECK_EQ(st, (int)RAD_E_INVAL);
CHECK(has(log, "--control-vector"));
}
}
TEST(the_wire_mode_is_one_of_two_names) {
Config c;
CHECK_EQ(parse({ "--tp-wire", "exact" }, &c), RAD_OK);