Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
a6a5338
feat(KERNEL-ATTN-PAGED): the additive ggml-flash-order arm of the CPU…
lu-zero Nov 30, 2026
ba60c01
records(KERNEL-ATTN-PAGED): the canonical issue for the ggml-flash-or…
lu-zero Nov 30, 2026
4a93830
test(KERNEL-ATTN-PAGED): a byte-exact default-body pin in the sibling…
lu-zero Nov 30, 2026
daffced
records(KERNEL-ATTN-PAGED): the F1 sibling byte-pin repair evidence
lu-zero Nov 30, 2026
ce02fac
fix(KERNEL-ATTN-PAGED): the ggml-flash-order S recurrence contracts p…
lu-zero Dec 2, 2026
594e9e2
spec(ENG-CHUNKED-PREFILL): prefill graph formation mirrors the oracle…
lu-zero Nov 27, 2026
b7c10d7
docs(ENG-CHUNKED-PREFILL): amend the spec to the pinned server checkp…
lu-zero Nov 29, 2026
1c627cc
feat(ENG-CHUNKED-PREFILL): engine prefill chunking mirrors the oracle…
lu-zero Nov 29, 2026
f9eed4a
test(ENG-CHUNKED-PREFILL): reach the production chunk-forward loop an…
lu-zero Nov 29, 2026
45ba384
docs(ENG-CHUNKED-PREFILL): record the F1/F2 repair round mutation-RED…
lu-zero Nov 29, 2026
8a015e2
fix(ENG-CHUNKED-PREFILL): repair the record anchors the rebase surfaced
lu-zero Nov 29, 2026
d1354a6
fix(ENG-CHUNKED-PREFILL): ride the hybrid empty slot_mapping through …
lu-zero Nov 29, 2026
9c7d7e7
docs(ENG-CHUNKED-PREFILL): close the falsified parity premise and rec…
lu-zero Nov 29, 2026
10c5fd8
docs(ENG-CHUNKED-PREFILL): correct the closure record after the secon…
lu-zero Nov 29, 2026
2193bb2
feat(QUANT-GGUF-CIQ-GEMM): the Q4_K/Q6_K repack seam — oracle-class g…
Nov 29, 2026
0b94f96
fix(QUANT-GGUF-CIQ-GEMM): repair the x86 CI lane and the fixture hash…
lu-zero Dec 2, 2026
4e1ae3c
fix(QUANT-GGUF-CIQ-GEMM): guard the remaining two arm-only test helpers
lu-zero Dec 3, 2026
b2d0490
records(NEW-CANDIDATE-PORTS): reconcile the olala W2 oracle issue wit…
lu-zero Nov 29, 2026
39a7546
test(ENG-CHUNKED-PREFILL): prove the chunk hand-off on sequential req…
lu-zero Dec 2, 2026
c97b43a
record(ENG-CHUNKED-PREFILL): import the consumer's cross-request chun…
lu-zero Dec 2, 2026
47c86f0
docs(NEW-CANDIDATE-PORTS): specify inkling2_loop W1, the CPU forward …
lu-zero Nov 25, 2026
633f98e
feat(NEW-CANDIDATE-PORTS): port inkling2_loop W1 CPU forward
lu-zero Nov 25, 2026
7698ca1
fix(NEW-CANDIDATE-PORTS): serve padded logits and pin W1 decode consi…
lu-zero Nov 25, 2026
0320c95
test(NEW-CANDIDATE-PORTS): map inkling2 divergence and audit forward ops
lu-zero Nov 25, 2026
e41c4bf
fix(NEW-CANDIDATE-PORTS): correct conv history, GQA mapping and softm…
lu-zero Nov 25, 2026
5cface8
fix(NEW-CANDIDATE-PORTS): isolate first bad op to layer 5 dynamic sho…
lu-zero Nov 26, 2026
8001628
docs(NEW-CANDIDATE-PORTS): record remaining f32 reduction-order drift
lu-zero Nov 26, 2026
395d26a
docs(NEW-CANDIDATE-PORTS): localize divergence to loop-pass bank and …
lu-zero Nov 26, 2026
6ccd507
docs(NEW-CANDIDATE-PORTS): record pass-1 bank probe and own the bank
lu-zero Nov 26, 2026
b5eb891
docs(NEW-CANDIDATE-PORTS): tagged taps settle pass-1 bank question
lu-zero Nov 26, 2026
ca145f5
perf(NEW-CANDIDATE-PORTS): mirror ggml query-fastest AttnRes mix layout
lu-zero Nov 26, 2026
ae30810
perf(NEW-CANDIDATE-PORTS): mirror ggml quantized-input Q8_0 and NVFP4…
lu-zero Nov 26, 2026
86ef922
perf(NEW-CANDIDATE-PORTS): mirror ggml BF16 activation quantization
lu-zero Nov 26, 2026
e8e0021
perf(NEW-CANDIDATE-PORTS): mirror ggml Q5_K/Q8_K expert dots and lock…
lu-zero Nov 26, 2026
fc11127
test(NEW-CANDIDATE-PORTS): record attention score tap attempt
lu-zero Nov 26, 2026
abb616e
perf(NEW-CANDIDATE-PORTS): mirror ggml flash attention for the CPU arm
lu-zero Nov 26, 2026
3b40f32
docs(NEW-CANDIDATE-PORTS): record flash path and oracle capture hazards
lu-zero Nov 26, 2026
f806e1a
perf(NEW-CANDIDATE-PORTS): mirror the oracle's F16 KV cache rounding
lu-zero Nov 26, 2026
93571ae
docs(NEW-CANDIDATE-PORTS): record the batch-shape mechanism finding
lu-zero Nov 27, 2026
c3a4532
perf(NEW-CANDIDATE-PORTS): add bit-proven nrc=2 mmla Q8_0 projection …
lu-zero Nov 27, 2026
4ab5845
perf(NEW-CANDIDATE-PORTS): select the mmla Q8_0 projection by batch s…
lu-zero Nov 27, 2026
b0e1d28
docs(NEW-CANDIDATE-PORTS): stop the oracle instrument hunt and record…
lu-zero Nov 27, 2026
2448e3e
docs(NEW-CANDIDATE-PORTS): record shared-seam repack GEMM bit-proof gap
lu-zero Nov 27, 2026
427dbc9
fix(QUANT-GGUF-CIQ-GEMM): mirror ggml's fused Q8_0 gemm accumulation
lu-zero Nov 27, 2026
12a56f1
test(NEW-CANDIDATE-PORTS): add seam bit-proof test and records for Q8…
lu-zero Nov 27, 2026
717b68b
docs(NEW-CANDIDATE-PORTS): cache-write tap exonerates F16 rounding
lu-zero Nov 27, 2026
678fe41
docs(NEW-CANDIDATE-PORTS): per-position preconv/postconv localization…
lu-zero Nov 27, 2026
72a3548
perf(NEW-CANDIDATE-PORTS): consume chunked-prefill seam in W1 gate co…
lu-zero Nov 29, 2026
31babdc
docs(NEW-CANDIDATE-PORTS): record kernel-class falsification and gate…
lu-zero Nov 29, 2026
6fac597
docs(NEW-CANDIDATE-PORTS): record the inkling2 three-way verdict
lu-zero Nov 29, 2026
4cbd7c8
fix(NEW-CANDIDATE-PORTS): q8 tie-rounding nearest-even and layer-majo…
lu-zero Dec 2, 2026
df15775
fix(NEW-CANDIDATE-PORTS): bit-match inkling2 clip, rms-norm and short…
lu-zero Dec 2, 2026
3afcdf8
docs(NEW-CANDIDATE-PORTS): record wave-5 and wave-6 conv/clip stage p…
lu-zero Dec 2, 2026
6a27147
fix(NEW-CANDIDATE-PORTS): bit-match inkling2 flash attention to ggml …
lu-zero Dec 3, 2026
7bc9040
fix(NEW-CANDIDATE-PORTS): bit-match inkling2 norm, clip, gate/wo rout…
lu-zero Dec 3, 2026
df9fd6d
fix(NEW-CANDIDATE-PORTS): bit-match inkling2 MoE router, weight norm,…
lu-zero Dec 3, 2026
c4b3fed
fix(NEW-CANDIDATE-PORTS): bit-match inkling2 sink recurrence and rela…
lu-zero Dec 3, 2026
fafe84a
fix(NEW-CANDIDATE-PORTS): bit-match inkling2 n>=3 bank-mix combine to…
Dec 3, 2026
5e24a24
fix(NEW-CANDIDATE-PORTS): bit-match inkling2 f32 MatVec dot to ggml_v…
lu-zero Dec 3, 2026
a8db84a
docs(NEW-CANDIDATE-PORTS): record wave-12 decode-step bisect in PROCE…
lu-zero Dec 3, 2026
14906db
fix(NEW-CANDIDATE-PORTS): normalize inkling2 loop-control halves sepa…
lu-zero Dec 3, 2026
6223dde
fix(NEW-CANDIDATE-PORTS): route inkling2 Q8_0 expert down through the…
lu-zero Dec 3, 2026
21cd64d
fix(NEW-CANDIDATE-PORTS): route inkling2 Q5_K experts through the tra…
lu-zero Dec 3, 2026
a75db92
records(NEW-CANDIDATE-PORTS): complete the inkling2 W1 row and reconc…
lu-zero Dec 3, 2026
cf86e1f
fix(NEW-CANDIDATE-PORTS): void the unused nc in the Q5_K scalar fallback
lu-zero Dec 4, 2026
2e81f2c
ci(NEW-CANDIDATE-PORTS): point the arm64 lane at the gated K-quant re…
lu-zero Dec 5, 2026
71545e9
fix(KERNEL-ATTN-PAGED): the ggml-flash-order vkq V accumulation contr…
lu-zero Dec 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .agents/engine-matrix.md

