Archived
naming: comments and log lines say control vector, not speed projection
This commit is contained in:
1 parent
3e9e0f4d03
commit
40f7390766
13 files changed
+19
-19
No files matched your search
+1
-1
@@ -174,7 +174,7 @@ typedef struct RadBuildCtx {
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
int kv_quant;
|
||||
|
||||
/* A control vector loaded from a GGUF `controlvector` file (--speed-projection), or null.
|
||||
/* A control vector loaded from a GGUF `controlvector` file found for this model, or null.
|
||||
*
|
||||
* The engine loads and validates it once, at bringup, and the plugin only reads it: the
|
||||
* direction table lives in device memory on every rank, in the activations' own float form,
|
||||
|
||||
+2
-2
@@ -284,7 +284,7 @@ const float* control_vector_upload(const ControlVector& cv, int rank) {
|
||||
const int64_t bytes = (int64_t) cv.dir.size() * 4;
|
||||
void* d = rad_dev_alloc(bytes, RAD_MEM_DEVICE);
|
||||
if (!d) {
|
||||
RAD_ERR("speed projection: rank %d: could not allocate %.2f MiB on the card for the "
|
||||
RAD_ERR("control vector: rank %d: could not allocate %.2f MiB on the card for the "
|
||||
"directions", rank, (double) bytes / (1024.0 * 1024.0));
|
||||
return nullptr;
|
||||
}
|
||||
@@ -297,7 +297,7 @@ const float* control_vector_upload(const ControlVector& cv, int rank) {
|
||||
rad_stream_sync(s);
|
||||
rad_stream_destroy(s);
|
||||
if (rc < 0) {
|
||||
RAD_ERR("speed projection: rank %d: uploading the directions failed: %s", rank,
|
||||
RAD_ERR("control vector: rank %d: uploading the directions failed: %s", rank,
|
||||
rad_dev_last_error());
|
||||
rad_dev_free(d, RAD_MEM_DEVICE);
|
||||
return nullptr;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* cvec.h -- the experimental speed projection: a GGUF control vector on the residual stream.
|
||||
/* cvec.h -- control vectors: one GGUF direction per layer, projected out of the residual stream.
|
||||
*
|
||||
* ============================== what it is ==============================
|
||||
*
|
||||
|
||||
+2
-2
@@ -1633,7 +1633,7 @@ bool Engine::state_slots_of(uint64_t seq, std::vector<int32_t>* out) const {
|
||||
/* The engine's part of /server_info: model, cards, KV, drafting and wire, for a running process.
|
||||
* The server holds only interfaces, so the engine renders this object and the server splices it in
|
||||
* verbatim. */
|
||||
/* The experimental speed projection, for /stats, /v1/models and /server_info. `available` is
|
||||
/* The control vector, for /stats and /server_info. `available` is
|
||||
* what a client should test before sending the field: without a loaded vector a request that asks
|
||||
* for it is refused, so a UI can hide the control rather than offer a switch that fails. */
|
||||
std::string Engine::cvec_json() const {
|
||||
@@ -2030,7 +2030,7 @@ int Engine::run_server() {
|
||||
d.tok = &tok_bridge;
|
||||
d.grammar = &grammar_bridge;
|
||||
d.live = snap;
|
||||
/* The experimental speed projection, when a vector was loaded. The admin endpoint flips the
|
||||
/* The control vector, when one was found. The admin endpoint flips the
|
||||
* default through this; nothing rebuilds a graph, so a toggle takes effect on the next request
|
||||
* and leaves the running ones alone. */
|
||||
if (cvec_.loaded()) {
|
||||
|
||||
+1
-1
@@ -483,7 +483,7 @@ private:
|
||||
bool has_ngram_ = false; /* the model carries an n-gram table */
|
||||
std::string prefix_off_why_; /* why the engine itself turned prefix caching off, or "" */
|
||||
|
||||
/* ---- the experimental speed projection (core/cvec.h). `cvec_` is the host table, loaded
|
||||
/* ---- control vectors (core/cvec.h). `cvec_` is the host table, loaded
|
||||
* once at bringup and empty when the feature is off; `cvec_views_` is, per rank, that table
|
||||
* uploaded to the rank's card and the ABI view build_ctx hands to a declaring plugin (the
|
||||
* view's `dir` is the allocation, so one vector holds both). `cvec_salt_` partitions the
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ struct OaiRequest {
|
||||
|
||||
int n = 1;
|
||||
SamplingParams sp;
|
||||
/* The experimental speed projection, tri-state: -1 the request named no choice (the engine's
|
||||
/* The control vector, tri-state: -1 the request named no choice (the deployment's
|
||||
* runtime default applies), 0 it asked for the stock model, 1 for the loaded control vector.
|
||||
* Parsed from `control_vector` (or Strata's `experimental_speed_projection`); a deployment
|
||||
* with no vector refuses 1 rather than silently serving the stock model. */
|
||||
|
||||
+1
-1
@@ -332,7 +332,7 @@ AVX_KERNEL(hc_write) {
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ hc_project */
|
||||
/* The experimental speed projection (core/cvec.h): h[s] -= scale * (h[s] . v) * v for each of the
|
||||
/* The control vector's projection (core/cvec.h): h[s] -= scale * (h[s] . v) * v for each of the
|
||||
* hc streams of a row whose switch is on. v is f32, the stream may be bf16/f16/f32; a row with a
|
||||
* zero switch is skipped without a read, so an unprojected request is byte-identical to one on a
|
||||
* deployment with no vector. */
|
||||
|
||||
@@ -114,7 +114,7 @@ static const RadOperandSpec oCausalConv[] = { OPD("x"), WGT("w"), INOUT("conv_st
|
||||
static const RadParamSpec pHcWrite[] = { P_INT("M"), P_INT("n"), P_INT("hc"), P_STR("dtype") };
|
||||
static const RadOperandSpec oHcEnter[] = { OPD("x"), OUT("h") };
|
||||
static const RadOperandSpec oHcWrite[] = { OPD("y"), OPD("inj"), INOUT("h") };
|
||||
/* The speed projection: one unit direction per layer (f32) and an int32 per-row switch. */
|
||||
/* The control vector's projection: one unit direction per layer (f32) and an int32 per-row switch. */
|
||||
static const RadParamSpec pHcProject[] = { P_INT("M"), P_INT("n"), P_INT("hc"), P_F64("scale"),
|
||||
P_STR("dtype") };
|
||||
static const RadOperandSpec oHcProject[] = { INOUT("h"), OPD("v"), OPD("on") };
|
||||
@@ -831,7 +831,7 @@ static const RadOpSchema kSchemas[] = {
|
||||
"format; a host kernel reads them as the dense tensors it is handed." },
|
||||
{ "hc_write", ARR(pHcWrite), ARR(oHcWrite), "h[s] += inj[s] * y, into the unnormed stream." },
|
||||
{ "hc_project", ARR(pHcProject), ARR(oHcProject),
|
||||
"The experimental speed projection (llama.cpp's `--cvec-mode project`): h[s] -= scale * "
|
||||
"The control vector's projection (llama.cpp's `--cvec-mode project`): h[s] -= scale * "
|
||||
"(h[s] . v) * v for each of the hc streams of a row whose flag is on. A zero flag is not read." },
|
||||
{ "mtp_enter", ARR(pMtpEnter), ARR(oMtpEnter),
|
||||
"MTP head entry: two norms, a per-sub-stream fc and a broadcast fc. `fc` names the two "
|
||||
@@ -1370,7 +1370,7 @@ ROWL("avx_hc_read", "hc_read", "norm",
|
||||
SIMPLE("avx_hc_write", "hc_write", "norm", "gated residual write: h[s] += inj[s] * y", DT_FLOAT,
|
||||
L(hc_write)),
|
||||
SIMPLE("avx_hc_project", "hc_project", "norm",
|
||||
"speed projection: h[s] -= scale * (h[s] . v) * v where the row's flag is on", DT_FLOAT,
|
||||
"control vector: h[s] -= scale * (h[s] . v) * v where the row's flag is on", DT_FLOAT,
|
||||
L(hc_project)),
|
||||
ROWL("avx_mtp_enter", "mtp_enter", "norm",
|
||||
"MTP head entry: two norms, a per-sub-stream fc and a broadcast fc",
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ int ref_hc_write(const RadArgs* a, RadStream) {
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ hc_project */
|
||||
/* The experimental speed projection: h[row, s*n + i] -= scale * (h . v) * v, for each of the hc
|
||||
/* The control vector's projection: h[row, s*n + i] -= scale * (h . v) * v, for each of the hc
|
||||
* streams s, on the rows whose `on` flag is 1.
|
||||
*
|
||||
* `v` is one layer's unit direction (the engine normalises the file's rows when it uploads them)
|
||||
|
||||
@@ -118,7 +118,7 @@ static const RadOperandSpec oCausalConv[] = { OPD("x"), WGT("w"), INOUT("conv_st
|
||||
OPD_O("num_accepted"), OUT("y") };
|
||||
|
||||
static const RadParamSpec pHcWrite[] = { P_INT("M"), P_INT("n"), P_INT("hc"), P_STR("dtype") };
|
||||
/* The speed projection (libref/ref_hc.cpp, core/cvec.h): one unit direction per layer and a
|
||||
/* The control vector's projection (libref/ref_hc.cpp, core/cvec.h): one unit direction per layer and a
|
||||
* per-row switch. `v` is f32 whatever the stream's dtype is, because the engine uploads the table
|
||||
* in f32; `on` is an int32 row mask (core derive.cpp's `projection_on_rows`). */
|
||||
static const RadParamSpec pHcProject[] = { P_INT("M"), P_INT("n"), P_INT("hc"), P_F64("scale"),
|
||||
@@ -1010,7 +1010,7 @@ static const RadOpSchema kSchemas[] = {
|
||||
"The write half: h[s] += inj[s] * y, for each of the hc streams of h. In place, and `h` is the "
|
||||
"UNNORMED stream the paired hc_read was handed -- the normalisation never enters the residual." },
|
||||
{ "hc_project", ARR(pHcProject), ARR(oHcProject),
|
||||
"The experimental speed projection (llama.cpp's `--cvec-mode project`): for each of the hc "
|
||||
"The control vector's projection (llama.cpp's `--cvec-mode project`): for each of the hc "
|
||||
"streams of a row whose `on` flag is 1, h[s] -= scale * (h[s] . v) * v, with v that layer's unit "
|
||||
"direction and scale the norm the file stored. The dot is per stream, not on the stream mean. A "
|
||||
"row whose flag is 0 is not read and not written, so an unprojected request is byte-identical to "
|
||||
@@ -1970,7 +1970,7 @@ ROWL("ref_mtp_enter", "mtp_enter", "norm",
|
||||
SIMPLE("ref_hc_write", "hc_write", "norm", "gated residual write: h[s] += inj[s] * y",
|
||||
DT_FLOAT, ref_hc_write),
|
||||
SIMPLE("ref_hc_project", "hc_project", "norm",
|
||||
"speed projection: h[s] -= scale * (h[s] . v) * v where the row's flag is on",
|
||||
"control vector: h[s] -= scale * (h[s] . v) * v where the row's flag is on",
|
||||
DT_FLOAT, ref_hc_project),
|
||||
SIMPLE("ref_layernorm", "layernorm", "norm", "layer norm with gain and bias", DT_FLOAT,
|
||||
ref_layernorm),
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* cvec_test.cpp -- the experimental speed projection's loader (core/cvec.h).
|
||||
/* cvec_test.cpp -- the control vector's loader (core/cvec.h).
|
||||
*
|
||||
* The vector is the published package's format: a GGUF `controlvector` with one unit f32
|
||||
* `direction.<l>` per layer and three metadata keys. These cases write such a file, then check
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* projection_test.cpp -- the per-request switch that feeds the speed projection.
|
||||
/* projection_test.cpp -- the per-request switch that feeds the control vector.
|
||||
*
|
||||
* Two halves, both host-side:
|
||||
*
|
||||
|
||||
@@ -4523,7 +4523,7 @@ int status_with(Fixture& f, const std::string& ep, const std::string& key, const
|
||||
|
||||
} /* namespace */
|
||||
|
||||
/* The experimental speed projection: absent, the engine's default applies; an explicit `true` on a
|
||||
/* The control vector: absent, the deployment's default applies; an explicit `true` on a
|
||||
* deployment with no vector is refused by name (serving the stock model while the client believes
|
||||
* otherwise would be a silent lie), and on one with a vector it reaches the engine's request. */
|
||||
TEST(the_control_vector_field_overrides_the_default_or_is_refused) {
|
||||
|
||||
Reference in new issue
Block a user