feat(experimental-ref): keyless routing, control vectors and attention references; emulated kernel scenarios

keyless.rs: SKLROUT1 artifact admission (layout cross-read against prepare-keyless-routing.py),
fmaf-order query routing, positional key reconstruction. cvec.rs: GGUF v3 parsing and the
load_control_vectors table builder (19 golden cases incl. the Original's error texts,
bit-exact, from the Original function extracted verbatim) and a reduction-tree twin of
cvec_kernel. attn.rs: scratch arithmetic and an f64 GQA reference. The emulated kernel
text reproduces routing and cvec bit for bit and attention modes 2/3/4 (incl. M-RoPE) to
1.6e-7 relative L2.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-10-14 15:31:44 +02:00
co-authored by Claude Sonnet 5.5
parent 1d1f5bfc14
commit 7bd31abdb2
11 changed files with 2056 additions and 50 deletions
@@ -264,6 +264,209 @@ Json scenario_stream() {
j.num("final_reset_state_fnv", (long long) state_hash(m, 0));
return j;
}
// ------------------------------------------------------------------------------------ keyless routing
// matrices[(h*256+d)*256+j] = (d==j ? .8f : 0.f) + (float)(((h*19+d*3+j*11)%17)-8) * .001f (mirrored in Rust)
std::vector<float> routing_matrices(int heads) {
std::vector<float> m((size_t) heads * 256 * 256);
for (int h = 0; h < heads; ++h)
for (int d = 0; d < 256; ++d)
for (int j = 0; j < 256; ++j)
m[((size_t) h * 256 + d) * 256 + j] = (d == j ? .8f : 0.f) + (float) (((h * 19 + d * 3 + j * 11) % 17) - 8) * .001f;
return m;
}
Json scenario_route() {
const int tokens = 3, heads = 3;
const auto m = routing_matrices(heads);
Lcg g(61);
std::vector<float> q((size_t) tokens * heads * 256);
for (auto& x : q) x = g.soft();
std::vector<float> out = q;
emu_launch(dim3(tokens * heads), dim3(256), [&] { leleka_keyless_route_query(out.data(), m.data(), heads); });
Json j;
j.num("tokens", tokens); j.num("heads", heads);
j.hex("routed", out);
return j;
}
// ---------------------------------------------------------------------------------------- control vector
Json scenario_cvec() {
const int n = 300, hc = 3, T = 2, L = 4, layer = 2;
Lcg g(71);
std::vector<float> v(n);
for (auto& x : v) x = g.soft();
double nrm = 0;
for (float x : v) nrm += (double) x * x;
nrm = std::sqrt(nrm);
std::vector<float> unit(n);
for (int j = 0; j < n; ++j) unit[j] = (float) (v[j] / nrm);
const size_t r_ld = (size_t) hc * n;
std::vector<float> R0((size_t) T * r_ld), bo((size_t) T * n), inj((size_t) T * hc);
for (auto& x : R0) x = g.soft() * 3.0f;
for (auto& x : bo) x = g.soft();
for (auto& x : inj) x = g.soft();
Json j;
j.num("n", n); j.num("hc", hc); j.num("T", T); j.num("layer", layer); j.num("L", L);
j.hex("unit", unit); j.hex("add_dir", v); j.hex("r0", R0); j.hex("bo", bo); j.hex("inj", inj);
auto run = [&](const char* name, int mode, const std::vector<float>& dirv, float s_val, int layer_used, bool on, bool write) {
std::vector<float> dir((size_t) L * n, 0.0f), s(L, 0.0f);
std::copy(dirv.begin(), dirv.end(), dir.begin() + (size_t) layer * n);
s[layer] = s_val;
int on_flag = on ? 1 : 0;
std::vector<float> R = R0;
emu_launch(dim3(hc, T), dim3(256), [&] {
leleka_cvec_apply(R.data(), dir.data(), s.data(), &on_flag, mode, layer_used, n, hc, (long long) r_ld,
write ? bo.data() : nullptr, n, write ? inj.data() : nullptr, hc, write ? 1 : 0);
});
j.hex(name, R);
};
run("project_s1", 0, unit, 1.0f, layer, true, false);
run("project_s2", 0, unit, 2.0f, layer, true, false);
run("add", 1, v, 1.0f, layer, true, false);
run("off", 0, unit, 1.0f, layer, false, false);
run("off_write", 0, unit, 1.0f, layer, false, true);
run("project_write", 0, unit, 1.0f, layer, true, true);
run("add_write", 1, v, 1.0f, layer, true, true);
run("no_direction_layer", 0, unit, 1.0f, 1, true, false);
return j;
}
// ------------------------------------------------------------------------------------------ attention
constexpr int ATT_CELLS = 70, ATT_CAP = 70, ATT_NCHUNKS = 2, ATT_NQ = 2, NH = 24;
uint64_t scratch_floats() { return (uint64_t) ATT_NCHUNKS * NH * (HD + 2) + 64; }
struct AttnRun { std::vector<float> out; };
// chunk kernel then merge, for ATT_NQ queries with per-query selections
template <class ChunkFn>
std::vector<float> run_attention(const std::vector<int32_t>& ids, const std::vector<int32_t>& steps, int n_q, ChunkFn chunk) {
const long long stride = (long long) scratch_floats();
std::vector<float> scratch((size_t) stride * n_q, 0.0f), out((size_t) n_q * NH * HD, 0.0f);
float* part_acc = scratch.data();
float* part_m = part_acc + (size_t) ATT_NCHUNKS * NH * HD;
float* part_l = part_m + (size_t) ATT_NCHUNKS * NH;
emu_launch(dim3(ATT_NCHUNKS, HEADS, n_q), dim3(256), [&] { chunk(part_acc, part_m, part_l, stride); });
emu_launch(dim3(NH, n_q), dim3(256), [&] { leleka_qsa_attn_merge(part_acc, part_m, part_l, ATT_NCHUNKS, out.data(), stride); });
return out;
}
std::vector<int32_t> att_table() { // permutation of the 18 pages
std::vector<int32_t> t(18);
for (int i = 0; i < 18; ++i) t[i] = (i * 5 + 3) % 18;
return t;
}
Json scenario_attention() {
Json root;
const auto table = att_table();
const int pages = 18;
const size_t rows = (size_t) pages * HEADS * PAGE;
Lcg g(81);
std::vector<std::vector<float>> kc, vc;
for (int c = 0; c < ATT_CELLS; ++c) {
std::vector<float> k(512), v(512);
for (auto& x : k) x = g.soft() * 1.5f;
for (auto& x : v) x = g.soft() * 1.5f;
kc.push_back(k); vc.push_back(v);
}
std::vector<float> q((size_t) ATT_NQ * NH * HD);
for (auto& x : q) x = g.soft();
root.num("input_fnv", (long long) (fnv_vec(q) ^ (fnv_vec(kc[0]) * 3) ^ (fnv_vec(vc[ATT_CELLS - 1]) * 5)));
// selections: query 0 attends cells 0..69, query 1 cells 0..65
std::vector<int32_t> ids((size_t) ATT_NQ * ATT_CAP, 0), steps((size_t) ATT_NQ * 4, 0);
for (int i = 0; i < ATT_CELLS; ++i) ids[i] = i;
for (int i = 0; i < 66; ++i) ids[ATT_CAP + i] = i;
steps[3] = ATT_CELLS; steps[4 + 3] = 66;
auto append_q4 = [&](std::vector<uint8_t>& kp, std::vector<uint8_t>& vp, const std::vector<float>& k, const std::vector<float>& v, int pos) {
const std::vector<int32_t> step = {pos, pos + 1, (pos + 1) / 4, 0};
emu_launch(dim3(HEADS, HD / 32, 2), dim3(32), [&] {
leleka_kv_append_q4_step(kp.data(), vp.data(), table.data(), step.data(), k.data(), v.data(), HEADS, HD, PAGE, nullptr, nullptr);
});
};
// ---- mode 2: Q4_0 K and V (rotated), rotated query, output in the rotated domain
{
std::vector<uint8_t> kp(rows * ROW_Q4), vp(rows * ROW_Q4);
for (int c = 0; c < ATT_CELLS; ++c) append_q4(kp, vp, rotate(kc[c]), rotate(vc[c]), c);
const auto qr = rotate(q);
const auto out = run_attention(ids, steps, ATT_NQ, [&](float* pa, float* pm, float* pl, long long stride) {
leleka_qsa_attn_chunk_m2(qr.data(), kp.data(), vp.data(), table.data(), ids.data(), steps.data(), HEADS, PAGE, pa, pm, pl, ATT_NCHUNKS, ATT_CAP, stride);
});
Json j; j.hex("out", out);
root.obj("m2", j);
}
// ---- mode 3: INT8 K (unrotated), Q4_0 V (rotated), unrotated query, rotated output
{
std::vector<int8_t> kq(rows * HD);
std::vector<uint16_t> ks(rows * 4);
std::vector<uint8_t> v4(rows * ROW_Q4);
for (int c = 0; c < ATT_CELLS; ++c) {
const std::vector<int32_t> step = {c, c + 1, (c + 1) / 4, 0};
emu_launch(dim3(HEADS, HD / 64, 2), dim3(64), [&] {
leleka_kv_append_q8_step(kq.data(), kq.data(), ks.data(), ks.data(), table.data(), step.data(), kc[c].data(), kc[c].data(), HEADS, HD, PAGE, nullptr, nullptr, nullptr, nullptr);
});
const auto vr = rotate(vc[c]);
emu_launch(dim3(HEADS, HD / 32, 2), dim3(32), [&] {
leleka_kv_append_q4_step(v4.data(), v4.data(), table.data(), step.data(), vr.data(), vr.data(), HEADS, HD, PAGE, nullptr, nullptr);
});
}
const auto out = run_attention(ids, steps, ATT_NQ, [&](float* pa, float* pm, float* pl, long long stride) {
leleka_qsa_attn_chunk_m3(q.data(), kq.data(), ks.data(), v4.data(), table.data(), ids.data(), steps.data(), HEADS, PAGE, pa, pm, pl, ATT_NCHUNKS, ATT_CAP, stride);
});
Json j; j.hex("out", out);
root.obj("m3", j);
}
// ---- mode 4: V-only INT8, routed + position-encoded queries, keys rebuilt from V by position
{
std::vector<int8_t> vq(rows * HD);
std::vector<uint16_t> vs(rows * 4);
for (int c = 0; c < ATT_CELLS; ++c) {
const std::vector<int32_t> step = {c, c + 1, (c + 1) / 4, 0};
emu_launch(dim3(HEADS, HD / 64, 1), dim3(64), [&] {
leleka_kv_append_q8_step(nullptr, vq.data(), nullptr, vs.data(), table.data(), step.data(), kc[c].data(), vc[c].data(), HEADS, HD, PAGE, nullptr, nullptr, nullptr, nullptr);
});
}
// rope tables [position][32] from double math
std::vector<float> co((size_t) ATT_CELLS * 32), si((size_t) ATT_CELLS * 32);
for (int p = 0; p < ATT_CELLS; ++p)
for (int d = 0; d < 32; ++d) {
const double angle = p * std::pow(1e7, -2.0 * d / 64);
co[(size_t) p * 32 + d] = (float) std::cos(angle);
si[(size_t) p * 32 + d] = (float) std::sin(angle);
}
std::vector<int32_t> mpos((size_t) ATT_CELLS * 3);
for (int cell = 0; cell < ATT_CELLS; ++cell) for (int sector = 0; sector < 3; ++sector) mpos[cell * 3 + sector] = cell / (sector + 2);
root.hex("cos", co); root.hex("sin", si);
const auto matrices = routing_matrices(NH);
// per-query positions and selections (cells with cell % 3 != 1 up to the position)
const int qpos[ATT_NQ] = {ATT_CELLS - 1, 51};
std::vector<int32_t> kids((size_t) ATT_NQ * ATT_CAP, 0), ksteps((size_t) ATT_NQ * 4, 0);
for (int b = 0; b < ATT_NQ; ++b) {
int w = 0;
for (int cell = 0; cell <= qpos[b]; ++cell) if (cell % 3 != 1) kids[(size_t) b * ATT_CAP + w++] = cell;
ksteps[b * 4 + 3] = w;
}
for (int vision = 0; vision < 2; ++vision) {
std::vector<float> routed = q;
emu_launch(dim3(ATT_NQ * NH), dim3(256), [&] { leleka_keyless_route_query(routed.data(), matrices.data(), NH); });
std::vector<float> roped = routed;
for (int b = 0; b < ATT_NQ; ++b) for (int h = 0; h < NH; ++h) for (int d = 0; d < 32; ++d) {
const int i = (b * NH + h) * HD + d;
const int rp = vision ? mpos[qpos[b] * 3 + d % 3] : qpos[b];
const float a = roped[i], vv = roped[i + 32], c = co[(size_t) rp * 32 + d], s2 = si[(size_t) rp * 32 + d];
roped[i] = a * c - vv * s2; roped[i + 32] = a * s2 + vv * c;
}
const auto out = run_attention(kids, ksteps, ATT_NQ, [&](float* pa, float* pm, float* pl, long long stride) {
leleka_qsa_attn_chunk_m4(roped.data(), vq.data(), vs.data(), table.data(), co.data(), si.data(), vision ? mpos.data() : nullptr, 64,
kids.data(), ksteps.data(), HEADS, PAGE, pa, pm, pl, ATT_NCHUNKS, ATT_CAP, stride);
});
Json j; j.hex("out", out);
root.obj(vision ? "m4_mrope" : "m4", j);
}
}
return root;
}
} // namespace
int main(int argc, char** argv) {
@@ -272,6 +475,9 @@ int main(int argc, char** argv) {
root.obj("q4", scenario_q4());
root.obj("q8", scenario_q8());
root.obj("stream", scenario_stream());
root.obj("route", scenario_route());
root.obj("cvec", scenario_cvec());
root.obj("attn", scenario_attention());
#ifdef HAVE_SCENARIOS_2
scenarios_2(root);
#endif
@@ -0,0 +1,161 @@
// Golden fixtures for control-vector loading: `load_control_vectors` of engine/strata/src/program/generate.cpp,
// included VERBATIM (extracted by gen_cvec_golden.sh with awk) and run on synthetic control-vector GGUF files
// written by this harness. `cvec_upload` (CUDA) is replaced by a recorder; the function is otherwise unmodified.
#include "strata/artifact/gguf_reader.hpp"
#include "strata/core/layout.hpp"
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <string>
#include <utility>
#include <vector>
// ---- stand-ins for what the extracted function touches
struct Options {
std::vector<std::pair<std::string, float>> cvec_files;
int cvec_first = -1, cvec_last = -1;
int cvec_mode = 1;
int cvec_single = -1;
};
namespace strata::kernels {
struct Recorded { std::vector<float> dir, s; int mode = -1, first = 0, last = 0; int64_t n_embd = 0, hc = 0; bool called = false; };
inline Recorded g_recorded;
inline bool cvec_upload(const std::vector<float>& dir, const std::vector<float>& s, int mode, int first, int last,
int64_t n_embd, int64_t hc, std::string&) {
g_recorded = {dir, s, mode, first, last, n_embd, hc, true};
return true;
}
} // namespace strata::kernels
#include "fragment_load_control_vectors.inc"
namespace {
uint64_t lcg_state = 77;
uint32_t next32() { lcg_state = lcg_state * 6364136223846793005ull + 1442695040888963407ull; return (uint32_t) (lcg_state >> 32); }
float value() { return (float) ((int32_t) (next32() >> 8) - (1 << 23)) / 8388608.0f * 2.0f; }
uint32_t bits(float f) { uint32_t u; std::memcpy(&u, &f, 4); return u; }
void put_u32(std::string& b, uint32_t v) { b.append((const char*) &v, 4); }
void put_u64(std::string& b, uint64_t v) { b.append((const char*) &v, 8); }
void put_str(std::string& b, const std::string& s) { put_u64(b, s.size()); b += s; }
struct T { std::string name; std::vector<float> data; uint32_t type = 0; };
std::string gguf(const std::string& arch, const std::vector<T>& ts, bool hint = false) {
std::string b;
put_u32(b, 0x46554747u); put_u32(b, 3); put_u64(b, ts.size()); put_u64(b, 1 + (hint ? 1 : 0));
put_str(b, "general.architecture"); put_u32(b, 8); put_str(b, arch);
if (hint) { put_str(b, "controlvector.model_hint"); put_u32(b, 8); put_str(b, "qwen4exp"); }
uint64_t off = 0;
for (const T& t : ts) {
put_str(b, t.name); put_u32(b, 1); put_u64(b, t.data.size()); put_u32(b, t.type); put_u64(b, off);
off += (t.data.size() * 4 + 31) / 32 * 32;
}
while (b.size() % 32) b.push_back(0);
for (const T& t : ts) {
b.append((const char*) t.data.data(), t.data.size() * 4);
while (b.size() % 32) b.push_back(0);
}
return b;
}
std::string hex(const std::string& s) {
static const char* d = "0123456789abcdef";
std::string o;
for (unsigned char c : s) { o += d[c >> 4]; o += d[c & 15]; }
return o;
}
std::vector<float> vec(int n) { std::vector<float> v(n); for (auto& x : v) x = value(); return v; }
struct Case { std::string name; std::vector<std::pair<std::string, float>> files; std::vector<std::string> contents; Options o; };
} // namespace
int main() {
const int L = 6, N = 40, HC = 4;
strata::core::ModelGeometry g;
g.n_layers = L; g.n_embd = N; g.hc = HC;
const std::string dir = std::string(getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp") + "/leleka_cvec_golden";
std::system(("mkdir -p " + dir).c_str());
std::vector<std::string> A = {gguf("controlvector", {{"direction.0", vec(N)}, {"direction.2", vec(N)}, {"direction.3", vec(N)}, {"direction.9", vec(N)}}, true),
gguf("controlvector", {{"direction.2", vec(N)}, {"direction.4", vec(N)}})};
const std::string wrong_arch = gguf("llama", {{"direction.2", vec(N)}});
const std::string wrong_shape = gguf("controlvector", {{"direction.2", vec(N + 1)}});
const std::string wrong_type = gguf("controlvector", {{"direction.2", vec(N), 1}});
const std::string no_dirs = gguf("controlvector", {{"other.2", vec(N)}});
const std::string only_layer0 = gguf("controlvector", {{"direction.0", vec(N)}});
const std::string zero_dir = gguf("controlvector", {{"direction.2", std::vector<float>(N, 0.0f)}});
const std::string truncated = A[0].substr(0, 60);
std::string bad_magic = A[0]; bad_magic[0] = 'X';
std::string v2 = A[0]; v2[4] = 2;
std::vector<Case> cases;
auto mk = [&](const std::string& name, std::vector<std::pair<std::string, float>> files, std::vector<std::string> contents, Options o) {
cases.push_back({name, std::move(files), std::move(contents), o});
};
Options add; add.cvec_mode = 1;
Options proj; proj.cvec_mode = 0;
Options range = add; range.cvec_first = 2; range.cvec_last = 4;
Options proj_range = proj; proj_range.cvec_first = 2; proj_range.cvec_last = 5;
Options single = proj; single.cvec_single = 3;
Options single_missing = proj; single_missing.cvec_single = 5;
Options single_ignored_in_add = add; single_ignored_in_add.cvec_single = 5;
Options out_of_range = add; out_of_range.cvec_first = 5; out_of_range.cvec_last = 5;
Options wide = add; wide.cvec_last = 100;
mk("add_two_files", {{"a.gguf", 1.5f}, {"b.gguf", -0.5f}}, {A[0], A[1]}, add);
mk("add_range", {{"a.gguf", 1.0f}, {"b.gguf", 2.0f}}, {A[0], A[1]}, range);
mk("add_last_beyond_model", {{"a.gguf", 0.25f}}, {A[0]}, wide);
mk("project_two_files", {{"a.gguf", 1.0f}, {"b.gguf", 1.0f}}, {A[0], A[1]}, proj);
mk("project_range", {{"a.gguf", 0.75f}, {"b.gguf", 0.5f}}, {A[0], A[1]}, proj_range);
mk("project_single_layer", {{"a.gguf", 1.0f}}, {A[0]}, single);
mk("project_single_missing", {{"a.gguf", 1.0f}}, {A[0]}, single_missing);
mk("add_ignores_single", {{"a.gguf", 1.0f}}, {A[0]}, single_ignored_in_add);
mk("nothing_in_range", {{"a.gguf", 1.0f}}, {A[0]}, out_of_range);
mk("zero_scale_project", {{"a.gguf", 0.0f}}, {A[0]}, proj);
mk("zero_direction_project", {{"z.gguf", 1.0f}}, {zero_dir}, proj);
mk("wrong_architecture", {{"w.gguf", 1.0f}}, {wrong_arch}, add);
mk("wrong_shape", {{"s.gguf", 1.0f}}, {wrong_shape}, add);
mk("wrong_type", {{"t.gguf", 1.0f}}, {wrong_type}, add);
mk("no_direction_tensors", {{"n.gguf", 1.0f}}, {no_dirs}, add);
mk("only_layer_zero", {{"o.gguf", 1.0f}}, {only_layer0}, add);
mk("truncated", {{"x.gguf", 1.0f}}, {truncated}, add);
mk("bad_magic", {{"m.gguf", 1.0f}}, {bad_magic}, add);
mk("version_2", {{"v.gguf", 1.0f}}, {v2}, add);
std::printf("{\"n_layers\":%d,\"n_embd\":%d,\"hc\":%d,\"cases\":[", L, N, HC);
for (size_t ci = 0; ci < cases.size(); ++ci) {
Case& c = cases[ci];
Options o = c.o;
for (size_t i = 0; i < c.files.size(); ++i) {
const std::string path = dir + "/" + std::to_string(ci) + "_" + c.files[i].first;
std::ofstream(path, std::ios::binary).write(c.contents[i].data(), (std::streamsize) c.contents[i].size());
o.cvec_files.push_back({path, c.files[i].second});
}
strata::kernels::g_recorded = {};
std::string summary, err;
const bool ok = load_control_vectors(o, g, summary, err);
// the error text names the temp path; record it with that prefix replaced by the file label
for (size_t i = 0; i < c.files.size(); ++i) {
const std::string path = dir + "/" + std::to_string(ci) + "_" + c.files[i].first;
for (size_t at; (at = err.find(path)) != std::string::npos;) err.replace(at, path.size(), c.files[i].first);
}
std::printf("%s\n{\"name\":\"%s\",\"options\":{\"first\":%d,\"last\":%d,\"mode\":%d,\"single\":%d},\"files\":[", ci ? "," : "", c.name.c_str(),
o.cvec_first, o.cvec_last, o.cvec_mode, o.cvec_single);
for (size_t i = 0; i < c.files.size(); ++i)
std::printf("%s{\"label\":\"%s\",\"scale\":%u,\"bytes\":\"%s\"}", i ? "," : "", c.files[i].first.c_str(), bits(c.files[i].second), hex(c.contents[i]).c_str());
std::printf("],\"ok\":%d,\"error\":\"%s\"", ok ? 1 : 0, ok ? "" : err.c_str());
if (ok) {
const auto& r = strata::kernels::g_recorded;
std::printf(",\"summary\":\"%s\",\"mode\":%d,\"first\":%d,\"last\":%d,\"dir\":[", summary.c_str(), r.mode, r.first, r.last);
for (size_t i = 0; i < r.dir.size(); ++i) std::printf("%s%u", i ? "," : "", bits(r.dir[i]));
std::printf("],\"s\":[");
for (size_t i = 0; i < r.s.size(); ++i) std::printf("%s%u", i ? "," : "", bits(r.s[i]));
std::printf("]");
}
std::printf("}");
}
std::printf("]}\n");
std::system(("rm -rf " + dir).c_str());
return 0;
}
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
# Regenerates tests/fixtures/cvec_golden.json from generate.cpp's own load_control_vectors (extracted verbatim)
# running on synthetic control-vector GGUF files. Host-only; `cvec_upload` is a recorder.
# crates/experimental-ref/oracle/gen_cvec_golden.sh
set -eu
here=$(cd "$(dirname "$0")" && pwd)
strata="$here/../../../engine/strata"
out="$here/../tests/fixtures"
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
awk '/^bool load_control_vectors\(const Options& o, const strata::core::ModelGeometry& g, std::string& summary, std::string& err\) \{/ {on=1} on {print} on && /^}/ {exit}' \
"$strata/src/program/generate.cpp" > "$work/fragment_load_control_vectors.inc"
test -s "$work/fragment_load_control_vectors.inc"
# -ffp-contract=off: the Original's host build has no FMA, `data += scale * src` is a multiply then an add
${CXX:-clang++} -std=c++17 -O1 -ffp-contract=off -Wno-unused-function -Wno-unused-variable -I"$strata/include" -I"$work" \
"$here/gen_cvec_golden.cpp" -o "$work/gen_cvec"
mkdir -p "$out"
"$work/gen_cvec" > "$out/cvec_golden.json"
echo "wrote $out/cvec_golden.json"
+116
View File
@@ -0,0 +1,116 @@
//! Decode attention over the experimental KV formats: scratch arithmetic of `qsa_decode_attn.cu` and a
//! double-precision reference of what the split-K kernel computes (softmax GQA over the selected cells).
//!
//! The device kernel accumulates in f32 in a split-K order and uses `__expf`; this reference is the exact
//! mathematical result over the *same dequantized* K/V, so agreement is a relative tolerance (the Original's own
//! parity tests use `5e-3` absolute against a host f32 reference). The attention kernels are:
//! KV_MODE 2 (Q4_0 K and V, rotated), 3 (K8V4: INT8 K, rotated Q4_0 V), 4 (keyless: V-only INT8, K rebuilt from
//! V by position). Modes 2 and 3 return the output in the *rotated* domain; the caller applies the FWHT.
use crate::layout::QsaShapes;
pub const HD: usize = 256;
/// Query heads per KV head (24 / 2).
pub const G: usize = 12;
/// Cells per block.
pub const CHUNK: usize = 64;
pub const THREADS: usize = 256;
/// `qsa_decode_attn_scratch_floats`: partial accumulators, maxima and sums for `cap` selected cells.
pub fn scratch_floats(cap: i64, s: &QsaShapes) -> u64 {
let chunks = (cap + CHUNK as i64 - 1) / CHUNK as i64;
chunks as u64 * s.n_head as u64 * (HD as u64 + 2) + 64
}
pub fn n_chunks(cap: i64) -> i64 {
(cap + CHUNK as i64 - 1) / CHUNK as i64
}
/// The score scale of the Original (`1.0f / sqrtf((float) HD)`), exactly 1/16.
pub const SCALE: f32 = 0.0625;
/// Softmax GQA attention in f64. `q` is `[n_head][256]`; `k` and `v` are `[n_ids][n_head_kv][256]`
/// (dequantized, already in the domain the kernel sees); `n_ids` cells are attended. Returns `[n_head][256]`.
pub fn reference(q: &[f32], k: &[f32], v: &[f32], n_head: usize, n_head_kv: usize, n_ids: usize) -> Vec<f64> {
assert_eq!(n_head % n_head_kv, 0);
assert_eq!(q.len(), n_head * HD);
assert_eq!(k.len(), n_ids * n_head_kv * HD);
assert_eq!(v.len(), k.len());
let group = n_head / n_head_kv;
let mut out = vec![0f64; n_head * HD];
if n_ids == 0 {
return out;
}
for h in 0..n_head {
let kvh = h / group;
let mut scores = vec![0f64; n_ids];
for (j, sc) in scores.iter_mut().enumerate() {
let kr = &k[(j * n_head_kv + kvh) * HD..][..HD];
let qr = &q[h * HD..][..HD];
*sc = qr.iter().zip(kr).map(|(a, b)| f64::from(*a) * f64::from(*b)).sum::<f64>() * f64::from(SCALE);
}
let max = scores.iter().cloned().fold(f64::NEG_INFINITY, f64::max);
let weights: Vec<f64> = scores.iter().map(|s| (s - max).exp()).collect();
let total: f64 = weights.iter().sum();
for (j, w) in weights.iter().enumerate() {
let vr = &v[(j * n_head_kv + kvh) * HD..][..HD];
for d in 0..HD {
out[h * HD + d] += w / total * f64::from(vr[d]);
}
}
}
out
}
/// Relative L2 and max absolute error between a kernel output and a reference.
pub fn errors(got: &[f32], want: &[f64]) -> (f64, f64) {
let (mut e2, mut r2, mut emax) = (0f64, 0f64, 0f64);
for (g, w) in got.iter().zip(want) {
let e = f64::from(*g) - w;
e2 += e * e;
r2 += w * w;
emax = emax.max(e.abs());
}
((e2 / r2.max(1e-300)).sqrt(), emax)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn scratch_size_matches_the_original_formula() {
let s = QsaShapes::real();
assert_eq!(scratch_floats(70, &s), 2 * 24 * 258 + 64);
assert_eq!(scratch_floats(2051, &s), 33 * 24 * 258 + 64);
assert_eq!(n_chunks(64), 1);
assert_eq!(n_chunks(65), 2);
}
#[test]
fn uniform_scores_average_the_values() {
let (nh, nkv, n) = (2, 1, 3);
let q = vec![0.0f32; nh * HD];
let k = vec![1.0f32; n * nkv * HD];
let mut v = vec![0.0f32; n * nkv * HD];
for j in 0..n {
v[j * HD] = (j + 1) as f32; // 1, 2, 3
}
let out = reference(&q, &k, &v, nh, nkv, n);
assert!((out[0] - 2.0).abs() < 1e-12 && (out[HD] - 2.0).abs() < 1e-12);
}
#[test]
fn a_dominant_key_selects_its_value() {
let (nh, nkv, n) = (1, 1, 2);
let mut q = vec![0.0f32; HD];
q[0] = 160.0;
let mut k = vec![0.0f32; n * HD];
k[0] = 1.0; // cell 0 aligned with q: score 10
let mut v = vec![0.0f32; n * HD];
v[0] = 5.0;
v[HD] = -7.0;
let out = reference(&q, &k, &v, nh, nkv, n);
assert!((out[0] - 5.0).abs() < 1e-3);
}
}
+682
View File
@@ -0,0 +1,682 @@
//! Control vectors (`--control-vector[-scaled]`, `--cvec-mode`, `--cvec-dir`; `kernels/cvec.{hpp,cu}`,
//! `load_control_vectors` in `generate.cpp`): GGUF parsing, the per-layer direction/scale tables, and the
//! kernel's application to the hyper-connection residual streams.
//!
//! After layer `l`'s FFN write, every one of the `hc` residual streams `h` of every token becomes
//! * project: `h <- h - s_l (h . v_l) v_l` with `v_l = d / |d|`, `s_l = |d|` (the steered component is removed
//! or, for `s != 1`, scaled);
//! * add: `h <- h + d` (llama.cpp's stock additive vector)
//! for `l` in `[first, last]`; `d` is the sum over files of `scale * direction.<src>` with `src = l` or one fixed
//! layer (`single:L`, project mode). Layer 0 has no direction.
//!
//! EXPERIMENTAL: steering changes model output by design. Off unless a vector is loaded; a loaded one is
//! switched per request (`on`); with the switch off and no pending write the kernel does nothing.
/// Threads of the kernel block and the register capacity of one stream (`n_embd <= 256 * 16`).
pub const THREADS: usize = 256;
pub const MAXK: usize = 16;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum CvecError {
/// GGUF structure: bad magic, version, truncated header, duplicate tensor, bad dims, array too long, ...
Gguf(String),
/// `general.architecture` is not `controlvector`.
NotAControlVector(String),
/// A `direction.<l>` tensor is not `n_embd` f32.
BadTensor { file: String, tensor: String, n_embd: i64 },
NoDirections(String),
/// `--cvec-dir single:L` names a layer the vector has no direction for.
NoSingleDirection(i64),
/// No layer in `[first, last]` is steered.
NothingSteered { first: i64, last: i64 },
UnsupportedEmbd,
BadTables,
}
impl std::fmt::Display for CvecError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Gguf(m) => write!(f, "{m}"),
Self::NotAControlVector(p) => {
write!(f, "{p}: not a control vector GGUF (general.architecture is not 'controlvector')")
}
Self::BadTensor { file, tensor, n_embd } => write!(f, "{file}: {tensor} must be {n_embd} f32"),
Self::NoDirections(p) => write!(f, "{p}: no direction.<layer> tensors"),
Self::NoSingleDirection(l) => write!(f, "--cvec-dir single:{l}: the vector has no direction for that layer"),
Self::NothingSteered { first, last } => {
write!(f, "the control vector has no direction in layers {first}..{last}")
}
Self::UnsupportedEmbd => f.write_str("control vector: unsupported n_embd"),
Self::BadTables => f.write_str("control vector: bad table sizes"),
}
}
}
impl std::error::Error for CvecError {}
// ------------------------------------------------------------------------------------------------ GGUF
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct GgufTensor {
pub name: String,
pub shape: Vec<u64>,
pub ggml_type: u32,
/// Byte range of the tensor data in the file (checked to lie inside it).
pub data: std::ops::Range<usize>,
}
impl GgufTensor {
pub fn elements(&self) -> u64 {
self.shape.iter().product()
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct GgufFile {
pub architecture: Option<String>,
pub model_hint: Option<String>,
pub tensors: Vec<GgufTensor>,
}
struct Cursor<'a> {
b: &'a [u8],
at: usize,
}
impl Cursor<'_> {
fn need(&self, n: usize) -> Result<(), CvecError> {
if self.at.checked_add(n).is_none_or(|e| e > self.b.len()) {
return Err(CvecError::Gguf("GGUF: unexpected end of file in header".into()));
}
Ok(())
}
fn take(&mut self, n: usize) -> Result<&[u8], CvecError> {
self.need(n)?;
let s = &self.b[self.at..self.at + n];
self.at += n;
Ok(s)
}
fn u32(&mut self) -> Result<u32, CvecError> {
Ok(u32::from_le_bytes(self.take(4)?.try_into().expect("4")))
}
fn u64(&mut self) -> Result<u64, CvecError> {
Ok(u64::from_le_bytes(self.take(8)?.try_into().expect("8")))
}
fn string(&mut self) -> Result<String, CvecError> {
let n = self.u64()?;
let n = usize::try_from(n).map_err(|_| CvecError::Gguf("GGUF: unexpected end of file in header".into()))?;
Ok(String::from_utf8_lossy(self.take(n)?).into_owned())
}
}
enum Meta {
Str(String),
Uint(u64),
Other,
}
fn read_value(c: &mut Cursor<'_>, t: u32, depth: u32) -> Result<Meta, CvecError> {
if depth > 2 {
return Err(CvecError::Gguf("GGUF: array nesting too deep".into()));
}
Ok(match t {
0 | 1 | 7 => Meta::Uint(u64::from(c.take(1)?[0])),
2 | 3 => Meta::Uint(u64::from(u16::from_le_bytes(c.take(2)?.try_into().expect("2")))),
4 | 5 => Meta::Uint(u64::from(c.u32()?)),
6 => {
c.take(4)?;
Meta::Other
}
8 => Meta::Str(c.string()?),
10 | 11 => Meta::Uint(c.u64()?),
12 => {
c.take(8)?;
Meta::Other
}
9 => {
let elem = c.u32()?;
let count = c.u64()?;
if count > (1 << 24) {
return Err(CvecError::Gguf("GGUF: implausible array length".into()));
}
for _ in 0..count {
read_value(c, elem, depth + 1)?;
}
Meta::Other
}
_ => return Err(CvecError::Gguf("GGUF: unknown metadata value type".into())),
})
}
/// Parse a GGUF v3 file's header (`GgufFile::parse` of `gguf_reader.hpp`), plus a check the Original lacks:
/// every tensor's data range must lie inside the file.
pub fn parse_gguf(bytes: &[u8]) -> Result<GgufFile, CvecError> {
let mut c = Cursor { b: bytes, at: 0 };
if c.u32()? != 0x4655_4747 {
return Err(CvecError::Gguf("not a GGUF file (bad magic)".into()));
}
let version = c.u32()?;
if version != 3 {
return Err(CvecError::Gguf(format!("GGUF v{version}, this reader handles v3")));
}
let n_tensors = c.u64()?;
let n_kv = c.u64()?;
let (mut architecture, mut model_hint, mut alignment) = (None, None, 32u64);
let mut seen_keys = std::collections::BTreeSet::new();
for _ in 0..n_kv {
let key = c.string()?;
let t = c.u32()?;
let v = read_value(&mut c, t, 0)?;
if !seen_keys.insert(key.clone()) {
continue; // emplace keeps the first
}
match (key.as_str(), v) {
("general.architecture", Meta::Str(s)) => architecture = Some(s),
("general.architecture", _) => architecture = Some(String::new()),
("controlvector.model_hint", Meta::Str(s)) => model_hint = Some(s),
("controlvector.model_hint", _) => model_hint = Some(String::new()),
("general.alignment", Meta::Uint(a)) if a != 0 => alignment = a,
_ => {}
}
}
let mut names = std::collections::BTreeSet::new();
let mut infos = Vec::new();
for _ in 0..n_tensors {
let name = c.string()?;
if !names.insert(name.clone()) {
return Err(CvecError::Gguf(format!("GGUF: duplicate tensor name '{name}'")));
}
let nd = c.u32()?;
if nd == 0 || nd > 4 {
return Err(CvecError::Gguf(format!("GGUF: bad n_dims for {name}")));
}
let mut shape = Vec::new();
for _ in 0..nd {
shape.push(c.u64()?);
}
let ggml_type = c.u32()?;
let offset = c.u64()?;
infos.push((name, shape, ggml_type, offset));
}
let data_start = (c.at as u64).div_ceil(alignment) * alignment;
if data_start > bytes.len() as u64 {
return Err(CvecError::Gguf("GGUF: data section starts past EOF".into()));
}
let mut tensors = Vec::new();
for (name, shape, ggml_type, offset) in infos {
let elements = shape.iter().try_fold(1u64, |a, d| a.checked_mul(*d));
// only F32 tensors are read; their extent is checked, others keep an empty range
let range = match (ggml_type, elements) {
(0, Some(n)) => {
let start = data_start.checked_add(offset);
let end = start.and_then(|s| n.checked_mul(4).and_then(|b| s.checked_add(b)));
match (start, end) {
(Some(s), Some(e)) if e <= bytes.len() as u64 => s as usize..e as usize,
_ => return Err(CvecError::Gguf(format!("GGUF: tensor {name} lies outside the file"))),
}
}
_ => 0..0,
};
tensors.push(GgufTensor { name, shape, ggml_type, data: range });
}
Ok(GgufFile { architecture, model_hint, tensors })
}
// ---------------------------------------------------------------------------------------------- tables
/// `--cvec-mode`: 0 project, 1 add (llama.cpp's default).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CvecMode {
Project = 0,
Add = 1,
}
/// The loader's options (`Options::cvec_*`): `first`/`last` of `<= 0` mean the defaults `1` / last layer.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct CvecOptions {
pub first: i64,
pub last: i64,
pub mode: CvecMode,
/// `--cvec-dir single:L` (project mode only); `-1` = per-layer.
pub single: i64,
}
impl Default for CvecOptions {
fn default() -> Self {
Self { first: -1, last: -1, mode: CvecMode::Add, single: -1 }
}
}
/// The tables `cvec_upload` takes plus the description the engine keeps (`Cvec`).
#[derive(Clone, Debug, PartialEq)]
pub struct CvecTables {
/// `n_layers * n_embd`: project = the unit `v_l`, add = `d_l`; zero rows elsewhere.
pub dir: Vec<f32>,
/// `n_layers`: project = `s_l`, add = 1; 0 = the layer is not steered.
pub s: Vec<f32>,
pub mode: CvecMode,
pub first: i64,
pub last: i64,
pub n_embd: i64,
pub hc: i64,
pub steered: Vec<bool>,
/// What `INFO` reports.
pub summary: String,
}
impl CvecTables {
/// `Cvec::covers`: layer `l`'s FFN write is followed by the vector (decided at load time).
pub fn covers(&self, l: i64) -> bool {
l >= self.first && l <= self.last && (l as usize) < self.steered.len() && l >= 0 && self.steered[l as usize]
}
}
/// `load_control_vectors`: every file's `direction.<l>` times its scale, summed (f32 multiply then add), then the
/// project/add tables. `files` are `(label, bytes, scale)`. A `direction.<l>` with `l < 1` or `l >= n_layers` is
/// ignored (layer 0 has no vector; past the model is ignored, as in llama.cpp).
pub fn load_control_vectors(
files: &[(String, Vec<u8>, f32)],
n_layers: i64,
n_embd: i64,
hc: i64,
o: &CvecOptions,
) -> Result<CvecTables, CvecError> {
let (l_n, n) = (n_layers as usize, n_embd as usize);
let mut data = vec![0.0f32; l_n * n];
let mut have = vec![false; l_n];
for (label, bytes, scale) in files {
let f = parse_gguf(bytes)?;
if f.architecture.as_deref() != Some("controlvector") {
return Err(CvecError::NotAControlVector(label.clone()));
}
let mut found = 0;
for t in &f.tensors {
let Some(rest) = t.name.strip_prefix("direction.") else { continue };
// std::strtol: an optional sign and leading digits, anything else stops the parse (0 if none)
let digits: String = rest.chars().take_while(|c| c.is_ascii_digit()).collect();
let l: i64 = digits.parse().unwrap_or(0);
if l < 1 || l >= n_layers {
continue;
}
if t.ggml_type != 0 || t.elements() != n as u64 {
return Err(CvecError::BadTensor { file: label.clone(), tensor: t.name.clone(), n_embd });
}
let src = &bytes[t.data.clone()];
for j in 0..n {
let v = f32::from_le_bytes(src[j * 4..j * 4 + 4].try_into().expect("4"));
data[l as usize * n + j] += *scale * v;
}
have[l as usize] = true;
found += 1;
}
if found == 0 {
return Err(CvecError::NoDirections(label.clone()));
}
}
let first = if o.first <= 0 { 1 } else { o.first };
let last = if o.last <= 0 || o.last >= n_layers { n_layers - 1 } else { o.last };
let single = if o.mode == CvecMode::Project { o.single } else { -1 };
if single >= 0 && (single >= n_layers || !have[single as usize]) {
return Err(CvecError::NoSingleDirection(single));
}
let mut dir = vec![0.0f32; l_n * n];
let mut s = vec![0.0f32; l_n];
let mut steered = 0;
for l in first..=last {
let src = if single >= 0 { single } else { l };
if src < 0 || src >= n_layers || !have[src as usize] {
continue;
}
let d = &data[src as usize * n..(src as usize + 1) * n];
match o.mode {
CvecMode::Project => {
let mut nrm = 0.0f64;
for v in d {
nrm += f64::from(*v) * f64::from(*v);
}
let nrm = nrm.sqrt();
if nrm <= 0.0 {
continue;
}
s[l as usize] = nrm as f32;
for j in 0..n {
dir[l as usize * n + j] = (f64::from(d[j]) / nrm) as f32;
}
}
CvecMode::Add => {
s[l as usize] = 1.0;
dir[l as usize * n..(l as usize + 1) * n].copy_from_slice(d);
}
}
steered += 1;
}
if steered == 0 {
return Err(CvecError::NothingSteered { first, last });
}
check_tables(&dir, &s, n_embd)?;
let summary = format!(
"{}:{}-{}{}",
if o.mode == CvecMode::Project { "project" } else { "add" },
first,
last,
if single >= 0 { format!(":single{single}") } else { String::new() }
);
let steered_flags = s.iter().map(|v| *v != 0.0).collect();
Ok(CvecTables { dir, s, mode: o.mode, first, last, n_embd, hc, steered: steered_flags, summary })
}
/// The admission of `cvec_upload`.
pub fn check_tables(dir: &[f32], s: &[f32], n_embd: i64) -> Result<(), CvecError> {
if n_embd < 1 || n_embd > (THREADS * MAXK) as i64 {
return Err(CvecError::UnsupportedEmbd);
}
if s.is_empty() || dir.len() != s.len() * n_embd as usize {
return Err(CvecError::BadTables);
}
Ok(())
}
// ---------------------------------------------------------------------------------------------- kernel
/// The fused hyper-connection read's gate (`sigmoidf_`, `1 / (1 + __expf(-x))`). The device uses the fast
/// intrinsic; this is the libm result, so a pending write is exact only up to that intrinsic's error.
pub fn sigmoid(x: f32) -> f32 {
1.0 / (1.0 + (-x).exp())
}
/// Butterfly sum over 32 lanes with `__shfl_xor_sync` offsets 16, 8, 4, 2, 1 (every lane ends with the same
/// value; lane 0's is returned).
pub fn warp_xor_sum(mut lanes: [f32; 32]) -> f32 {
let mut o = 16;
while o > 0 {
let prev = lanes;
for l in 0..32 {
lanes[l] = prev[l] + prev[l ^ o];
}
o >>= 1;
}
lanes[0]
}
/// One `cvec_apply` over a batch: `R` is `T` rows of `r_ld` floats, each holding `hc` streams of `n`. With
/// `write`, the pending FFN write `R += bo * 2 sigmoid(inj / hc)` is applied first (`bo` rows of `bo_ld`,
/// `inj` rows of `inj_ld`). Literal twin of `cvec_kernel`'s per-thread dataflow, including the reduction tree.
#[allow(clippy::too_many_arguments)]
pub fn apply(
r: &mut [f32],
tables: &CvecTables,
on: bool,
layer: usize,
t_count: usize,
r_ld: usize,
pending: Option<(&[f32], usize, &[f32], usize)>,
) {
let (n, hc) = (tables.n_embd as usize, tables.hc as usize);
let write = pending.is_some();
let s = tables.s[layer];
let steer = on && s != 0.0;
if !steer && !write {
return;
}
let v = &tables.dir[layer * n..(layer + 1) * n];
for t in 0..t_count {
for c in 0..hc {
let base = t * r_ld + c * n;
let (w, b) = match pending {
Some((bo, bo_ld, inj, inj_ld)) => (2.0 * sigmoid(inj[t * inj_ld + c] / hc as f32), Some(&bo[t * bo_ld..][..n])),
None => (0.0, None),
};
// per-thread registers
let mut x = vec![[0.0f32; MAXK]; THREADS];
let mut dots = [0.0f32; THREADS];
for tid in 0..THREADS {
let mut dot = 0.0f32;
for k in 0..MAXK {
let d = tid + k * THREADS;
if d < n {
let mut xv = r[base + d];
if let Some(b) = b {
xv = b[d].mul_add(w, xv);
}
x[tid][k] = xv;
if steer && tables.mode == CvecMode::Project {
dot = xv.mul_add(v[d], dot);
}
}
}
dots[tid] = dot;
}
let mut dot = 0.0f32;
if steer && tables.mode == CvecMode::Project {
let mut part = [0.0f32; THREADS / 32];
for (w_i, p) in part.iter_mut().enumerate() {
let mut lanes = [0.0f32; 32];
lanes.copy_from_slice(&dots[w_i * 32..w_i * 32 + 32]);
*p = warp_xor_sum(lanes);
}
let mut lanes = [0.0f32; 32];
lanes[..THREADS / 32].copy_from_slice(&part);
dot = warp_xor_sum(lanes) * s; // s (h . v)
}
for tid in 0..THREADS {
for k in 0..MAXK {
let d = tid + k * THREADS;
if d < n {
let mut xv = x[tid][k];
if steer {
xv = if tables.mode == CvecMode::Project { (-dot).mul_add(v[d], xv) } else { xv + v[d] };
}
r[base + d] = xv;
}
}
}
}
}
}
#[cfg(test)]
mod tests {
use super::*;
// ---- a tiny GGUF writer for the tests (v3, F32 tensors)
fn gguf(arch: &str, hint: Option<&str>, tensors: &[(&str, Vec<f32>)]) -> Vec<u8> {
let mut b = Vec::new();
let s = |b: &mut Vec<u8>, t: &str| {
b.extend_from_slice(&(t.len() as u64).to_le_bytes());
b.extend_from_slice(t.as_bytes());
};
b.extend_from_slice(&0x4655_4747u32.to_le_bytes());
b.extend_from_slice(&3u32.to_le_bytes());
b.extend_from_slice(&(tensors.len() as u64).to_le_bytes());
b.extend_from_slice(&(1 + u64::from(hint.is_some())).to_le_bytes());
s(&mut b, "general.architecture");
b.extend_from_slice(&8u32.to_le_bytes());
s(&mut b, arch);
if let Some(h) = hint {
s(&mut b, "controlvector.model_hint");
b.extend_from_slice(&8u32.to_le_bytes());
s(&mut b, h);
}
let mut off = 0u64;
for (name, v) in tensors {
s(&mut b, name);
b.extend_from_slice(&1u32.to_le_bytes());
b.extend_from_slice(&(v.len() as u64).to_le_bytes());
b.extend_from_slice(&0u32.to_le_bytes());
b.extend_from_slice(&off.to_le_bytes());
off += (v.len() * 4).div_ceil(32) as u64 * 32;
}
while b.len() % 32 != 0 {
b.push(0);
}
for (_, v) in tensors {
for x in v {
b.extend_from_slice(&x.to_le_bytes());
}
while b.len() % 32 != 0 {
b.push(0);
}
}
b
}
fn vec_of(n: usize, seed: f32) -> Vec<f32> {
(0..n).map(|i| ((i as f32 + seed) * 0.37).sin()).collect()
}
#[test]
fn parses_and_ignores_layer_zero_and_past_the_model() {
let n = 8;
let bytes = gguf("controlvector", Some("qwen4exp"), &[("direction.0", vec_of(n, 0.0)), ("direction.2", vec_of(n, 2.0)), ("direction.9", vec_of(n, 9.0))]);
let f = parse_gguf(&bytes).unwrap();
assert_eq!(f.architecture.as_deref(), Some("controlvector"));
assert_eq!(f.model_hint.as_deref(), Some("qwen4exp"));
assert_eq!(f.tensors.len(), 3);
let t = load_control_vectors(&[("a.gguf".into(), bytes, 1.5)], 4, n as i64, 2, &CvecOptions::default()).unwrap();
assert_eq!(t.summary, "add:1-3");
assert!(t.covers(2) && !t.covers(1) && !t.covers(3) && !t.covers(0));
let want = 1.5 * vec_of(n, 2.0)[3];
assert_eq!(t.dir[2 * n + 3], want + 0.0);
}
#[test]
fn project_mode_normalizes_and_scale_is_the_norm() {
let n = 16;
let d = vec_of(n, 1.0);
let bytes = gguf("controlvector", None, &[("direction.1", d.clone())]);
let o = CvecOptions { mode: CvecMode::Project, first: 1, last: 3, single: -1 };
let t = load_control_vectors(&[("a".into(), bytes, 2.0)], 4, n as i64, 4, &o).unwrap();
let nrm: f64 = d.iter().map(|v| f64::from(2.0 * v).powi(2)).sum::<f64>().sqrt();
assert!((f64::from(t.s[1]) - nrm).abs() < 1e-5);
let unit: f64 = (0..n).map(|j| f64::from(t.dir[n + j]).powi(2)).sum();
assert!((unit - 1.0).abs() < 1e-6);
assert_eq!(t.s[2], 0.0); // layer 2 has no direction
assert_eq!(t.summary, "project:1-3");
}
#[test]
fn single_layer_direction_steers_every_layer() {
let n = 8;
let bytes = gguf("controlvector", None, &[("direction.2", vec_of(n, 2.0))]);
let o = CvecOptions { mode: CvecMode::Project, first: 1, last: 3, single: 2 };
let t = load_control_vectors(&[("a".into(), bytes.clone(), 1.0)], 4, n as i64, 2, &o).unwrap();
assert!(t.covers(1) && t.covers(2) && t.covers(3));
assert_eq!(t.summary, "project:1-3:single2");
let o = CvecOptions { single: 3, ..o };
assert_eq!(
load_control_vectors(&[("a".into(), bytes, 1.0)], 4, n as i64, 2, &o),
Err(CvecError::NoSingleDirection(3))
);
}
#[test]
fn rejections() {
let n = 8;
let ok = gguf("controlvector", None, &[("direction.1", vec_of(n, 1.0))]);
let load = |bytes: Vec<u8>, o: CvecOptions| load_control_vectors(&[("f".into(), bytes, 1.0)], 4, n as i64, 2, &o);
let d = CvecOptions::default();
assert!(matches!(load(gguf("llama", None, &[("direction.1", vec_of(n, 1.0))]), d), Err(CvecError::NotAControlVector(_))));
assert!(matches!(load(gguf("controlvector", None, &[("direction.1", vec_of(n + 1, 1.0))]), d), Err(CvecError::BadTensor { .. })));
assert!(matches!(load(gguf("controlvector", None, &[("foo", vec_of(n, 1.0))]), d), Err(CvecError::NoDirections(_))));
assert!(matches!(load(ok[..20].to_vec(), d), Err(CvecError::Gguf(_))));
let mut bad_magic = ok.clone();
bad_magic[0] = 0;
assert!(matches!(load(bad_magic, d), Err(CvecError::Gguf(_))));
// steered layers outside the requested range
let o = CvecOptions { first: 2, last: 3, ..d };
assert_eq!(load(ok, o), Err(CvecError::NothingSteered { first: 2, last: 3 }));
// a zero direction in project mode is skipped
let zero = gguf("controlvector", None, &[("direction.1", vec![0.0; n])]);
assert!(matches!(load(zero, CvecOptions { mode: CvecMode::Project, ..d }), Err(CvecError::NothingSteered { .. })));
assert_eq!(check_tables(&[0.0; 10], &[0.0; 2], 5), Ok(()));
assert_eq!(check_tables(&[0.0; 10], &[0.0; 2], 6), Err(CvecError::BadTables));
assert_eq!(check_tables(&[], &[], 5), Err(CvecError::BadTables));
assert_eq!(check_tables(&[0.0; 4097 * 2], &[0.0; 2], 4097), Err(CvecError::UnsupportedEmbd));
}
fn tables(mode: CvecMode, n: usize, hc: usize, layer: usize, l: usize, scale: f32) -> CvecTables {
let mut dir = vec![0.0f32; l * n];
let mut s = vec![0.0f32; l];
let v = vec_of(n, 3.0);
let nrm = v.iter().map(|x| f64::from(*x).powi(2)).sum::<f64>().sqrt();
match mode {
CvecMode::Project => {
for j in 0..n {
dir[layer * n + j] = (f64::from(v[j]) / nrm) as f32;
}
s[layer] = scale; // s = 1 projects the direction out, s = 2 reflects the component
}
CvecMode::Add => {
dir[layer * n..(layer + 1) * n].copy_from_slice(&v);
s[layer] = 1.0;
}
}
let steered = s.iter().map(|x| *x != 0.0).collect();
CvecTables { dir, s, mode, first: 1, last: l as i64 - 1, n_embd: n as i64, hc: hc as i64, steered, summary: String::new() }
}
#[test]
fn project_removes_the_component_and_add_adds() {
let (n, hc, t_count) = (600usize, 3usize, 2usize);
let r_ld = hc * n;
let r0: Vec<f32> = (0..t_count * r_ld).map(|i| ((i * 7 % 13) as f32 - 6.0) * 0.3).collect();
let tp = tables(CvecMode::Project, n, hc, 2, 4, 1.0);
let mut r = r0.clone();
apply(&mut r, &tp, true, 2, t_count, r_ld, None);
for t in 0..t_count {
for c in 0..hc {
let after: f64 = (0..n).map(|j| f64::from(r[t * r_ld + c * n + j]) * f64::from(tp.dir[2 * n + j])).sum();
assert!(after.abs() < 1e-3, "{after}");
}
}
// off: unchanged
let mut r = r0.clone();
apply(&mut r, &tp, false, 2, t_count, r_ld, None);
assert_eq!(r, r0);
// a layer without a direction is untouched
apply(&mut r, &tp, true, 1, t_count, r_ld, None);
assert_eq!(r, r0);
// add
let ta = tables(CvecMode::Add, n, hc, 2, 4, 1.0);
let mut r = r0.clone();
apply(&mut r, &ta, true, 2, t_count, r_ld, None);
for t in 0..t_count {
for c in 0..hc {
for j in 0..n {
assert_eq!(r[t * r_ld + c * n + j], r0[t * r_ld + c * n + j] + ta.dir[2 * n + j]);
}
}
}
}
#[test]
fn pending_write_is_applied_even_when_the_vector_is_off() {
let (n, hc) = (300usize, 2usize);
let r0: Vec<f32> = (0..hc * n).map(|i| (i % 11) as f32 * 0.1).collect();
let bo: Vec<f32> = (0..n).map(|i| (i % 5) as f32 - 2.0).collect();
let inj = vec![0.5f32, -1.0];
let tp = tables(CvecMode::Project, n, hc, 2, 4, 1.0);
let mut r = r0.clone();
apply(&mut r, &tp, false, 2, 1, hc * n, Some((&bo, n, &inj, hc)));
for c in 0..hc {
let w = 2.0 * sigmoid(inj[c] / hc as f32);
for j in 0..n {
assert_eq!(r[c * n + j], bo[j].mul_add(w, r0[c * n + j]));
}
}
}
#[test]
fn warp_sum_is_a_butterfly_tree() {
let mut lanes = [0.0f32; 32];
for (i, l) in lanes.iter_mut().enumerate() {
*l = (i + 1) as f32;
}
assert_eq!(warp_xor_sum(lanes), 528.0);
// lanes >= 8 zero: the final reduction of 8 warp partials
let mut p = [0.0f32; 32];
for (i, l) in p.iter_mut().take(8).enumerate() {
*l = 1.0 / (i as f32 + 3.0);
}
let want = ((p[0] + p[4]) + (p[2] + p[6])) + ((p[1] + p[5]) + (p[3] + p[7]));
assert_eq!(warp_xor_sum(p), want);
}
}
+493
View File
@@ -0,0 +1,493 @@
//! Keyless / V-only QSA (`STRATA_KEYLESS_ROUTING`, charter G7, `docs/keyless-runtime.md`): the routing-matrix
//! artifact (`SKLROUT1`, `src/core/keyless.cpp`), the in-place query routing kernel (`keyless.cu`) and the
//! positional key reconstruction the V-only attention performs (`attn_chunk_kernel<4>`).
//!
//! The cache stores only INT8 V (codes + one fp16 scale per 64 values; 528 B per cell and layer). The query is
//! routed by an explicit per-head 256x256 matrix, then position-encoded; scores are taken against RoPE(V) at
//! each cell's position and the value sum retrieves the raw, unrotated V.
//!
//! EXPERIMENTAL with a FAILED model-quality gate (`docs/experiments/2026-10-04-keyless-runtime.md`): off by
//! default, never silently enabled; initial support requires INT8, no Hadamard rotation, one GPU stage and zero
//! position base.
use std::collections::BTreeSet;
pub const MAGIC: &[u8; 8] = b"SKLROUT1";
pub const VERSION: u32 = 1;
pub const DIM: usize = 256;
/// Rotated dimensions of the V-only keys (`keyless_n_rot`, the kernel requires exactly 64).
pub const N_ROT: usize = 64;
/// `__ldg`-free `mrope_pos`: with a `[cell][3]` (t, h, w) table the pair rotates by `tab[cell * 3 + pair % 3]`,
/// without one the position is the cell index (`mrope.hpp`).
pub fn mrope_pos(tab: Option<&[i32]>, pos: i32, pair: i32) -> i32 {
tab.map_or(pos, |t| t[pos as usize * 3 + (pair % 3) as usize])
}
/// `route_kernel`, host twin: `tokens x heads` queries of 256 floats are replaced by `matrix[head] * q`,
/// `sum = fmaf(row[i], weight[i], sum)` over i = 0..255 in order, where row `d` of head `h`'s matrix is
/// `matrices[(h * 256 + d) * 256 ..]` ("output-major"). Block `b = token * heads + head` reads head `b % heads`.
pub fn route_query(q: &mut [f32], matrices: &[f32], tokens: usize, heads: usize) -> Result<(), KeylessError> {
if q.len() != tokens * heads * DIM || matrices.len() != heads * DIM * DIM || tokens < 1 || heads < 1 {
return Err(KeylessError::Geometry);
}
if tokens > i32::MAX as usize / heads {
return Err(KeylessError::Geometry);
}
for block in 0..tokens * heads {
let h = block % heads;
let query = &mut q[block * DIM..(block + 1) * DIM];
let row: [f32; DIM] = (*query).try_into().expect("row");
for d in 0..DIM {
let weight = &matrices[(h * DIM + d) * DIM..][..DIM];
let mut sum = 0.0f32;
for i in 0..DIM {
sum = row[i].mul_add(weight[i], sum);
}
query[d] = sum;
}
}
Ok(())
}
/// Launch-argument admission of `keyless_route_query` (the host wrapper's check).
pub fn check_route_geometry(tokens: i64, heads: i64, dim: i64) -> Result<(), KeylessError> {
if tokens < 1 || heads < 1 || dim != DIM as i64 || tokens > i64::from(i32::MAX) / heads {
return Err(KeylessError::Geometry);
}
Ok(())
}
/// The key of a V-only cell: RoPE applied to the first 64 dimensions of the dequantized V row (`v` is 256
/// values), pairs `(d, d +- 32)`; `cos`/`sin` are `[position][32]` tables (`build_rope_table`).
pub fn key_from_value(v: &[f32], cell: i32, cos: &[f32], sin: &[f32], mrope: Option<&[i32]>) -> Vec<f32> {
assert_eq!(v.len(), DIM);
let half = N_ROT / 2;
let mut k = v.to_vec();
for d in 0..N_ROT {
let pair = d % half;
let rotary_pos = mrope_pos(mrope, cell, pair as i32) as usize;
let co = cos[rotary_pos * half + pair];
let si = sin[rotary_pos * half + pair];
let other = if d < half { d + half } else { d - half };
k[d] = if d < half { v[d] * co - v[other] * si } else { v[d] * co + v[other] * si };
}
k
}
// -------------------------------------------------------------------------------------------- artifact
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum KeylessError {
Geometry,
/// Header, version or geometry differs from the model (`invalid keyless artifact header/geometry`).
Header,
Truncated,
/// A layer id is out of range, not a QSA layer, or repeated.
InvalidLayer(u32),
/// A source projection is missing or its type, size or encoding differs.
SourceMismatch { layer: u32, role: &'static str },
/// The FNV-1a 64 of the source projection bytes differs from the artifact's record.
Fingerprint { layer: u32, role: &'static str },
NonFinite(u32),
Trailing,
}
impl std::fmt::Display for KeylessError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Geometry => f.write_str("invalid keyless query routing geometry or artifact"),
Self::Header => f.write_str("invalid keyless artifact header/geometry"),
Self::Truncated => f.write_str("truncated keyless artifact"),
Self::InvalidLayer(l) => write!(f, "keyless artifact has invalid/duplicate layer {l}"),
Self::SourceMismatch { layer, role } => {
write!(f, "keyless artifact source projection geometry/type mismatch (layer {layer}, {role})")
}
Self::Fingerprint { layer, role } => {
write!(f, "keyless artifact source projection fingerprint mismatch (layer {layer}, {role})")
}
Self::NonFinite(l) => write!(f, "truncated/nonfinite keyless query matrix (layer {l})"),
Self::Trailing => f.write_str("keyless artifact has trailing data"),
}
}
}
impl std::error::Error for KeylessError {}
/// The model's side of the admission: `ModelGeometry` and its QSA layer set.
#[derive(Clone, Debug)]
pub struct KeylessGeometry {
pub n_layers: u32,
pub qsa_layers: BTreeSet<u32>,
pub n_head: u32,
pub n_head_kv: u32,
pub head_dim: u32,
pub n_embd: u32,
}
impl KeylessGeometry {
/// `layer % 4 == 3` is a QSA layer (`is_qsa_layer`).
pub fn real() -> Self {
Self {
n_layers: 48,
qsa_layers: (0..48).filter(|l| l % 4 == 3).collect(),
n_head: 24,
n_head_kv: 2,
head_dim: 256,
n_embd: 2560,
}
}
}
/// One source projection of the loaded model (`WeightTable::find("blk.<l>.attn_<role>.weight")`).
#[derive(Clone, Copy, Debug)]
pub struct SourceTensor<'a> {
pub native_type: i32,
pub elements: u64,
/// The native (quantized) bytes; at least the artifact's recorded length.
pub data: &'a [u8],
}
#[derive(Clone, Debug, PartialEq)]
pub struct RoutingLayer {
pub layer: u32,
/// `[heads][256][256]` output-major matrices.
pub matrices: Vec<f32>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Routing {
pub layers: Vec<RoutingLayer>,
}
impl Routing {
/// `keyless_routing(layer)`.
pub fn layer(&self, layer: u32) -> Option<&[f32]> {
self.layers.iter().find(|l| l.layer == layer).map(|l| &l.matrices[..])
}
}
/// FNV-1a 64 (the artifact's fingerprint of the source bytes).
pub fn fnv1a64(bytes: &[u8]) -> u64 {
let mut h = 0xcbf2_9ce4_8422_2325u64;
for b in bytes {
h = (h ^ u64::from(*b)).wrapping_mul(0x0000_0100_0000_01b3);
}
h
}
/// `(block_elements, block_bytes)` of the native projection encodings the artifact records
/// (`kind`: 42 Q2_0, 8 Q8_0, 11 Q3_K, 12 Q4_K, 13 Q5_K, 14 Q6_K, 23 IQ4_XS).
pub fn block_geometry(kind: u32) -> Option<(u64, u64)> {
let elements = match kind {
42 => 64,
8 => 32,
_ => 256,
};
let bytes = match kind {
42 => 18,
11 => 110,
12 => 144,
13 => 176,
14 => 210,
23 => 136,
8 => 34,
_ => return None,
};
Some((elements, bytes))
}
struct Reader<'a> {
b: &'a [u8],
at: usize,
}
impl Reader<'_> {
fn take(&mut self, n: usize) -> Result<&[u8], KeylessError> {
let end = self.at.checked_add(n).ok_or(KeylessError::Truncated)?;
let s = self.b.get(self.at..end).ok_or(KeylessError::Truncated)?;
self.at = end;
Ok(s)
}
fn u32(&mut self) -> Result<u32, KeylessError> {
Ok(u32::from_le_bytes(self.take(4)?.try_into().expect("4")))
}
fn u64(&mut self) -> Result<u64, KeylessError> {
Ok(u64::from_le_bytes(self.take(8)?.try_into().expect("8")))
}
}
/// `keyless_load` minus the CUDA allocations: parse and fully admit a `SKLROUT1` artifact against the model's
/// geometry and its source projections. Every check happens before any matrix would reach a device.
pub fn parse_artifact<'a>(
bytes: &[u8],
g: &KeylessGeometry,
source: &dyn Fn(u32, &str) -> Option<SourceTensor<'a>>,
) -> Result<Routing, KeylessError> {
let mut r = Reader { b: bytes, at: 0 };
let magic = r.take(8)?;
if magic != MAGIC {
return Err(KeylessError::Header);
}
let (version, layers, heads, dim) = (r.u32()?, r.u32()?, r.u32()?, r.u32()?);
if version != VERSION
|| layers as usize != g.qsa_layers.len()
|| heads != g.n_head
|| dim != g.head_dim
|| dim as usize != DIM
{
return Err(KeylessError::Header);
}
let mut seen = BTreeSet::new();
let mut out = Vec::new();
for _ in 0..layers {
let layer = r.u32()?;
if layer >= g.n_layers || !g.qsa_layers.contains(&layer) || !seen.insert(layer) {
return Err(KeylessError::InvalidLayer(layer));
}
for role in ["q", "k", "v"] {
let kind = r.u32()?;
let nbytes = r.u64()?;
let wanted = r.u64()?;
let role_static: &'static str = match role {
"q" => "q",
"k" => "k",
_ => "v",
};
let mismatch = KeylessError::SourceMismatch { layer, role: role_static };
let w = source(layer, role).ok_or_else(|| mismatch.clone())?;
let expected_elements =
u64::from(g.n_embd) * u64::from(g.head_dim) * if role == "q" { u64::from(g.n_head) * 2 } else { u64::from(g.n_head_kv) };
if w.native_type as i64 != i64::from(kind)
|| nbytes == 0
|| nbytes > expected_elements * 4
|| expected_elements != w.elements
{
return Err(mismatch);
}
let (block_elements, block_bytes) = block_geometry(kind).ok_or_else(|| mismatch.clone())?;
if expected_elements % block_elements != 0 || nbytes != expected_elements / block_elements * block_bytes {
return Err(mismatch);
}
let data = w.data.get(..nbytes as usize).ok_or_else(|| mismatch.clone())?;
if fnv1a64(data) != wanted {
return Err(KeylessError::Fingerprint { layer, role: role_static });
}
}
let n = heads as usize * DIM * DIM;
let raw = r.take(n * 4)?;
let matrices: Vec<f32> = raw.chunks_exact(4).map(|c| f32::from_le_bytes(c.try_into().expect("4"))).collect();
if matrices.iter().any(|v| !v.is_finite()) {
return Err(KeylessError::NonFinite(layer));
}
out.push(RoutingLayer { layer, matrices });
}
if r.at != bytes.len() {
return Err(KeylessError::Trailing);
}
Ok(Routing { layers: out })
}
#[cfg(test)]
mod tests {
use super::*;
fn identity_scaled(heads: usize, scale: f32) -> Vec<f32> {
let mut m = vec![0.0f32; heads * DIM * DIM];
for h in 0..heads {
for d in 0..DIM {
m[(h * DIM + d) * DIM + d] = scale;
}
}
m
}
#[test]
fn routing_by_identity_scales_the_query_and_heads_wrap_by_block() {
let (tokens, heads) = (2, 3);
let mut m = identity_scaled(heads, 1.0);
for d in 0..DIM {
m[(2 * DIM + d) * DIM + d] = 2.0; // head 2 doubles
}
let mut q: Vec<f32> = (0..tokens * heads * DIM).map(|i| (i % 7) as f32 - 3.0).collect();
let orig = q.clone();
route_query(&mut q, &m, tokens, heads).unwrap();
for block in 0..tokens * heads {
let k = if block % heads == 2 { 2.0 } else { 1.0 };
for d in 0..DIM {
assert_eq!(q[block * DIM + d], k * orig[block * DIM + d]);
}
}
}
#[test]
fn routing_matrix_is_output_major() {
// matrix row 0 sums the first two inputs: out[0] = q0 + q1
let mut m = vec![0.0f32; DIM * DIM];
m[0] = 1.0;
m[1] = 1.0;
let mut q = vec![0.0f32; DIM];
q[0] = 3.0;
q[1] = 4.0;
route_query(&mut q, &m, 1, 1).unwrap();
assert_eq!(q[0], 7.0);
assert!(q[1..].iter().all(|v| *v == 0.0));
assert_eq!(route_query(&mut [0.0; 10], &m, 1, 1), Err(KeylessError::Geometry));
assert!(check_route_geometry(8, 24, 256).is_ok());
assert!(check_route_geometry(8, 24, 128).is_err());
assert!(check_route_geometry(i64::from(i32::MAX), 24, 256).is_err());
}
#[test]
fn mrope_is_the_cell_index_without_a_table() {
assert_eq!(mrope_pos(None, 17, 5), 17);
let tab = [10, 11, 12, 20, 21, 22];
assert_eq!(mrope_pos(Some(&tab), 1, 0), 20);
assert_eq!(mrope_pos(Some(&tab), 1, 4), 21); // pair % 3 == 1: h
assert_eq!(mrope_pos(Some(&tab), 0, 5), 12); // pair % 3 == 2: w
}
#[test]
fn key_reconstruction_rotates_the_first_64_dims_only() {
let v: Vec<f32> = (0..DIM).map(|i| i as f32 * 0.01).collect();
// position 0: cos 1, sin 0 -> identity
let (mut cos, mut sin) = (vec![0.0f32; 4 * 32], vec![0.0f32; 4 * 32]);
for p in 0..4 {
for d in 0..32 {
let a = p as f32 * (d as f32 + 1.0) * 0.1;
cos[p * 32 + d] = a.cos();
sin[p * 32 + d] = a.sin();
}
}
assert_eq!(key_from_value(&v, 0, &cos, &sin, None), v);
let k = key_from_value(&v, 2, &cos, &sin, None);
assert_eq!(k[64..], v[64..]);
assert_ne!(k[..64], v[..64]);
// rotation preserves the norm of each (d, d + 32) pair
for d in 0..32 {
let n0 = v[d] * v[d] + v[d + 32] * v[d + 32];
let n1 = k[d] * k[d] + k[d + 32] * k[d + 32];
assert!((n0 - n1).abs() < 1e-5);
}
}
// ------------------------------------------------------------------ artifact
struct Model {
g: KeylessGeometry,
// (layer, role) -> (kind, elements, data)
tensors: Vec<(u32, &'static str, i32, u64, Vec<u8>)>,
}
fn small_model() -> Model {
let mut g = KeylessGeometry::real();
g.qsa_layers = [3u32, 7].into_iter().collect();
g.n_head = 2;
g.n_head_kv = 1;
g.n_embd = 256;
let mut tensors = Vec::new();
for layer in [3u32, 7] {
for (role, mul) in [("q", 2 * 2u64), ("k", 1), ("v", 1)] {
let elements = 256 * 256 * mul;
// Q4_K: 256-element blocks of 144 bytes
let nbytes = (elements / 256 * 144) as usize;
let data: Vec<u8> = (0..nbytes).map(|i| ((i * 31 + layer as usize * 7 + role.len()) % 251) as u8).collect();
tensors.push((layer, role, 12, elements, data));
}
}
Model { g, tensors }
}
fn write_artifact(m: &Model, matrix_value: f32) -> Vec<u8> {
let mut out = Vec::new();
out.extend_from_slice(MAGIC);
for v in [1u32, m.g.qsa_layers.len() as u32, m.g.n_head, m.g.head_dim] {
out.extend_from_slice(&v.to_le_bytes());
}
// layout of scripts/prepare-keyless-routing.py: "<8s4I", then per layer "<I", 3 x "<IQQ", f32 matrices
for layer in &m.g.qsa_layers {
out.extend_from_slice(&layer.to_le_bytes());
for role in ["q", "k", "v"] {
let t = m.tensors.iter().find(|t| t.0 == *layer && t.1 == role).unwrap();
out.extend_from_slice(&(t.2 as u32).to_le_bytes());
out.extend_from_slice(&(t.4.len() as u64).to_le_bytes());
out.extend_from_slice(&fnv1a64(&t.4).to_le_bytes());
}
for _ in 0..m.g.n_head as usize * DIM * DIM {
out.extend_from_slice(&matrix_value.to_le_bytes());
}
}
out
}
fn lookup<'m>(m: &'m Model) -> impl Fn(u32, &str) -> Option<SourceTensor<'m>> + 'm {
move |layer, role| {
m.tensors
.iter()
.find(|t| t.0 == layer && t.1 == role)
.map(|t| SourceTensor { native_type: t.2, elements: t.3, data: &t.4 })
}
}
#[test]
fn artifact_round_trip_and_each_admission_failure() {
let m = small_model();
let good = write_artifact(&m, 0.5);
let routing = parse_artifact(&good, &m.g, &lookup(&m)).unwrap();
assert_eq!(routing.layers.len(), 2);
assert_eq!(routing.layer(7).unwrap().len(), 2 * DIM * DIM);
assert!(routing.layer(5).is_none());
let err = |bytes: &[u8]| parse_artifact(bytes, &m.g, &lookup(&m)).unwrap_err();
let mut bad = good.clone();
bad[0] = b'X';
assert_eq!(err(&bad), KeylessError::Header);
let mut bad = good.clone();
bad[8] = 2; // version
assert_eq!(err(&bad), KeylessError::Header);
let mut bad = good.clone();
bad[12] = 3; // layers
assert_eq!(err(&bad), KeylessError::Header);
let mut bad = good.clone();
bad[20] = 128; // head_dim
assert_eq!(err(&bad), KeylessError::Header);
let mut bad = good.clone();
bad[24] = 5; // first layer id is not a QSA layer
assert_eq!(err(&bad), KeylessError::InvalidLayer(5));
assert_eq!(err(&good[..good.len() - 1]), KeylessError::Truncated);
let mut bad = good.clone();
bad.push(0);
assert_eq!(err(&bad), KeylessError::Trailing);
// matrix NaN
let mut bad = good.clone();
let at = 24 + 4 + 3 * 20 + 16;
bad[at..at + 4].copy_from_slice(&f32::NAN.to_le_bytes());
assert_eq!(err(&bad), KeylessError::NonFinite(3));
// a different source tensor: fingerprint
let mut other = small_model();
other.tensors[0].4[3] ^= 0xFF;
assert_eq!(
parse_artifact(&good, &m.g, &lookup(&other)).unwrap_err(),
KeylessError::Fingerprint { layer: 3, role: "q" }
);
// a different encoding
let mut other = small_model();
other.tensors[1].2 = 14;
assert_eq!(
parse_artifact(&good, &m.g, &lookup(&other)).unwrap_err(),
KeylessError::SourceMismatch { layer: 3, role: "k" }
);
// duplicate layer
let mut dup = good.clone();
let layer_len = 4 + 60 + m.g.n_head as usize * DIM * DIM * 4;
let first = dup[24..24 + 4].to_vec();
dup[24 + layer_len..24 + layer_len + 4].copy_from_slice(&first);
assert_eq!(err(&dup), KeylessError::InvalidLayer(3));
}
#[test]
fn block_geometry_table() {
assert_eq!(block_geometry(42), Some((64, 18)));
assert_eq!(block_geometry(8), Some((32, 34)));
assert_eq!(block_geometry(12), Some((256, 144)));
assert_eq!(block_geometry(14), Some((256, 210)));
assert_eq!(block_geometry(1), None);
}
}
+3
View File
@@ -12,9 +12,12 @@
//!
//! Nothing here claims a speed or model-quality result.
pub mod attn;
pub mod cache;
pub mod cvec;
pub mod f16;
pub mod fwht;
pub mod keyless;
pub mod kv_q8;
pub mod kv_stream;
pub mod layout;
@@ -0,0 +1,53 @@
//! Control-vector loading against `load_control_vectors` of `generate.cpp` (extracted verbatim, run on synthetic
//! control-vector GGUF files by `oracle/gen_cvec_golden.sh`).
mod common;
use common::{fixture, unhex};
use leleka_experimental_ref::cvec::{CvecMode, CvecOptions, load_control_vectors};
#[test]
fn tables_and_errors_match_the_original_loader() {
let g = fixture("cvec_golden.json");
let (layers, n, hc) = (g["n_layers"].as_i64().unwrap(), g["n_embd"].as_i64().unwrap(), g["hc"].as_i64().unwrap());
let mut ok_cases = 0;
let mut err_cases = 0;
for c in g["cases"].as_array().unwrap() {
let name = c["name"].as_str().unwrap();
let o = &c["options"];
let opts = CvecOptions {
first: o["first"].as_i64().unwrap(),
last: o["last"].as_i64().unwrap(),
mode: if o["mode"].as_i64() == Some(0) { CvecMode::Project } else { CvecMode::Add },
single: o["single"].as_i64().unwrap(),
};
let files: Vec<(String, Vec<u8>, f32)> = c["files"]
.as_array()
.unwrap()
.iter()
.map(|f| {
(
f["label"].as_str().unwrap().to_string(),
unhex(f["bytes"].as_str().unwrap()),
f32::from_bits(f["scale"].as_u64().unwrap() as u32),
)
})
.collect();
let got = load_control_vectors(&files, layers, n, hc, &opts);
if c["ok"].as_i64() == Some(1) {
let t = got.unwrap_or_else(|e| panic!("{name}: {e}"));
let bits = |k: &str| -> Vec<u32> { c[k].as_array().unwrap().iter().map(|x| x.as_u64().unwrap() as u32).collect() };
assert_eq!(t.dir.iter().map(|x| x.to_bits()).collect::<Vec<_>>(), bits("dir"), "{name}: dir");
assert_eq!(t.s.iter().map(|x| x.to_bits()).collect::<Vec<_>>(), bits("s"), "{name}: s");
assert_eq!(t.mode as i64, c["mode"].as_i64().unwrap(), "{name}");
assert_eq!((t.first, t.last), (c["first"].as_i64().unwrap(), c["last"].as_i64().unwrap()), "{name}");
assert_eq!(t.summary, c["summary"].as_str().unwrap(), "{name}");
ok_cases += 1;
} else {
let e = got.expect_err(name);
assert_eq!(e.to_string(), c["error"].as_str().unwrap(), "{name}");
err_cases += 1;
}
}
assert_eq!((ok_cases, err_cases), (7, 12));
}
@@ -247,3 +247,221 @@ fn kv_stream_resolver_copy_and_ring_match_the_model() {
map.reset();
assert_eq!(state_hash(&map, 0) as i64, f["final_reset_state_fnv"].as_i64().unwrap());
}
// ---------------------------------------------------------------------------------- keyless routing
use leleka_experimental_ref::{
attn,
cvec::{self, CvecMode, CvecTables},
keyless,
};
fn routing_matrices(heads: usize) -> Vec<f32> {
let mut m = vec![0.0f32; heads * 256 * 256];
for h in 0..heads {
for d in 0..256 {
for j in 0..256 {
let a = if d == j { 0.8f32 } else { 0.0 };
m[(h * 256 + d) * 256 + j] = a + ((((h * 19 + d * 3 + j * 11) % 17) as i32 - 8) as f32) * 0.001f32;
}
}
}
m
}
#[test]
fn keyless_query_routing_kernel_matches_the_fmaf_reference_bit_for_bit() {
let fx = fixture("emulated_kernels.json");
let f = &fx["route"];
let (tokens, heads) = (f["tokens"].as_u64().unwrap() as usize, f["heads"].as_u64().unwrap() as usize);
let mut g = Lcg::new(61);
let mut q: Vec<f32> = (0..tokens * heads * 256).map(|_| g.soft()).collect();
keyless::route_query(&mut q, &routing_matrices(heads), tokens, heads).unwrap();
assert_hex_eq("routed", &f32_bytes(&q), &f["routed"]);
}
// ------------------------------------------------------------------------------------ control vector
#[test]
fn cvec_kernel_matches_the_reduction_tree_twin() {
let fx = fixture("emulated_kernels.json");
let f = &fx["cvec"];
let (n, hc, t_count, layer, l) = (
f["n"].as_u64().unwrap() as usize,
f["hc"].as_u64().unwrap() as usize,
f["T"].as_u64().unwrap() as usize,
f["layer"].as_u64().unwrap() as usize,
f["L"].as_u64().unwrap() as usize,
);
let unit = hex_f32(f["unit"].as_str().unwrap());
let add_dir = hex_f32(f["add_dir"].as_str().unwrap());
let r0 = hex_f32(f["r0"].as_str().unwrap());
let bo = hex_f32(f["bo"].as_str().unwrap());
let inj = hex_f32(f["inj"].as_str().unwrap());
// regenerate and cross-check the inputs
let mut g = Lcg::new(71);
let v: Vec<f32> = (0..n).map(|_| g.soft()).collect();
assert_eq!(v.iter().map(|x| x.to_bits()).collect::<Vec<_>>(), add_dir.iter().map(|x| x.to_bits()).collect::<Vec<_>>());
let r_ld = hc * n;
let table = |mode: CvecMode, dirv: &[f32], s_val: f32| {
let mut dir = vec![0.0f32; l * n];
let mut s = vec![0.0f32; l];
dir[layer * n..(layer + 1) * n].copy_from_slice(dirv);
s[layer] = s_val;
let steered = s.iter().map(|x| *x != 0.0).collect();
CvecTables { dir, s, mode, first: 1, last: l as i64 - 1, n_embd: n as i64, hc: hc as i64, steered, summary: String::new() }
};
let run = |t: &CvecTables, on: bool, layer_used: usize, write: bool| {
let mut r = r0.clone();
let pending = if write { Some((&bo[..], n, &inj[..], hc)) } else { None };
cvec::apply(&mut r, t, on, layer_used, t_count, r_ld, pending);
r
};
let cases: [(&str, Vec<f32>, bool); 8] = [
("project_s1", run(&table(CvecMode::Project, &unit, 1.0), true, layer, false), false),
("project_s2", run(&table(CvecMode::Project, &unit, 2.0), true, layer, false), false),
("add", run(&table(CvecMode::Add, &add_dir, 1.0), true, layer, false), false),
("off", run(&table(CvecMode::Project, &unit, 1.0), false, layer, false), false),
("off_write", run(&table(CvecMode::Project, &unit, 1.0), false, layer, true), true),
("project_write", run(&table(CvecMode::Project, &unit, 1.0), true, layer, true), true),
("add_write", run(&table(CvecMode::Add, &add_dir, 1.0), true, layer, true), true),
("no_direction_layer", run(&table(CvecMode::Project, &unit, 1.0), true, 1, false), false),
];
for (name, got, uses_sigmoid) in cases {
if !uses_sigmoid {
// no exp involved: bit-exact, including the dot reduction tree
assert_hex_eq(name, &f32_bytes(&got), &f[name]);
} else {
// the pending write evaluates sigmoid(): libm expf here, the device's __expf there. The harness and
// this test both use the platform libm, so they agree to a few ULP, not necessarily bit for bit.
let want = hex_f32(f[name].as_str().unwrap());
let mut worst = 0.0f32;
for (a, b) in got.iter().zip(&want) {
worst = worst.max((a - b).abs() / b.abs().max(1.0));
}
assert!(worst < 1e-5, "{name}: worst relative difference {worst}");
}
}
assert_eq!(f32_bytes(&r0), f32_bytes(&hex_f32(f["r0"].as_str().unwrap())));
}
// ------------------------------------------------------------------------------------------ attention
const CELLS: usize = 70;
const NQ: usize = 2;
const NH: usize = 24;
fn gqa_tensors(
ids: &[i32],
deq: &dyn Fn(&[i32]) -> Vec<f32>,
) -> Vec<f32> {
deq(ids)
}
fn check_attention(name: &str, got: &[f32], q: &[Vec<f32>], selections: &[Vec<i32>], k: &dyn Fn(&[i32]) -> Vec<f32>, v: &dyn Fn(&[i32]) -> Vec<f32>) {
assert_eq!(got.len(), NQ * NH * 256);
for b in 0..NQ {
let ids = &selections[b];
let want = attn::reference(&q[b], &gqa_tensors(ids, k), &gqa_tensors(ids, v), NH, 2, ids.len());
let (l2, max) = attn::errors(&got[b * NH * 256..(b + 1) * NH * 256], &want);
eprintln!("{name} query {b}: relative L2 {l2:e}, max abs {max:e}");
assert!(l2 < 1e-5 && max < 1e-5, "{name} query {b}: relative L2 {l2:e}, max abs {max:e}");
}
}
#[test]
fn quantized_attention_kernels_match_the_double_precision_reference() {
let fx = fixture("emulated_kernels.json");
let f = &fx["attn"];
let table: Vec<i32> = (0..18).map(|i| (i * 5 + 3) % 18).collect();
let rows = 18 * S.rows_per_page();
let mut g = Lcg::new(81);
let (mut kc, mut vc) = (Vec::new(), Vec::new());
for _ in 0..CELLS {
kc.push((0..512).map(|_| g.soft() * 1.5).collect::<Vec<f32>>());
vc.push((0..512).map(|_| g.soft() * 1.5).collect::<Vec<f32>>());
}
let q: Vec<f32> = (0..NQ * NH * 256).map(|_| g.soft()).collect();
let fnv = fnv1a(&f32_bytes(&q)) ^ fnv1a(&f32_bytes(&kc[0])).wrapping_mul(3) ^ fnv1a(&f32_bytes(&vc[CELLS - 1])).wrapping_mul(5);
assert_eq!(fnv as i64, f["input_fnv"].as_i64().unwrap());
let sel_full: Vec<i32> = (0..CELLS as i32).collect();
let sel_short: Vec<i32> = (0..66).collect();
let selections = vec![sel_full, sel_short];
let per_q = |x: &[f32]| -> Vec<Vec<f32>> { (0..NQ).map(|b| x[b * NH * 256..(b + 1) * NH * 256].to_vec()).collect() };
// ---- mode 2: Q4_0 K and V rotated, rotated query
{
let mut pools = PoolSet::new(KvFormat::Q4_0, &S, rows).unwrap();
for c in 0..CELLS {
cache::append_cell(KvFormat::Q4_0, &mut pools, None, &table, c as i64, &rotate(&kc[c]), &rotate(&vc[c]), &S, C).unwrap();
}
let qr = per_q(&rotate(&q));
let got = hex_f32(f["m2"]["out"].as_str().unwrap());
check_attention(
"mode 2",
&got,
&qr,
&selections,
&|ids| cache::dequant_q4(&pools.k_q4, &table, ids, &S).unwrap(),
&|ids| cache::dequant_q4(&pools.v_q4, &table, ids, &S).unwrap(),
);
}
// ---- mode 3: INT8 K (unrotated), Q4_0 V (rotated)
{
let mut pools = PoolSet::new(KvFormat::K8V4, &S, rows).unwrap();
for c in 0..CELLS {
cache::append_cell(KvFormat::K8V4, &mut pools, None, &table, c as i64, &kc[c], &rotate(&vc[c]), &S, C).unwrap();
}
let got = hex_f32(f["m3"]["out"].as_str().unwrap());
check_attention(
"mode 3",
&got,
&per_q(&q),
&selections,
&|ids| cache::dequant_q8(&pools.k_q, &pools.k_scale, &table, ids, &S).unwrap(),
&|ids| cache::dequant_q4(&pools.v_q4, &table, ids, &S).unwrap(),
);
}
// ---- mode 4: V-only, routed + position-encoded queries, keys rebuilt from V
{
let mut pools = PoolSet::new(KvFormat::Int8Keyless, &S, rows).unwrap();
for c in 0..CELLS {
cache::append_cell(KvFormat::Int8Keyless, &mut pools, None, &table, c as i64, &kc[c], &vc[c], &S, C).unwrap();
}
let cos = hex_f32(f["cos"].as_str().unwrap());
let sin = hex_f32(f["sin"].as_str().unwrap());
let mpos: Vec<i32> = (0..CELLS).flat_map(|cell| (0..3).map(move |sector| (cell / (sector + 2)) as i32)).collect();
let qpos = [CELLS as i32 - 1, 51];
let matrices = routing_matrices(NH);
let kids: Vec<Vec<i32>> = qpos.iter().map(|p| (0..=*p).filter(|c| c % 3 != 1).collect()).collect();
for (vision, key) in [(false, "m4"), (true, "m4_mrope")] {
let mut routed = q.clone();
keyless::route_query(&mut routed, &matrices, NQ, NH).unwrap();
for b in 0..NQ {
for h in 0..NH {
for d in 0..32 {
let i = (b * NH + h) * 256 + d;
let rp = if vision { mpos[qpos[b] as usize * 3 + d % 3] } else { qpos[b] } as usize;
let (a, v2, c, s) = (routed[i], routed[i + 32], cos[rp * 32 + d], sin[rp * 32 + d]);
routed[i] = a * c - v2 * s;
routed[i + 32] = a * s + v2 * c;
}
}
}
let got = hex_f32(f[key]["out"].as_str().unwrap());
let mrope = if vision { Some(&mpos[..]) } else { None };
let value = |ids: &[i32]| cache::dequant_q8(&pools.v_q, &pools.v_scale, &table, ids, &S).unwrap();
let keys = |ids: &[i32]| -> Vec<f32> {
let v = value(ids);
let mut out = Vec::with_capacity(v.len());
for (i, &cell) in ids.iter().enumerate() {
for kvh in 0..2 {
out.extend(keyless::key_from_value(&v[(i * 2 + kvh) * 256..][..256], cell, &cos, &sin, mrope));
}
}
out
};
check_attention(key, &got, &per_q(&routed), &kids, &keys, &value);
}
}
}
+20
View File
@@ -0,0 +1,20 @@
{"n_layers":6,"n_embd":40,"hc":4,"cases":[
{"name":"add_two_files","options":{"first":-1,"last":-1,"mode":1,"single":-1},"files":[{"label":"a.gguf","scale":1069547520,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"},{"label":"b.gguf","scale":3204448256,"bytes":"474755460300000002000000000000000100000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f720b00000000000000646972656374696f6e2e320100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3401000000280000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000001e368d3f1ca1a9bfc6b1debf4ebbb0bfc035b63e7651b2bfd24ba9bfe05585be38a6e3bed2729ebf70f6dbbf00610e3e6ab6d33f942d3c3fc8451e3ff015b53fac7df93fe66f85bf0291da3f600ce03f8090253d8c7b3a3f40122bbdcc479e3f84f8e43f0843bcbf886fb83f30057abe884c8ebf3055b13f4c06a9bfd872fcbeb6deedbfd4d306bf9607ae3f40d7bb3fa262833f6069293fa0f9a33e902ccebe72b1e93f0039fd3ea420c0bf20ec083f389ceabf4c02cf3f005513be9e46be3f02eba93fec1d063ffc4bf2bf6055f8be341fd23f2042873fa269d6bf74d062bfdc12993f4007bdbf8c636d3f6c8c743f8effdb3fb4e8ccbf7c3eb0bfe0dcde3fb88983be34c2723f8094c03f48e4bc3ef29cb93f5009c13e70df5fbfbcb3113fe0be2bbe4086c9be4ec6cabfa0b34fbe18106f3fb4ba363fd2c697bf7c0c93bf"}],"ok":1,"error":"","summary":"add:1-5","mode":1,"first":1,"last":5,"dir":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3222388501,1073877954,3218538465,3218125109,1069846423,3222238518,3212206856,3221738254,1068165355,3219579951,1068414425,1073343844,1031852816,1068782022,1055028496,1066245619,3204719742,1077837988,3213032955,1061185982,1077351472,3203025024,3222472444,3226183197,3216736485,1080839214,3197614040,1075045168,1043273736,1071870684,1058640558,3188901968,1074868798,3220664239,3192247848,3216426700,3217740166,1068512543,1062728660,1075060167,1077407624,1073983020,1059561766,1071629460,1049125952,3190315904,3213455276,3224325637,1055052524,1075898388,3218930267,1070467083,1053705356,1077717686,3221928430,3205298502,3172045216,3176762944,3214949849,1077155532,1041766080,1070506203,1047972504,1067580306,1068521418,1070598213,1075478039,1023041472,1071242277,3216776738,1075261168,1072507365,1076216399,3215840549,1077575244,3220872905,1050786656,1067553849,3204578640,1077215897,3211374962,3195877632,1061167268,3196644384,1063951416,3209626188,1033065728,3208529566,3207195394,3196460524,1064455164,1048073568,3209830196,3204923936,1062627746,1055051892,3206091484,1060964160,3203228556,3203697772,3210477454,1062004916,1060126332,3210665184,1040419256,3203580468,3208680576,3191661640,3208223986,3191933264,1054859120,3197219772,1034665696,1045005888,1061865038,1037022112,3203338264,3199646388,1058522834,1058212988,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"s":[0,0,1065353216,1065353216,1065353216,0]},
{"name":"add_range","options":{"first":2,"last":4,"mode":1,"single":-1},"files":[{"label":"a.gguf","scale":1065353216,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"},{"label":"b.gguf","scale":1073741824,"bytes":"474755460300000002000000000000000100000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f720b00000000000000646972656374696f6e2e320100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3401000000280000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000001e368d3f1ca1a9bfc6b1debf4ebbb0bfc035b63e7651b2bfd24ba9bfe05585be38a6e3bed2729ebf70f6dbbf00610e3e6ab6d33f942d3c3fc8451e3ff015b53fac7df93fe66f85bf0291da3f600ce03f8090253d8c7b3a3f40122bbdcc479e3f84f8e43f0843bcbf886fb83f30057abe884c8ebf3055b13f4c06a9bfd872fcbeb6deedbfd4d306bf9607ae3f40d7bb3fa262833f6069293fa0f9a33e902ccebe72b1e93f0039fd3ea420c0bf20ec083f389ceabf4c02cf3f005513be9e46be3f02eba93fec1d063ffc4bf2bf6055f8be341fd23f2042873fa269d6bf74d062bfdc12993f4007bdbf8c636d3f6c8c743f8effdb3fb4e8ccbf7c3eb0bfe0dcde3fb88983be34c2723f8094c03f48e4bc3ef29cb93f5009c13e70df5fbfbcb3113fe0be2bbe4086c9be4ec6cabfa0b34fbe18106f3fb4ba363fd2c697bf7c0c93bf"}],"ok":1,"error":"","summary":"add:2-4","mode":1,"first":2,"last":4,"dir":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1065822762,3219021204,3232087300,3230261281,1072518250,3231176343,3228472225,3221319787,3189168160,3229804802,3225838309,1070605624,1081716364,1076486275,1071539436,1082211444,1082558020,3202704976,1079202948,1083357874,1073747642,1068663822,3218113188,1061393428,1078763939,3212340652,1078626338,1064863096,3223238729,1083005484,3224082833,3214900826,3224680363,3223396555,1078119064,1075722460,1068194422,1075679021,1067950820,1058697408,1073037152,1068471014,1054835080,1066741176,1043716864,3185605120,3208069008,3219766620,1050097480,1071024838,3214102930,1065966258,1049199368,1073450568,3216570344,3199989512,3166836608,3172010368,3210061772,1072701030,1036699904,1065992338,1042581264,1062730264,1063985080,1066053678,1070464372,1017571968,1066483054,3212497624,1070175210,1067326446,1071448852,3211249372,1073260646,3215398022,1045931136,1062694988,3199029696,1072781516,1080668530,1065171200,3225428132,1065937952,3228212280,1078919756,3197326592,1077823134,1076488962,1065754092,3228716028,3212334432,1079123764,1074217504,3226888610,3219312756,1075385052,3225225024,1072522124,1072991340,1079771022,3226265780,3224387196,1079958752,3204680120,1072874036,1077974144,1060955208,1077517554,1061226832,3219119984,1066513340,3198926560,3209266752,3226125902,3201282976,1072631832,1068939956,3222783698,3222473852,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"s":[0,0,1065353216,1065353216,1065353216,0]},
{"name":"add_last_beyond_model","options":{"first":-1,"last":100,"mode":1,"single":-1},"files":[{"label":"a.gguf","scale":1048576000,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"}],"ok":1,"error":"","summary":"add:1-5","mode":1,"first":1,"last":5,"dir":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3197321746,1047120200,3201929346,3200649704,1049770378,3204102000,3196751774,3200267750,1044246576,3201220198,1034722392,1051495672,1041752200,1050121074,1040203336,1050330610,1033664232,1053918776,3169292224,1049285130,1056298092,3162435520,3200635264,3202008462,3183654664,1056722746,1032897744,1052427272,3179503112,1053998670,3156529472,3179615160,1046780972,3199954370,1034295312,3186422560,3191264668,1049736442,1043024936,1052004008,1056259936,1051693798,1038057864,1049963960,1026939648,3168827904,3191291792,3202989404,1033320264,1054247622,3197325714,1049189042,1032422152,1056673352,3199793128,3183212296,3150059392,3155233152,3193284556,1055923814,1019922688,1049215122,1025804048,1045953048,1047207864,1049276462,1053687156,1000794752,1049705838,3195720408,1053397994,1050549230,1054671636,3194472156,1056483430,3198620806,1029153920,1045917772,3182252480,1056004300,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"s":[0,0,1065353216,1065353216,0,0]},
{"name":"project_two_files","options":{"first":-1,"last":-1,"mode":0,"single":-1},"files":[{"label":"a.gguf","scale":1065353216,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"},{"label":"b.gguf","scale":1065353216,"bytes":"474755460300000002000000000000000100000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f720b00000000000000646972656374696f6e2e320100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3401000000280000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000001e368d3f1ca1a9bfc6b1debf4ebbb0bfc035b63e7651b2bfd24ba9bfe05585be38a6e3bed2729ebf70f6dbbf00610e3e6ab6d33f942d3c3fc8451e3ff015b53fac7df93fe66f85bf0291da3f600ce03f8090253d8c7b3a3f40122bbdcc479e3f84f8e43f0843bcbf886fb83f30057abe884c8ebf3055b13f4c06a9bfd872fcbeb6deedbfd4d306bf9607ae3f40d7bb3fa262833f6069293fa0f9a33e902ccebe72b1e93f0039fd3ea420c0bf20ec083f389ceabf4c02cf3f005513be9e46be3f02eba93fec1d063ffc4bf2bf6055f8be341fd23f2042873fa269d6bf74d062bfdc12993f4007bdbf8c636d3f6c8c743f8effdb3fb4e8ccbf7c3eb0bfe0dcde3fb88983be34c2723f8094c03f48e4bc3ef29cb93f5009c13e70df5fbfbcb3113fe0be2bbe4086c9be4ec6cabfa0b34fbe18106f3fb4ba363fd2c697bf7c0c93bf"}],"ok":1,"error":"","summary":"project:1-5","mode":0,"first":1,"last":5,"dir":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3146255891,3172225868,3197814934,3196306029,1040636166,3197556321,3193468950,3189675855,1020662670,3196085342,3187189158,1040570305,1045054175,1043119393,1036613255,1047275664,1045098226,1029046413,1041203733,1048520320,1043365407,1030739879,3188644548,3173655323,1040026427,1026827211,1041965645,1037742738,3187035321,1049128956,3186946325,3179776622,3182281938,3191025953,1041731794,1035262648,1021367269,1042416547,1035081928,1035277426,1049001104,1044418335,1031086293,1042521150,1019704011,3161862486,3184064986,3196071182,1025890371,1047219219,3189871112,1041671266,1024905375,1049227809,3192577227,3176015393,3142901334,3147764085,3186250532,1048816784,1012819746,1041699869,1018458552,1038933742,1040248672,1041767143,1046604533,993464398,1042238057,3188296536,1046287397,1043163040,1047684253,3187553022,1049123661,3191291493,1022132495,1038895054,3174962724,1048860920,1048034798,1032206597,3192630640,1032922964,3195582161,1046180894,3164352616,1045018347,1043603969,1032728051,3196087920,3179520406,1046397166,1041195960,3194178917,3186651922,1042433697,3192415322,1039902952,1040293884,1047083335,3193518644,3191527127,1047282350,3171643919,1040231706,1045178435,1028144968,1044694397,1028432921,3186447562,1033532942,3166048768,3176506282,3193370357,3168546843,1040019255,1036105437,3189827233,3189498760,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"s":[0,0,1094060510,1089039156,1089567650,0]},
{"name":"project_range","options":{"first":2,"last":5,"mode":0,"single":-1},"files":[{"label":"a.gguf","scale":1061158912,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"},{"label":"b.gguf","scale":1056964608,"bytes":"474755460300000002000000000000000100000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f720b00000000000000646972656374696f6e2e320100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3401000000280000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000001e368d3f1ca1a9bfc6b1debf4ebbb0bfc035b63e7651b2bfd24ba9bfe05585be38a6e3bed2729ebf70f6dbbf00610e3e6ab6d33f942d3c3fc8451e3ff015b53fac7df93fe66f85bf0291da3f600ce03f8090253d8c7b3a3f40122bbdcc479e3f84f8e43f0843bcbf886fb83f30057abe884c8ebf3055b13f4c06a9bfd872fcbeb6deedbfd4d306bf9607ae3f40d7bb3fa262833f6069293fa0f9a33e902ccebe72b1e93f0039fd3ea420c0bf20ec083f389ceabf4c02cf3f005513be9e46be3f02eba93fec1d063ffc4bf2bf6055f8be341fd23f2042873fa269d6bf74d062bfdc12993f4007bdbf8c636d3f6c8c743f8effdb3fb4e8ccbf7c3eb0bfe0dcde3fb88983be34c2723f8094c03f48e4bc3ef29cb93f5009c13e70df5fbfbcb3113fe0be2bbe4086c9be4ec6cabfa0b34fbe18106f3fb4ba363fd2c697bf7c0c93bf"}],"ok":1,"error":"","summary":"project:2-5","mode":0,"first":2,"last":5,"dir":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3174142913,994812311,3197695382,3196321448,1041471445,3197793097,3193053922,3191027731,1027516016,3196226040,3182230788,1041899911,1043689076,1043536900,1036213990,1046888781,1043051683,1036617897,1037787003,1047583805,1045452724,1026895218,3190312892,3183300223,1034799652,1037300966,1040515984,1040887427,3184883886,1049196716,3183802194,3179012706,3172205632,3192010269,1040428014,1029479592,3142366458,1042872797,1035786618,1039398067,1049001104,1044418334,1031086293,1042521150,1019704011,3161862487,3184064986,3196071182,1025890371,1047219219,3189871112,1041671266,1024905375,1049227809,3192577227,3176015394,3142901334,3147764085,3186250532,1048816784,1012819746,1041699869,1018458552,1038933743,1040248672,1041767143,1046604533,993464398,1042238057,3188296536,1046287398,1043163040,1047684253,3187553022,1049123661,3191291493,1022132495,1038895054,3174962724,1048860920,1048034798,1032206597,3192630640,1032922964,3195582161,1046180894,3164352616,1045018347,1043603969,1032728051,3196087920,3179520406,1046397166,1041195960,3194178917,3186651922,1042433697,3192415322,1039902952,1040293884,1047083335,3193518644,3191527127,1047282350,3171643919,1040231706,1045178435,1028144968,1044694397,1028432921,3186447562,1033532942,3166048768,3176506282,3193370357,3168546843,1040019255,1036105437,3189827233,3189498760,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"s":[0,0,1088797105,1085214823,1081179042,0]},
{"name":"project_single_layer","options":{"first":-1,"last":-1,"mode":0,"single":3},"files":[{"label":"a.gguf","scale":1065353216,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"}],"ok":1,"error":"","summary":"project:1-5:single3","mode":0,"first":1,"last":5,"dir":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1049001104,1044418335,1031086293,1042521150,1019704011,3161862486,3184064986,3196071182,1025890371,1047219219,3189871112,1041671266,1024905375,1049227809,3192577227,3176015393,3142901334,3147764085,3186250532,1048816784,1012819746,1041699869,1018458552,1038933742,1040248672,1041767143,1046604533,993464398,1042238057,3188296536,1046287397,1043163040,1047684253,3187553022,1049123661,3191291493,1022132495,1038895054,3174962724,1048860920,1049001104,1044418335,1031086293,1042521150,1019704011,3161862486,3184064986,3196071182,1025890371,1047219219,3189871112,1041671266,1024905375,1049227809,3192577227,3176015393,3142901334,3147764085,3186250532,1048816784,1012819746,1041699869,1018458552,1038933742,1040248672,1041767143,1046604533,993464398,1042238057,3188296536,1046287397,1043163040,1047684253,3187553022,1049123661,3191291493,1022132495,1038895054,3174962724,1048860920,1049001104,1044418335,1031086293,1042521150,1019704011,3161862486,3184064986,3196071182,1025890371,1047219219,3189871112,1041671266,1024905375,1049227809,3192577227,3176015393,3142901334,3147764085,3186250532,1048816784,1012819746,1041699869,1018458552,1038933742,1040248672,1041767143,1046604533,993464398,1042238057,3188296536,1046287397,1043163040,1047684253,3187553022,1049123661,3191291493,1022132495,1038895054,3174962724,1048860920,1049001104,1044418335,1031086293,1042521150,1019704011,3161862486,3184064986,3196071182,1025890371,1047219219,3189871112,1041671266,1024905375,1049227809,3192577227,3176015393,3142901334,3147764085,3186250532,1048816784,1012819746,1041699869,1018458552,1038933742,1040248672,1041767143,1046604533,993464398,1042238057,3188296536,1046287397,1043163040,1047684253,3187553022,1049123661,3191291493,1022132495,1038895054,3174962724,1048860920,1049001104,1044418335,1031086293,1042521150,1019704011,3161862486,3184064986,3196071182,1025890371,1047219219,3189871112,1041671266,1024905375,1049227809,3192577227,3176015393,3142901334,3147764085,3186250532,1048816784,1012819746,1041699869,1018458552,1038933742,1040248672,1041767143,1046604533,993464398,1042238057,3188296536,1046287397,1043163040,1047684253,3187553022,1049123661,3191291493,1022132495,1038895054,3174962724,1048860920],"s":[0,1089039156,1089039156,1089039156,1089039156,1089039156]},
{"name":"project_single_missing","options":{"first":-1,"last":-1,"mode":0,"single":5},"files":[{"label":"a.gguf","scale":1065353216,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"}],"ok":0,"error":"--cvec-dir single:5: the vector has no direction for that layer"},
{"name":"add_ignores_single","options":{"first":-1,"last":-1,"mode":1,"single":5},"files":[{"label":"a.gguf","scale":1065353216,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"}],"ok":1,"error":"","summary":"add:1-5","mode":1,"first":1,"last":5,"dir":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3214098962,1063897416,3218706562,3217426920,1066547594,3220879216,3213528990,3217044966,1061023792,3217997414,1051499608,1068272888,1058529416,1066898290,1056980552,1067107826,1050441448,1070695992,3186069440,1066062346,1073075308,3179212736,3217412480,3218785678,3200431880,1073499962,1049674960,1069204488,3196280328,1070775886,3173306688,3196392376,1063558188,3216731586,1051072528,3203199776,3208041884,1066513658,1059802152,1068781224,1073037152,1068471014,1054835080,1066741176,1043716864,3185605120,3208069008,3219766620,1050097480,1071024838,3214102930,1065966258,1049199368,1073450568,3216570344,3199989512,3166836608,3172010368,3210061772,1072701030,1036699904,1065992338,1042581264,1062730264,1063985080,1066053678,1070464372,1017571968,1066483054,3212497624,1070175210,1067326446,1071448852,3211249372,1073260646,3215398022,1045931136,1062694988,3199029696,1072781516,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"s":[0,0,1065353216,1065353216,0,0]},
{"name":"nothing_in_range","options":{"first":5,"last":5,"mode":1,"single":-1},"files":[{"label":"a.gguf","scale":1065353216,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"}],"ok":0,"error":"the control vector has no direction in layers 5..5"},
{"name":"zero_scale_project","options":{"first":-1,"last":-1,"mode":0,"single":-1},"files":[{"label":"a.gguf","scale":0,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"}],"ok":0,"error":"the control vector has no direction in layers 1..5"},
{"name":"zero_direction_project","options":{"first":-1,"last":-1,"mode":0,"single":-1},"files":[{"label":"z.gguf","scale":1065353216,"bytes":"474755460300000001000000000000000100000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f720b00000000000000646972656374696f6e2e32010000002800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}],"ok":0,"error":"the control vector has no direction in layers 1..5"},
{"name":"wrong_architecture","options":{"first":-1,"last":-1,"mode":1,"single":-1},"files":[{"label":"w.gguf","scale":1065353216,"bytes":"474755460300000001000000000000000100000000000000140000000000000067656e6572616c2e6172636869746563747572650800000005000000000000006c6c616d610b00000000000000646972656374696f6e2e3201000000280000000000000000000000000000000000000000000000000000000000000000000000008be6bd983599be5224a2bfa091cf3e5a4ae1bfb078703edc077d3f1070b6be108da3be9c898d3ff06edfbf10017ebfc02bce3e84774f3ff4ae4abf04b2ba3f0074e4be006abe3be6cbea3f209a633fb0451ebf384eedbfe60ab03fc075383d7c75633f0463dcbf42439bbf2c563abf42caecbf963fc2bfbedeebbfd0b7c9bfbc9a493fe8b17c3fd4c78cbfc03262bd40877f3e6023e43fc8bb7a3f687ba6be"}],"ok":0,"error":"w.gguf: not a control vector GGUF (general.architecture is not 'controlvector')"},
{"name":"wrong_shape","options":{"first":-1,"last":-1,"mode":1,"single":-1},"files":[{"label":"s.gguf","scale":1065353216,"bytes":"474755460300000001000000000000000100000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f720b00000000000000646972656374696f6e2e320100000029000000000000000000000000000000000000000000000000000000e8df14bfc077f13e404dc33ebcec91bff031fb3ff008ed3f74f9db3f7c1a703fb61399bf98aac33f0c68df3fd08f743ece47de3f28bdd1bff4bd61bf70f8be3ede51b6bf30d43fbed4ba403fb80fc13f5aaf8dbf30f9253ecc3e863f46dce33f10f72f3f00bb9e3c1276ce3fb82bd73ea0665bbffe46b73fb27ee63f9e26b23fb8802ebf4852743f7650dd3ff46cc93f64c4fcbfa07d8fbd1645e9bf2e7bf23ffa08cd3f00000000000000000000000000000000000000000000000000000000"}],"ok":0,"error":"s.gguf: direction.2 must be 40 f32"},
{"name":"wrong_type","options":{"first":-1,"last":-1,"mode":1,"single":-1},"files":[{"label":"t.gguf","scale":1065353216,"bytes":"474755460300000001000000000000000100000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f720b00000000000000646972656374696f6e2e3201000000280000000000000001000000000000000000000000000000000000002e5c8f3fd6c4fdbf782ff7bec093abbfd84aefbee0d4aabdf419553fdcd55fbf6016913d001606bd42a6bdbfd07a393e403b423d1608ffbf9479f23fc2def1bf54e5d4bf509c4b3e8c6cbebf10ed113e9c83cd3ffe95acbf64f5603f8cafc5bf981027bfc246843f80e61d3d1c31a63fe8a8b0bfa4c6e63fd2b5913f9283e63f6477b9bf8cfbe9bfc835973ee8162d3f283154bf143ede3f74a15a3fe8c240bf"}],"ok":0,"error":"t.gguf: direction.2 must be 40 f32"},
{"name":"no_direction_tensors","options":{"first":-1,"last":-1,"mode":1,"single":-1},"files":[{"label":"n.gguf","scale":1065353216,"bytes":"474755460300000001000000000000000100000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f7207000000000000006f746865722e3201000000280000000000000000000000000000000000000000000000000000000000000038aa39bff00c733f6c6aee3fa441bc3fa48176bf2e8594bf602d233ffc5acd3f4c93a63f00b72fbfe0e9333eb841af3fe83995befeea9bbf40c40fbd5ab2a73fccf92d3fccdef0bf30ea023f58bcfc3fa057debe2071c6be64ee1fbfb0bd81be1cfa64bfb2a2933f4065443eccbca1bf8095dfbc9a6df5bf5014183e6886bdbea83c53bf20b17abede49963f84c14a3fdcb8e8bf600b2abf526fd63f0071e03c"}],"ok":0,"error":"n.gguf: no direction.<layer> tensors"},
{"name":"only_layer_zero","options":{"first":-1,"last":-1,"mode":1,"single":-1},"files":[{"label":"o.gguf","scale":1065353216,"bytes":"474755460300000001000000000000000100000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f720b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000000000000000000ec497dbf60e82abe08bab6be4438a7bf6474313fb278ecbf903071be3ad2cebfd2b4ecbfa2b28bbfe0e4c43e0086393c98ff7fbfb2d0e03f081064bf2046fcbdb085b63f921e8fbf980cb0be608ce83e3e78e63feccddebf526ffbbf2c85d53fc6ecf0bfbed3923fb213c8bfe4dc553f8050873f10fa3bbe3223963f085a49bfd0dc9abecc1794bf04db42bf204dddbfaeceb6bf80deb2bff8299a3f306ca63e"}],"ok":0,"error":"o.gguf: no direction.<layer> tensors"},
{"name":"truncated","options":{"first":-1,"last":-1,"mode":1,"single":-1},"files":[{"label":"x.gguf","scale":1065353216,"bytes":"474755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d000000"}],"ok":0,"error":"GGUF: unexpected end of file in header"},
{"name":"bad_magic","options":{"first":-1,"last":-1,"mode":1,"single":-1},"files":[{"label":"m.gguf","scale":1065353216,"bytes":"584755460300000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"}],"ok":0,"error":"not a GGUF file (bad magic)"},
{"name":"version_2","options":{"first":-1,"last":-1,"mode":1,"single":-1},"files":[{"label":"v.gguf","scale":1065353216,"bytes":"474755460200000004000000000000000200000000000000140000000000000067656e6572616c2e617263686974656374757265080000000d00000000000000636f6e74726f6c766563746f721800000000000000636f6e74726f6c766563746f722e6d6f64656c5f68696e740800000008000000000000007177656e346578700b00000000000000646972656374696f6e2e300100000028000000000000000000000000000000000000000b00000000000000646972656374696f6e2e3201000000280000000000000000000000a0000000000000000b00000000000000646972656374696f6e2e330100000028000000000000000000000040010000000000000b00000000000000646972656374696f6e2e3901000000280000000000000000000000e00100000000000000000000000000000000000000000000000000b4af123f00159bbc6094d63fa2e1f93f3aeacfbf9cfcd33fec02103f4c38f73f3ae6ee3f38db23bf580254bf0068b0bb0486163fc806f7bf40520abff4c15f3f38ad3c3f6888f43f065d863fa03d38be9859673f006165bcf0e89abfe0f3d4bd5ab8f33fccb37ebf90a4fe3f043b9dbfb0b5023e3c55063faced093f8cbc7abf708b253e7003043e5cdf37bf04bcc53fc497d63f508c4c3fde79933f447ed53f124293bf48c9693f8290d9bfe809c6bf8a39923f70b7fabf9e8f8abfe635c0bf30f03d3f66becebf589cac3ef88cac3f88e0173f7293973f483e003ff2c59a3fe8769c3e3886d13fc08fe7bd0ad28a3f6cd4f53fc0ef7ebd80d1c5bf8ec5dabf08b7c2be3a4ffc3fd0c4903e08c4ba3f085e83be4ebed23f40d124bdb81385be2c9c643fc26dbbbf1018a63e20f3ecbe9cd536bffab4913f284c2b3fa84eb43f603ff53fe692af3f8881df3eb82d953f00db353e007ae0bd903f37bf5cbde9bf4837973ec68ad63f925193bfb25a893f0883893e488efb3fe8f7b8bf08f7bbbe8017c2bc800911bdcca755bf661ef03f00c9ca3d92c0893f1087243e18fa573fb81f6b3f2eb08a3f74fdcd3f80eaa63c6e3d913fd8d27abfea93c93fee1b9e3f1403dd3fdcc667bf66a8f83f8614a7bf80a4573e4c70573fc051adbecc58f13f5c19b8bf807fb8bdb01c163e0093bb3fe802f4bf66d2a43f8868eb3f98cf6e3f66cca3bf2e37a63feca3a53f8077d63e5c1878bfa87bb43fae6e9e3f6a1ed9bfb6a2cc3fe05ba13e465283bf387fcc3f087def3f7aacdebfe896b83ea8b07fbf34c8203f6c5525bf908824bf3869d73efa5994bf3638b9bf1470133f7aaf963fb46191bf3443483f9217ef3fd80b3b3f2200ef3f64d0e03fc00cd43d7c43703f"}],"ok":0,"error":"GGUF v2, this reader handles v3"}]}
File diff suppressed because one or more lines are too long