Large diffs are not rendered by default.

273 changes: 273 additions & 0 deletions .agents/evidence/eng-chunked-prefill-20261128/PROCESS.md

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions .agents/evidence/inkling2-loop-w1-20261125/PROCESS.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"gen": [152717, 13, 68014, 32], "ptoks": [371, 151451, 149879, 151194, 149884]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"gen": [152717, 13, 68014, 32], "ptoks": [371, 151451, 149879, 151194, 149884]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"gen": [152717, 13, 68014, 32], "ptoks": [371, 151451, 149879, 151194, 149884]}
149 changes: 149 additions & 0 deletions .agents/evidence/inkling2-loop-w1-20261125/threeway-harness.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// Three-way probe: oracle kproj tap vs ggml mul_mat on the oracle's own captured
// inputs and weights. Scratch instrument, /tmp only.
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"
#include "ggml-cpu.h"
#include "gguf.h"
#include "ggml-backend-impl.h"
#include <dlfcn.h>
using repack_buft_fn = ggml_backend_buffer_type_t (*)(void);
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdint>

int main(int argc, char ** argv) {
const char * gguf_path = argv[1];
const char * tap_path = argv[2];
int n_tok = atoi(argv[3]);

// ---- load taps (kproj_in and kproj, il=0, the record with this token count) ----
// tap file format: INK2TAP1, then per record: il(4) qlen(4) q taglen(4) tag count(8) f32*
std::vector<float> kproj_in, kproj;
int64_t in_rows = 0, out_rows = 0;
{
FILE * f = fopen(tap_path, "rb");
if (!f) { fprintf(stderr, "cannot open %s\n", tap_path); return 1; }
char magic[8]; fread(magic, 1, 8, f);
while (true) {
int32_t il, qlen;
if (fread(&il, 4, 1, f) != 1) break;
fread(&qlen, 4, 1, f);
char q[128]; fread(q, 1, qlen, f); q[qlen] = 0;
int32_t tl; fread(&tl, 4, 1, f);
char tag[256]; fread(tag, 1, tl, f); tag[tl] = 0;
int64_t n; fread(&n, 8, 1, f);
std::vector<float> v(n);
fread(v.data(), 4, n, f);
if (il == 0 && strcmp(q, "kproj_in") == 0 && n / 2304 == n_tok) {
kproj_in = v; in_rows = 2304;
fprintf(stderr, "kproj_in rec: n=%lld tag=%s\n", (long long) n, tag);
}
if (il == 0 && strcmp(q, "kproj") == 0 && n / 1024 == n_tok) {
kproj = v; out_rows = 1024;
fprintf(stderr, "kproj rec: n=%lld tag=%s\n", (long long) n, tag);
}
}
fclose(f);
}
if (kproj_in.empty() || kproj.empty()) { fprintf(stderr, "taps not found\n"); return 1; }

// ---- load weight ----
gguf_init_params params = { true, nullptr };
gguf_context * gu = gguf_init_from_file(gguf_path, params);
if (!gu) { fprintf(stderr, "gguf load failed\n"); return 1; }
const char * wname = "blk.0.attn_k.weight";
int wi = gguf_find_tensor(gu, wname);
if (wi < 0) { fprintf(stderr, "tensor %s not found\n", wname); return 2; }
enum ggml_type wt = gguf_get_tensor_type(gu, wi);
size_t wofs = gguf_get_data_offset(gu) + gguf_get_tensor_offset(gu, wi);
// dims from gguf
int64_t wne[4];
{ const int64_t * wne_p = gguf_get_tensor_ne(gu, wi); for (int k = 0; k < 4; ++k) wne[k] = wne_p[k]; }

ggml_init_params ip = { 1024ull*1024*64, NULL, true };
ggml_context * wctx = ggml_init(ip);
ggml_tensor * wt_meta = ggml_new_tensor(wctx, wt, 4, wne);
size_t wnbytes = ggml_nbytes(wt_meta);
fprintf(stderr, "weight %s type=%s ne=[%lld,%lld,%lld,%lld] bytes=%zu\n", wname, ggml_type_name(wt),
(long long) wne[0], (long long) wne[1], (long long) wne[2], (long long) wne[3], wnbytes);
ggml_free(wctx);

void * wdata = malloc(wnbytes);
{
FILE * f = fopen(gguf_path, "rb");
fseek(f, wofs, SEEK_SET);
if (fread(wdata, 1, wnbytes, f) != wnbytes) { fprintf(stderr, "weight read failed\n"); return 1; }
fclose(f);
}

fprintf(stderr, "weight %s type=%s ne=[%lld,%lld,%lld,%lld] bytes=%zu\n", wname, ggml_type_name(wt),
(long long) wne[0], (long long) wne[1], (long long) wne[2], (long long) wne[3], wnbytes);

// ---- build both computations ----
size_t buf_sz = 512ull * 1024 * 1024;
void * buf = malloc(buf_sz);
ggml_context * ctx = ggml_init({ buf_sz, buf, false });
ggml_tensor * W = ggml_new_tensor(ctx, wt, 4, wne);
{ // route the weight exactly like llama-server: CPU_REPACK buffer -> gemm q8_0_4x8
void * hcpu = dlopen("/tmp/llamacpp-inkling-tap-build/bin/libggml-cpu.so.1", 2 | 0x100);
auto fn = (repack_buft_fn) dlsym(hcpu, "_Z35ggml_backend_cpu_repack_buffer_typev");
if (!fn) { fprintf(stderr, "dlsym repack buft failed: %s\n", dlerror()); return 3; }
ggml_backend_buffer_type_t rbuft = fn();
ggml_backend_buffer_t wbuf = ggml_backend_buft_alloc_buffer(rbuft, wnbytes + 4096);
W->buffer = wbuf;
W->data = ggml_backend_buffer_get_base(wbuf);
wbuf->iface.init_tensor(wbuf, W);
wbuf->iface.set_tensor(wbuf, W, wdata, 0, wnbytes);
fprintf(stderr, "weight routed through %s buffer\n", ggml_backend_buft_name(rbuft));
}
ggml_tensor * X = ggml_new_tensor_2d(ctx, GGML_TYPE_F32, in_rows, n_tok);
memcpy(X->data, kproj_in.data(), 4 * kproj_in.size());

ggml_tensor * Yfull = ggml_mul_mat(ctx, W, X); // nrc = n_tok (oracle route)
ggml_tensor * X1 = ggml_new_tensor_2d(ctx, GGML_TYPE_F32, in_rows, 1);
memcpy(X1->data, kproj_in.data(), 4 * in_rows); // column 0 only
ggml_tensor * Yone = ggml_mul_mat(ctx, W, X1); // nrc = 1 (vec_dot route)

ggml_cgraph * gf = ggml_new_graph(ctx);
ggml_build_forward_expand(gf, Yfull);
ggml_build_forward_expand(gf, Yone);
ggml_backend_t cpu = ggml_backend_cpu_init();
ggml_backend_cpu_set_n_threads(cpu, 1);
ggml_backend_graph_compute(cpu, gf);

std::vector<float> yfull(4 * Yfull->ne[0]), yone(Yone->ne[0]);
memcpy(yfull.data(), Yfull->data, 4 * yfull.size());
memcpy(yone.data(), Yone->data, 4 * yone.size());

// ---- compare column 0 (prompt position 1) and all columns ----
printf("col | maxabs(oracle vs full-route) | maxabs(oracle vs one-route) | bitwise-full bitwise-one\n");
for (int c = 0; c < n_tok; ++c) {
double m_full = 0, m_one = 0; int bf = 0, bo = 0;
for (int r = 0; r < out_rows; ++r) {
float o = kproj[c * out_rows + r];
float a = yfull[c * out_rows + r];
float b = yone[r];
double d1 = fabs((double) o - a), d2 = fabs((double) o - b);
if (d1 > m_full) m_full = d1;
if (d2 > m_one) m_one = d2;
unsigned iu; memcpy(&iu, &o, 4); unsigned au; memcpy(&au, &a, 4);
unsigned bu; memcpy(&bu, &b, 4);
if (iu != au) ++bf;
if (iu != bu) ++bo;
}
int ulp1f = 0, ulp2f = 0, bigf = 0;
for (int r = 0; r < out_rows; ++r) {
unsigned iu; memcpy(&iu, &kproj.data()[c*out_rows+r], 4);
unsigned au; memcpy(&au, &yfull.data()[c*out_rows+r], 4);
unsigned dd = iu > au ? iu - au : au - iu;
if (dd == 1) ++ulp1f; else if (dd <= 3) ++ulp2f; else ++bigf;
}
printf("%3d | %.6e | %.6e | bf=%d/%d bo=%d/%d ulp1=%d ulp<=3=%d big=%d\n", c, m_full, m_one,
(int) bf, (int) out_rows, (int) bo, (int) out_rows, ulp1f, ulp2f, bigf);
}
return 0;
}
75 changes: 75 additions & 0 deletions .agents/evidence/inkling2-loop-w1-20261125/threeway-verdict.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# INKLING2-W1 wave 3 (2026-11-30): the missing three-way

