Archived
vocabulary: hc_project -- a control vector's direction, projected out of the wide stream
h[s] -= scale * (h[s] . v) * v for each of the hyper-connection streams s llama.cpp's --cvec-mode project semantics: the dot is per stream, because the patch applies it to the [n_embd, hc, tokens] view where mul_mat(v, cur) reduces over dim 0. v is one layer's unit direction (f32), scale is the norm its file stored, and 'on' is a per-row int32 switch: a zero row is skipped without a read or a write, so an unprojected request is byte-identical to a deployment with no vector loaded. libref is the oracle and the host fallback, libavx carries it at every ISA level, libr4d (one workgroup per (row, stream), LDS reduction) serves the card. docs/OPS.md gains the row and the operation's three facts.
This commit is contained in:
1 parent
64adee3ece
commit
459dd4f42d
14 files changed
+362
-11
No files matched your search
@@ -118,6 +118,12 @@ 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
|
||||
* 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"),
|
||||
P_STR("dtype") };
|
||||
static const RadOperandSpec oHcProject[] = { INOUT("h"), OPD("v"), OPD("on") };
|
||||
static const RadOperandSpec oHcEnter[] = { OPD("x"), OUT("h") };
|
||||
static const RadOperandSpec oHcWrite[] = { OPD("y"), OPD("inj"), INOUT("h") };
|
||||
static const RadParamSpec pMhcPre[] = { P_INT("M"), P_INT("n"), P_INT("hc"),
|
||||
@@ -1003,6 +1009,12 @@ static const RadOpSchema kSchemas[] = {
|
||||
{ "hc_write", ARR(pHcWrite), ARR(oHcWrite),
|
||||
"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 "
|
||||
"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 "
|
||||
"a deployment with no vector loaded." },
|
||||
{ "mtp_enter", ARR(pMtpEnter), ARR(oMtpEnter),
|
||||
"The MTP head's entry for a wide residual stream: x[k*n+i] = fc_h[i] . grouped_norm(h)[k] "
|
||||
"+ fc_e[i] . norm(e), for each of the hc sub-streams k. `ngroup` == hc is one rsqrt per "
|
||||
@@ -1957,6 +1969,9 @@ ROWL("ref_mtp_enter", "mtp_enter", "norm",
|
||||
ref_check_dtypes, ref_mtp_enter, ref::ref_layout_mtp),
|
||||
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",
|
||||
DT_FLOAT, ref_hc_project),
|
||||
SIMPLE("ref_layernorm", "layernorm", "norm", "layer norm with gain and bias", DT_FLOAT,
|
||||
ref_layernorm),
|
||||
SIMPLE("ref_grid_embed", "grid_embed", "elem",
|
||||
|
||||
Reference in new issue
Block a user