# real KAR codec roundtrip, teacher-forced against llama.cpp (benchmarks/quality/gpt-oss-20b-teacher-forced/set2/table-igpu, 770 positions)
model: gpt-oss-20b-MXFP4.gguf (sha256 65D06D31A3977D553CB3AF137B5C26B5F1E9297A6AAA29AE7CAA98788CDE53AB); dump_logprobs 14 threads, top 20; avx-vnni
codec: crates/kar-codec (moved unchanged from control-plane/src/kar_codec.rs), group 32, codebook fitted per tensor to 65,536 evenly sampled values; reconstruction stored as Q8_0
baseline (8-bit attention/output, MXFP4 experts): 93.4% agreement, mean KL 0.016 (spec node cpu-runtime.md)
date: 2026-10-16; the first table was built in the shared checkout and reproduced exactly (4 levels, all tensors) from a clean worktree build

## attention + output weights, LELEKA_EXPERIMENTAL_KAR_LEVELS=3..6
levels 3 done in 185 s
positions: ours 770, reference 770, compared 770
best token agrees at 307/770 positions (39.9%)
|difference| of the best token's log-probability: mean 0.7083, max 2.8101
|difference| over all shared top-20 tokens: mean 1.0740, max 19.1056 (8699 values)
KL(reference || ours) on shared top tokens: mean 0.55743, max 6.31522
mean NLL of the actual next token over 270 positions: ours 3.0557, reference 2.2564 (difference +0.7993); 499 positions had it outside a top list
by position (count, mean |d top|, mean KL, best-token agreement):
    0..9    n=10   0.3497  0.24180  60%
   10..29   n=20   0.5145  0.61057  70%
   30..59   n=30   0.6246  0.95645  37%
   60..99   n=40   0.5629  0.65195  45%
  100..199  n=100  0.6679  0.49850  47%
  200..end  n=570  0.7431  0.54381  37%
largest best-token differences: pos 265: 2.810, pos 105: 2.777, pos 697: 2.683, pos 391: 2.594, pos 710: 2.570
levels 4 done in 163 s
positions: ours 770, reference 770, compared 770
best token agrees at 524/770 positions (68.1%)
|difference| of the best token's log-probability: mean 0.3816, max 2.4864
|difference| over all shared top-20 tokens: mean 0.5913, max 9.2826 (11683 values)
KL(reference || ours) on shared top tokens: mean 0.21328, max 6.62943
mean NLL of the actual next token over 350 positions: ours 2.7265, reference 2.5046 (difference +0.2219); 419 positions had it outside a top list
by position (count, mean |d top|, mean KL, best-token agreement):
    0..9    n=10   0.1013  0.03300  90%
   10..29   n=20   0.2352  0.32692  70%
   30..59   n=30   0.3898  0.46370  67%
   60..99   n=40   0.3101  0.43152  72%
  100..199  n=100  0.3576  0.17255  68%
  200..end  n=570  0.4005  0.19110  67%
largest best-token differences: pos 472: 2.486, pos 714: 2.191, pos 268: 1.970, pos 29: 1.909, pos 452: 1.856
levels 5 done in 158 s
positions: ours 770, reference 770, compared 770
best token agrees at 611/770 positions (79.4%)
|difference| of the best token's log-probability: mean 0.2210, max 1.9191
|difference| over all shared top-20 tokens: mean 0.3564, max 6.2864 (13137 values)
KL(reference || ours) on shared top tokens: mean 0.09482, max 1.74321
mean NLL of the actual next token over 366 positions: ours 2.6508, reference 2.5619 (difference +0.0889); 403 positions had it outside a top list
by position (count, mean |d top|, mean KL, best-token agreement):
    0..9    n=10   0.1203  0.06200  80%
   10..29   n=20   0.2318  0.14368  85%
   30..59   n=30   0.2708  0.15547  80%
   60..99   n=40   0.1839  0.10824  90%
  100..199  n=100  0.1701  0.06149  78%
  200..end  n=570  0.2313  0.09539  79%
largest best-token differences: pos 261: 1.919, pos 447: 1.700, pos 238: 1.421, pos 714: 1.397, pos 640: 1.300
levels 6 done in 150 s
positions: ours 770, reference 770, compared 770
best token agrees at 646/770 positions (83.9%)
|difference| of the best token's log-probability: mean 0.1584, max 1.3144
|difference| over all shared top-20 tokens: mean 0.2546, max 5.9330 (13857 values)
KL(reference || ours) on shared top tokens: mean 0.06255, max 2.80275
mean NLL of the actual next token over 378 positions: ours 2.6658, reference 2.6358 (difference +0.0300); 391 positions had it outside a top list
by position (count, mean |d top|, mean KL, best-token agreement):
    0..9    n=10   0.0517  0.00537  90%
   10..29   n=20   0.1820  0.11677  80%
   30..59   n=30   0.2317  0.15084  70%
   60..99   n=40   0.1209  0.05713  90%
  100..199  n=100  0.1345  0.04953  85%
  200..end  n=570  0.1625  0.05966  84%