## Question
Does the oracle's il=0 k_proj equal the ggml kernel computed on the ORACLE'S OWN
captured inputs and weight bytes?

## Non-perturbation proof (capture validity)
Tap build /tmp/llamacpp-inkling-tap at abca69200 (in-repo diff: capture-only taps;
ggml/ pristine except one getenv-guarded debug print in ggml-cpu.c, disabled —
W1NRC unset during capture). Golden prompt [371,151451,149879,151194,149884]
confirmed by /tokenize parity. Three oracle-server runs, all under
`flock -w 7200 /tmp/bigmodel.lock` (MemAvailable 161 GB logged):
- taps OFF, -t 1 -> gen [152717, 13, 68014, 32] (== golden prefix)
- taps ON, -t 1 -> gen [152717, 13, 68014, 32]
- taps OFF, -t 32 -> gen [152717, 13, 68014, 32]
Identical. `--no-warmup` on all three.

## Capture shape (new fact)
The oracle splits the 5-token prefill into graphs [1 token @t371] + [4 tokens
@t151451..149884] (tap files taps.0000/0001.bin probes + 0002.bin = the 4-token
prefill, 0003.bin = decode @t152717). So the failing k_proj runs as ONE mul_mat
with nrc=4, not a single 5-token graph and not five nrc=1 calls.

