core: only the package's layer range steers, and the table stays out of the budget

The loader stored a norm for every direction in the file, and the plugin declares
an op wherever a layer's scale is nonzero, so `layer_range` (4..44, the package's
own selection) reached only the range checks and the log line: the engine steered
all 47 directions -- 94 hc_project instances in the declared graph where the
sources and the docs say 41. The scale is zeroed outside the range now, which is
what RadControlVector documents ("a zero scale means this layer is not steered")
and what llama.cpp's patch does (its tensor is absent outside the range).
cvec_test asserts it for the default and for a JSON-stated range; --debug-graph
shows 41 a rank.

The direction table is also taken back out of the VRAM budget
(VramFacts::held_out). It is allocated in declare(), before vram_budget_resolve
reads free VRAM, so without the term the pools are planned around bytes the
program never sees. On this box the split came out identical either way
(claimable 12.92 GiB in both), so the term is a guarantee by construction rather
than a fix for an observed miss -- and it keeps a deployment that merely offers a
vector on the same plan as one that does not.
This commit is contained in:
C_Tamas authored and StillDeadcode committed 2026-10-21 09:26:17 +02:00
1 parent 071d204252
commit ad7c962375
5 files changed
+28 -6

No files matched your search

+4 -1
View File
@@ -254,7 +254,10 @@ int control_vector_load(const std::string& path, const std::string& arch, int64_
float* dst = &out->dir[(size_t) (l * n_embd)];
const float inv = (float) (1.0 / norm);
for (int64_t i = 0; i < n_embd; ++i) dst[i] = d[i] * inv;
out->scales[(size_t) l] = (float) norm * scale;
/* Zero outside the range: a layer is steered exactly when its scale is nonzero
* (abi/rad_builder.h, RadControlVector), and a file carries directions for layers the
* package's JSON leaves out. The row is kept so a range change needs no new upload. */
out->scales[(size_t) l] = (l >= first && l <= last) ? (float) norm * scale : 0.0f;
/* A layer inside the range with no direction would silently be unsteered. */
if (l >= first && l <= last) worst = std::max(worst, std::fabs(norm - 1.0));