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:
C_Tamas authored and StillDeadcode committed 2026-10-21 09:26:17 +02:00
1 parent 64adee3ece
commit 459dd4f42d
14 files changed
+362 -11

No files matched your search

+13
View File
@@ -480,6 +480,19 @@ extern "C" int r4d_shape_hc_write(const RadParam* p, int n_p, int operand, RadOp
R4D_PICK(l);
}
/* hc_project's three: the bf16 stream (in place), the layer's unit f32 direction, and the int32
* per-row switch. The switch is an index domain: 0 or 1. */
extern "C" int r4d_shape_hc_project(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
const int64_t M = pi(p, n_p, "M"), n = pi(p, n_p, "n"), hc = pi(p, n_p, "hc");
const uint32_t D = dt_act(p, n_p, "dtype");
const RadOpdDesc l[] = {
opd(D, M, hc * n), /* h, in place */
opd((uint32_t) RAD_F32, n), /* v */
opd_idx(M, 1, 1, 0), /* on: 0 or 1 */
};
R4D_PICK(l);
}
/* hc_write's operands with the all-reduce in front; `y` is also the message. */
extern "C" int r4d_shape_ar_hc_write(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
return r4d_shape_hc_write(p, n_p, operand, out);