## Three-way result (harness /tmp/ink2-w1-cap/threeway.cpp, ggml from the tap build)
Weight blk.0.attn_k.weight q8_0 ne=[2304,1024]. kproj_in/kproj taps from
taps.0002.bin (tag p1, il0). Comparison per output column:

| route (weight buffer) | nrc | maxabs vs oracle kproj | bitwise match |
|----------------------------------|-----|------------------------|---------------|
| plain ctx buffer (vec_dot tier) | 4 | 9.5e-7 | 0/1024 |
| plain ctx buffer (vec_dot tier) | 1 | 2.4e-6 | 0/1024 |
| CPU_REPACK buffer (gemm q8_0_4x8)| 4 | 0.0 | 1024/1024 |
| CPU_REPACK buffer | 1 (decode taps.0003.bin) | 0.0 | 1024/1024 (== plain vec_dot too) |

VERDICT: oracle kproj == kernel(oracle inputs) BIT-FOR-BIT, but ONLY when the
weight is routed the way llama-server routes it: weights are allocated in
ggml_backend_cpu_repack_buffer_type() (registered at ggml-cpu.cpp:65), so the
mul_mat dispatches through ggml::cpu::repack::extra_buffer_type::supports_op
(repack.cpp:5240) to ggml_gemm_q8_0_4x8_q8_0. With the same inputs and the same
weight bytes in a plain buffer, the chunked multi-row vec_dot path
(ggml-cpu.c:1294, blck 16x16, interleaved num_rows_per_vec_dot) differs by
~1e-6 ULP dust. For nrc=1 (decode) repack/gemm falls back and ALL routes agree
bitwise — consistent with decode tokens 0..4 already matching the golden.