largest best-token differences: pos 487: 1.314, pos 238: 1.294, pos 382: 1.274, pos 714: 1.161, pos 572: 1.125

## one group at a time, 4 levels (LELEKA_EXPERIMENTAL_KAR_TENSORS)
== levels 4, tensors output.weight
positions: ours 770, reference 770, compared 770
best token agrees at 615/770 positions (79.9%)
|difference| of the best token's log-probability: mean 0.2021, max 1.6173
|difference| over all shared top-20 tokens: mean 0.2983, max 4.5421 (13487 values)
KL(reference || ours) on shared top tokens: mean 0.06187, max 1.40561
mean NLL of the actual next token over 372 positions: ours 2.6550, reference 2.6007 (difference +0.0544); 397 positions had it outside a top list
== levels 4, tensors attn_q,attn_k
positions: ours 770, reference 770, compared 770
best token agrees at 582/770 positions (75.6%)
|difference| of the best token's log-probability: mean 0.2342, max 1.9492
|difference| over all shared top-20 tokens: mean 0.4088, max 9.1422 (12864 values)
KL(reference || ours) on shared top tokens: mean 0.12049, max 4.32719
mean NLL of the actual next token over 368 positions: ours 2.7062, reference 2.5863 (difference +0.1199); 401 positions had it outside a top list
== levels 4, tensors attn_v,attn_output
positions: ours 770, reference 770, compared 770
best token agrees at 559/770 positions (72.6%)
|difference| of the best token's log-probability: mean 0.3176, max 2.0886
|difference| over all shared top-20 tokens: mean 0.4883, max 10.3942 (12182 values)
KL(reference || ours) on shared top tokens: mean 0.17176, max 9.18236
mean NLL of the actual next token over 357 positions: ours 2.6826, reference 2.5441 (difference +0.1385); 412 positions had it outside a top list
== levels 4, tensors attn_,output.weight
positions: ours 770, reference 770, compared 770
best token agrees at 524/770 positions (68.1%)
|difference| of the best token's log-probability: mean 0.3816, max 2.4864
|difference| over all shared top-20 tokens: mean 0.5913, max 9.2826 (11683 values)
KL(reference || ours) on shared top tokens: mean 0.21328, max 6.62943
mean NLL of the actual next token over 350 positions: ours 2.7265, reference 2.5046 (difference +0.2219); 419 positions had it outside a top list

## experts of layers 0-5 (LELEKA_EXPERIMENTAL_KAR_EXPERT_LEVELS, _LAYERS=0-5); 4 levels could not be fitted (too few distinct values)
== expert levels 3, layers 0-5
positions: ours 770, reference 770, compared 770
best token agrees at 661/770 positions (85.8%)
|difference| of the best token's log-probability: mean 0.1573, max 1.7111
|difference| over all shared top-20 tokens: mean 0.2635, max 13.6500 (13710 values)
KL(reference || ours) on shared top tokens: mean 0.08140, max 11.80278
mean NLL of the actual next token over 374 positions: ours 2.6124, reference 2.6097 (difference +0.0027); 395 positions had it outside a top list
== expert levels 2, layers 0-5
positions: ours 770, reference 770, compared 770
best token agrees at 561/770 positions (72.9%)
|difference| of the best token's log-probability: mean 0.3446, max 2.3022
|difference| over all shared top-20 tokens: mean 0.4884, max 8.4988 (12480 values)
KL(reference || ours) on shared top tokens: mean 0.16637, max 6.23427
mean NLL of the actual next token over 375 positions: ours 2.5340, reference 2.6268 (difference -0.0928); 394 positions had it outside a top list
== expert levels 0 (control: Q8_0 storage without KAR), layers 0-5
positions: ours 770, reference 770, compared 770
best token agrees at 712/770 positions (92.5%)
|difference| of the best token's log-probability: mean 0.0796, max 1.0772
|difference| over all shared top-20 tokens: mean 0.1281, max 4.0103 (14534 values)
KL(reference || ours) on shared top tokens: mean 0.01823, max 0.99799
mean NLL of the actual next token over 378 positions: ours 2.6274, reference 2.6345 (difference -0.0071); 391 positions had it outside a top list
