okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

albedocmake: strata_kernels links strata_kernels_cpu (iq_kernels.cu reads the latent colscale table from expert_layout.cpp; strata-q36ref failed to link)a4af4df61

main
1 file

files

README.md3.1 KiB

2026-09-27: Q4_0 KV with Hadamard rotation (PR #21, --kv q4_0)

PR #21 (code-martin) adds a 4-bit K/V format: an orthonormal 256-point Walsh-Hadamard rotation of K, V and Q, then ggml q4_0 blocks (576 B per cell and layer, vs 1,056 B in int8).

Integration fixes made on merge

kv_q4_parity (the PR's test) and all 70 ctest tests pass.

Quality (teacher-forced, tools/kv_precision_compare.py)

Same text, same fixed expert set (Q2_0, 3,000 slots, --adapt-swaps 0); only --kv differs. fp16 is the reference.

TextKVSame top-1 as fp16Mean KLPerplexityvs fp16 (nats/token)
code agent (512)int898.4%0.0142.649-0.011 +- 0.006
q4_095.7%0.0302.598-0.031 +- 0.014
document (1,024)int895.6%0.00930.18+0.012 +- 0.005
q4_091.3%0.03932.26+0.078 +- 0.011
chat (1,024)int895.5%0.00918.24-0.003 +- 0.005
q4_090.7%0.02818.52+0.012 +- 0.008
document, 8K (every 8th position)int892.3%0.1147.63-0.013 +- 0.020
q4_088.0%0.2978.65+0.112 +- 0.037

Speed and memory (Q2_0, 128K, matrix bench, --kv-resident 32768)

KVExpert slotsDecode tok/sTokens/roundRounds/sK/V in RAM
int8 (kv-stream/matrix-stream)4,04462.42.5224.81.52 GiB
q4_0 (matrix-q4)4,19067.42.6225.7 (+3.7%)0.83 GiB

Without streaming (contexts up to 64K, or too little RAM for it) q4_0 halves the whole KV cache in VRAM instead.

Decision

--kv q4_0 is a user option:

int8 stays the default: every published quality number was measured with it, and q4_0's precision cost is real, though it passes the needles.