FUSED-WQKV SUSPECT FALSIFIED at source: inkling2.cpp:408-410 issues separate
build_lora_mm(layer.wq/wk/wv, ...) ops; no fused [q;k;v] projection exists.

## Structural cause pinned (ours vs oracle)
- Oracle prefill k_proj: one nrc=4 mul_mat through ggml_gemm_q8_0_4x8_q8_0
(i8mm 4x8 tile; per (32-block, 8-subblock): int dot of 8 elements scaled by
d_w[l]*d_x[l], accumulated into f32 per subblock).
- Ours: src/vllm/model_executor/models/inkling2_loop_paged.cpp:330-334 — the
forward is TOKEN-major (for tt at :282); each proj call sees m=1, so prefill
runs Inkling2MatVecMmla (inkling2_loop_ops.cpp:155), a per-row interleaved
vec_dot tier. Summation order != the gemm's: vec_dot sums the four 8-wide
int partials of a 32-block together before one scale; the gemm scales each
8-wide partial separately. That ~1e-6 ULP dust at kproj is the seed that
amplifies through the short conv into the j=5 token flip (151663 vs 161721).

## Fix design (next wave; no arithmetic invention)
vt::cpu::QuantRepackMatmul (src/vt/cpu/cpu_quant_repack_arm.cpp:184) already
transcribes both tiers with proven bit-parity to ggml (m%4==0 rows -> GemmTileQ8_0
in the gemm order; remainder rows -> GemvRowQ8_0 in the vec_dot/gemv order).
Decode needs no change. The repair is routing, not arithmetic: for prefill
ubatches (T>=2) the Q8_0 attention projections must be issued as ONE
QuantRepackMatmul call over all T columns per layer (gemm order), which requires
making the prefill path LAYER-major (or at minimum batching the projection op
across the ubatch where its inputs are already resolved). Token-major per-token
calls can never reach the gemm tier: m=1 selects the fallback, which is exactly
the route the oracle does not take for prefill.
Red-first bit-proof available cheaply: harness threeway.cpp pattern — route our
projection through QuantRepackMatmul on the oracle's captured kproj_in and
require 1024/1024 bitwise vs the oracle tap before any gate run; then the
5-token gate (single capture shape, knob matching the [1,4] oracle plan) must
flip j=5 151663 -> 161721.
139 changes: 139 additions & 0 deletions .agents/evidence/quant-q4k-seam-20261129/PROCESS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# QUANT-GGUF-CIQ-GEMM — q4k/q6k repack shared-seam unit (2026-11-29)

Helper session `q4k-seam`, row QUANT-GGUF-CIQ-GEMM, worktree
/tmp/quant-q4k-seam from main ee9c3de77, branch
row/QUANT-GGUF-CIQ-GEMM-q4k-q6k-repack. Canonical issue
ISSUE-LOCAL-01M8M4B648PC33WK7K3ANACVVP (.agents/issues/QUANT-GGUF-CIQ-GEMM/).

## Unit

1. `vt::cpu::QuantRepackMatmul` gains the Q4_K and Q6_K repack twins: the
dotprod gemv (rows <= 3) and the i8mm 4-row GEMM (rows > 3, leftover rows
back on the gemv), transcribed verbatim from the pinned tap
/tmp/llamacpp-kolibri11-tap at 5f4d22289 (arch/arm/repack.cpp:781/:1570/
:4015/:4984 NEON arms; the SVE arms are NOT transcribed — this host
exposes no SVE, /proc/cpuinfo, so the oracle binary dispatches the NEON
arms). The upstream kernels' fused `vfmaq_f32` scale folds are kept
verbatim (the bit-identity target here is the oracle kernel — a different
fp order from the vec_dot path), a recorded deviation from the Q8_0 arm's
non-fused vmla policy (file header, cpu_quant_repack_arm.cpp).
2. QuantizeRowQ8KFused (explicit std::fma == the oracle binary's
-ffp-contract=fast nearest_int) and QuantizeRowQ8K4x8Fused (verbatim
ggml_quantize_mat_q8_K_4x8 + fused nearest_int) — ADDITIVE arms; the
default BlockFromFloat table is untouched.
3. QuantRepackEligible/QuantRepackWeight extended to Q4_K/Q6_K (N%8==0,
K%256==0 — the pinned selection, repack.cpp:5011-5017/:5052-5059); the
portable make_block_{q4_K,q6_K}x8 interleave lives in cpu_quant_repack.cpp.

## Bit-proof (tap build /tmp/llamacpp-kolibri11-32891-build at 5f4d22289)

Fixture tests/fixtures/quant-q4k-q6k-repack-oracle-f32.bin (5,385,315 bytes,
sha256 2975aa85fd1be8192f7f8e4a90fac2d0f01dfd32727dbfdee44a11d9eb30132f)
generated by the scratch generator in this directory (compiled against the
tap libs), containing:
- the tap's quantize_row_q8_K bytes on the 5 kolibri11 live rows,
- the tap's ggml_quantize_mat_q8_K_4x8 bytes + input,
- the tap's REPACKED block bytes for Q4_K/Q6_K 512x2560 (weights synthesized
from a shared xorshift32 LCG — leg 3 doubles as the generator-drift
tripwire),
- 40 kernel cases: the 5 live-row Q4_K tensors at m=1 (gemv, live row) and
m=4 (gemm), plus Q4_K/Q6_K random shapes at m in {1,2,3,4,5,8} (m=5 =
4-row gemm + gemv leftover, the oracle forward_mul_mat shape).

RED/GREEN (test_quant_repack_kq_repack):
- GREEN: 393/393 assertions byte-for-byte (green-full-run.txt). Notably the
gemm legs pin OUR QuantizeRowQ8K4x8Fused + GemmQ{4,6}K8x8 against the
TAP's own quantize_mat + gemm pairing — the interleaved-q8_K bsums layout
question raised during transcription is settled empirically by these legs.
- The in-test discriminating controls: the default contract=off quantizer
must differ from the oracle on at least one live row (passes; some live
rows and all-random rows coincide, per the kolibri actcheck evidence), and
the plain vec_dot class must differ from the repacked outputs somewhere.

## Mutations (each: bend, rebuild, run, restore byte-for-byte — backups kept)

- M2 QuantizeRowQ8KFused magic constant +1.0f: 5 leg-1 memcmp reds + gemv
reds. First attempt +0.5f was a NO-OP (below the f32 ULP at 2^23) and
stayed green — recorded as a bad mutation (kolibri precedent).
- M3 GemmQ4K8x8 bias vmlsq->vmlaq: 14 failures, red.
- M4 GemvQ6K8x8 high-bits mask 0x30->0x20: 8 failures, red. First attempt
(mask_hi -> mask_lo) failed to COMPILE (-Werror unused variable) and left
a stale binary reporting a false green — recorded; the redo notes the
stale-binary hazard.
- M5 QuantizeRowQ8K4x8Fused bsums index <<2->>1: 15 failures, red.
- M6 reachability: Q4_K/Q6_K routing condition disabled in
QuantRepackMatmul: the seam entry throws ("weight must be a repacked q8_0
tensor"), red. VT_CPU_QUANT_REPACK=portable skips the test coherently
(exit 77), which is inertness, not red.

## Inertness (default config, this host)

- ctest -R 'quant|repack': 28/28 pass (4 CUDA/ROCm skip coherently).
- ctest GGUF-model subset (kolibri/flint/gguf_load/inkling2): running at
the time of writing; result recorded below.

## Consumers owed re-proofs (coordinator dispatches)

- kolibri11-u3 (model-local twin 5838c608b) — may now switch to the shared
seam in its own follow-up; NOT rewired here.
- inkling2-w1 per-op table.
- qwen3_5_gguf_weights.cpp and muse_glimmer_gguf_weights.cpp: the only two
loaders calling QuantRepackEligible/QuantRepackWeight; their eligible
Q4_K/Q6_K weights now REPACK on i8mm hosts and take the oracle repacked
class (intended change; their keep-quant goldens and any byte-exact gates
need re-proof).
- MatmulBTQuantGrouped (cpu_quant_gemm.cpp) repacked slices for Q4_K/Q6_K
expert towers.
- Every other MatmulBTQuant / QuantTraits.from_float consumer (deepseek_v4,
flint, laguna, minimax_h3, glm5_next, qwen4_exp, CUDA/ROCm/Vulkan/TT
providers) is byte-unchanged by construction (additive arms; default
from_float table untouched) but is listed for the fresh reviewer's
mutation check.

## Scope discipline

Seam + tests only; no model rewiring; no push; no tolerance concepts
anywhere (byte-for-byte or nothing). Spec note: this unit ran under the
row's committed spec umbrella (gguf-compute-in-quant-gemm.md / the G7/G6
repack tiers); a row-level spec addendum for the q4k/q6k arms is owed with
the row's next lifecycle change.

## APPENDIX 2026-11-29 (later same day) — opt-in default + attribution

First staged preflight surfaced three GGUF-model gate failures
(test_kolibri1_gguf logit band + hard flips, test_deepseek_v4_gguf_load
stacked-expert non-repacked contract, test_flint_paged_engine goldens).
Attribution: test_flint_paged_engine needs the untracked per-host
tests/vllm/models/flint_goldens_q4_k_m.json (absent from a fresh worktree);
test_kolibri1_gguf and test_deepseek_v4_gguf_load fail IDENTICALLY on the
clean baseline ee9c3de77 (baseline run in /tmp/quant-q4k-base-bld, same
signatures: 5x logit-band CHECKs + hard_flips; the deepseek_v4.cpp:631
non-repacked contract throw) — pre-existing on this host, not caused by this
unit.

Nevertheless the eligibility extension DID flip eligible k-quant weights to
the repacked class by default, which silently moves every Q4_K/Q6_K model's
outputs on an i8mm host before its consumers are re-proofed. Resolution: the
Q4_K/Q6_K arm of QuantRepackEligible is OPT-IN behind
VT_CPU_QUANT_REPACK_KQ=1 (default off = byte-identical to today); the seam
dispatch, kernels, fused quantizers and bit-proof legs are unchanged (the
bit-proof test sets the flag in-process). The coordinator flips the default
when the consumer re-proofs land (kolibri11-u3, inkling2-w1,
qwen3_5/muse_glimmer keep-quant goldens, deepseek_v4 stacked-expert
contract).

## APPENDIX 2026-11-29 (preflight repair, coordinator-visible)

- check-env-doc: the new knob is now documented as a behavior-changing
selection row in docs/ENVIRONMENT.md (VT_CPU_QUANT_REPACK_KQ, default off,
inertness guarantee stated in the row).
- test_check_test_registration -> test_every_fetch_content_site_is_pinned_off
(6 != 3): PRE-EXISTING/environmental, NOT the staged content. Root cause:
the gate counts `FetchContent_Declare` under the WORKTREE root (rglob
CMakeLists.txt/*.cmake, skipping only .git), so an in-tree build directory
(build/_deps/*-src) inflates the count. Verified: the identical unittest
passes on the clean shared checkout at ee9c3de77 (no build dir), fails in
this worktree only while build/ existed, and passes after the build moved
out-of-tree (/tmp/quant-q4k-seam-bld) with the same staged content. Routed
to the coordinator as a checker-environment hazard: a gate that rglobs the
worktree counts developer build artifacts as tree content. Not fixed here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=== Inertness rerun with the OPT-IN default (VT_CPU_QUANT_REPACK_KQ unset): model-gate subset ===

Total Test time (real) = 268.41 sec

The following tests FAILED:
40 - test_kolibri1_gguf (Failed)
214 - test_flint_paged_engine (Failed)
235 - test_deepseek_v4_gguf_load (Failed)
Errors while running CTest
Loading