# Model quality gate: the Rust/CUDA port (Original mode17 serve path) against the unmodified Original Status: measured on the RTX 5090 (driver 595.99.02, CUDA 13.2.86), 2026-10-17/18. Branch `claude/quality-gate` (port = `claude/port-gpu-bringup` 6b94e7c, seed on by default, + the stop-set fix below; merged with the bring-up head 4f7c461 afterwards). Model: Qwen3.8-Flash-Next IQ3_S, KAR level-2 PLE, MTP pack `data/mtp-rt`. Original = `stra169-ladder/build-sm120/strata` (sha256 714deada...), the build behind jobs 809/980; the `numerics-orig` build (diagnostic dump patches compiled in) reproduces it bit for bit on the reads (arm R6: all 612 rows, difference exactly 0). ## 1. Method **Teacher forcing, both directions.** A *path* is the prompt followed by the tokens an engine produced. Both engines are made to decode along the same path and log the top-16 log-probabilities of every row. * Original: `--serve` requests `GEN 1 ` with `--short-read 4096 --prompt-cache 0`, so the whole path goes through the verify windows and `STRATA_LOGPOS` / `STRATA_LOGPOS_TOPK=16` log every row (the only mode in which the Original exposes log-probabilities). Reference arm **R1** = the port's configuration family: spec 4 + suffix 3, `--spec-min-p 0.5`, 2048 per-layer slots from the placeholder profile, `--pcie-frac 0.55`, int8 KV, KAR PLE L2, tier **static** (`--adapt-every 0`: placement independent of copy timing). * Port: `LELEKA_SMOKE_FORCE_DIR` (new, `quality_force.rs`): the smoke replaces the picks of every verify window by the tokens of the path (the controller still verifies drafts against them, so acceptance, stop and length follow the path); logits and `LELEKA_TRACE_LOGPROBS` rows stay the port's own. Pass 0 of every corpus prompt is forced along the Original's job-809 pass-0 tokens, pass 1 is free. A row is *valid* when the window's consumed tokens equal the path up to it (rows after a rejected draft token are skipped). The hook is off unless a test installs a sequence (unit test `quality_force::tests`). * Corpus: `~/work/gpu-runs/prompts.txt` (6 prompts, 612 generated-region rows on the Original paths O0-O5; p2 is 90 tokens ending in the stop token, p5 is 10). * Per position: `dmax16` = max over the tokens present in both top-16 lists of |lp_a - lp_b| (the tail tokens dominate it); `d_top1` = |difference of the log-probability of the reference's argmax token|; `flip` = argmax differs, with the reference's top1-top2 margin at that row. d_top1 is what decides tokens; dmax16 is reported because the task asked for it. **Gate (pass criterion tied to the Original's own envelope).** The Original is compared with itself under every configuration change that is known to alter its outputs; the largest deviation it shows against its own reference is the tolerance: | tolerance (Original vs its own R1, section 2) | value | | --- | --- | | d_top1 p99 | <= 0.22 nats | | d_top1 max | <= 0.43 nats | | dmax16 p99 | <= 2.05 nats (max 5.2) | | argmax-flip rate | <= 2.8 % of rows | | Original margin at every flip | <= 0.49 nats | | stop: forced run stops exactly where the path stops, stop token rank 1 | required | A port arm passes when it stays inside; a single row outside is listed and explained, not averaged away. ## 2. The Original's own envelope (teacher-forced reads of O0-O5, 612 rows per arm, generated region) | arm | dmax16 med / p99 / max | d_top1 med / p99 / max | flips | Original margin at the flips | | --- | --- | --- | --- | --- | | R1 read twice in one process | 0 / 0 / 0 | 0 / 0 / 0 | 0 | bitwise deterministic | | R6 numerics-orig build | 0 / 0 / 0 | 0 / 0 / 0 | 0 | bitwise identical to the unmodified build | | R1 with `pcie_frac=0` (request key) | 0.395 / 1.75 / 5.21 | 0.001 / 0.177 / 0.329 | 11 (1.8 %) | <= 0.34 | | R2 near-empty VRAM tier (2 slots/layer: experts on the CPU) | 0.453 / 1.95 / 4.05 | 0.001 / 0.189 / 0.279 | 10 (1.6 %) | <= 0.23 | | R3 verify window `--spec 2` (shape of the windows) | 0.396 / 1.71 / 4.48 | 0.001 / 0.209 / 0.286 | 15 (2.5 %) | <= 0.41 | | R4 adaptive tier, first reads | 0 / 1.0 / 1.6 | 0 / 0.045 / 0.178 | 1 | 0.10 | | R4 adaptive tier, repeat 1 / repeat 2 of the same reads | 0.43 / 1.5 / 2.9 ; 0.42 / 2.0 / 4.2 | 0.001 / 0.18 / 0.39 ; 0.001 / 0.22 / 0.43 | 15 (2.5 %) ; 17 (2.8 %) | <= 0.49 ; <= 0.41 | | prompt read batched vs through windows (prompts 0, 1, 2 of job 9967; first <= 40 generated tokens, 104 rows) | 0.557 / 2.15 / 2.94 | 0.010 / 0.238 / 0.254 | 5 (4.8 %) | <= 0.25 | | GGUF PLE instead of KAR L2 (not an envelope member, section 6) | 0.62 / 2.86 / 4.38 | 0.001 / 0.34 / 0.54 | 21 (3.4 %) | <= 0.43 | Pooled over the five non-identical envelope arms (3060 rows): d_top1 median 0.001, p99 0.197, max 0.433, dmax16 p99 1.83, flips 2.22 %. The Original's greedy sequences move accordingly (first differing token of each arm against its job-809 pass 0; `=` identical): | Original arm | p0 | p1 | p2 | p3 | p4 | p5 | | --- | --- | --- | --- | --- | --- | --- | | F1 batched prompt, static, spec_min_p 0.5 / 0 / 0.8 | 25 / 4 / 4 | 2 / 2 / 2 | = / = / = | 98 / 60 / 75 | 10 / 77 / 10 | = | | R1 static | 6 | 2 | **4** | 28 | 10 | = | | R2 near-CPU | 4 | 2 | **4** | 28 | = | = | | R3 `--spec 2` | 6 | 2 | **4** | 10 | 77 | 2 | | R4 adaptive | 6 | = | **4** | 28 | 77 | = | | R5 GGUF PLE | 4 | 2 | **4** | 10 | 10 | = | | from the decode-parity jobs (orig-dec-A, A35, AD, AU, S, SP) | 4-99 | 4-8 | 2-35 | 2-100 | 10-77 | 8-35 | ## 3. The port against the Original (section B/C/V/V2 of `q_analyze.py`) Port arms (forced pass 0 along the Original's pass-0 tokens, 612 rows each, reference = R1): | port arm | d_top1 med / p99 / max | dmax16 p99 / max | flips | largest Original margin at a flip | | --- | --- | --- | --- | --- | | P1 static tier, seed off | 0.001 / 0.176 / **1.152** | 1.84 / 3.34 | 10 (1.6 %) | 0.56 | | P5 static tier, seed ON | 0.001 / 0.191 / **1.022** | 2.32 / 4.53 | 10 (1.6 %) | 0.41 | | P2 adaptive tier, seed off | 0.001 / 0.202 / **0.836** | 2.14 / 4.28 | 11 (1.8 %) | 0.41 | | P6 adaptive tier + seed ON (the new default) | 0.001 / 0.235 / **0.974** | 1.98 / 3.19 | 14 (2.3 %) | 0.41 | | P3 tier off (all experts on the CPU pool: dense path alone) | 0.001 / 0.206 / **0.720** | 2.19 / 3.44 | 19 (3.1 %) | 0.41 | | P4 static, `--pcie-frac 0` | 0.001 / 0.198 / **1.361** | 2.12 / 4.94 | 15 (2.5 %) | 0.41 | | port vs port: P2 / P3 / P4 / P5 / P6 against P1 | p99 0.15-0.21, max 0.29-0.52 | 1.7-2.0 / 2.6-4.9 | 1.6-2.9 % | | Pooled over the six port arms (3672 rows): d_top1 median 0.001, p99 **0.210** (Original pool 0.197), flips **2.15 %** (2.22 %), dmax16 p99 2.07 (1.83). Without one row, the pooled d_top1 max is 0.417 (Original 0.433) and the flip rate 1.99 %. The port's own envelope (arms against P1) is the same size as the Original's: p99 0.189, max 0.518, flips 2.19 %. **The one row outside the tolerance** is the same in every port arm (the bold maxima): corpus prompt 1, generated token 2, position 66, whose input token is `` (248068). Original (windows read, batched-prompt read, near-CPU, GGUF, all configurations): 198 at -0.51..-0.74 over 271 at -0.65..-0.92, except two configurations that put 271 first (R3 by 0.03, R4 repeat 1 by 0.45); port: 271 at -0.21..-0.35, 198 at -1.23..-1.66 in all six arms, including the all-CPU-experts arm. So the port's value lies 0.3-0.7 nats beyond the Original's most extreme configuration (d_top1 up to 1.36 against the R1 value). All other 3671 pooled port rows are inside the envelope. Localisation (section 9.2): the residual stream of that row is ordinary, so it is a high-gain row, not a fault. **Verdict of section 3:** the port's deviation distribution equals the Original's self-deviation (pooled medians, p99 within +6 %, flip rate 2.15 % vs 2.22 %, flip margins <= 0.41 except one 0.56 whose port margin is 0.02, i.e. a coin flip in both engines); one row (above) is outside and not yet explained at the logit level but localised in section 9.2 as a normal-sized residual difference on a high-gain row. No evidence of a systematic numerical error in the dense path, the KAR PLE source, the expert paths (CPU, VRAM static, adaptive, PCIe 0) or the speculative window shapes. ## 4. Open question 1: corpus prompt 2 (diverges at token 4; the Original stops at 90, the port runs to 128) Near tie, not a defect. * The Original diverges from its own job-809 pass 0 on prompt 2 at **token 4** in every windows-read configuration (R1, R2, R3, R4, R5: row 2 of section 2). Its teacher-forced read of its own path puts token 449 behind token 264 by 0.149 nats (R1), 0.26 (R2); the batched-prompt read of job 9967 gives 449 (-1.059) over 264 (-1.139) by 0.080, the windows read 264 (-1.010) over 449 (-1.158). * The port at that row (all six arms): 264 at -0.95..-1.03, 449 at -1.22..-1.28, i.e. the windows-read ordering, within 0.22 nats of the Original's. * Teacher-forced along the Original's 90 tokens the port produced exactly 90 tokens and stopped on the stop token in every arm (probe job and all six arms: `produced 90 of 90 forced tokens, stopped as forced`); the stop token is rank 1 at the last row in all six arms with log-probability -0.06..-0.22 (Original -0.09). So the 90-vs-128 difference is the consequence of the near-tie at token 4 (a different text), not of the stop handling. * d_top1 over the 90 rows of prompt 2: median 0.002, p99 0.145-0.176, max 0.15-0.21; no flip against R1 except one of margin 0.09 (seed arm). ## 5. Open question 2: the other divergences (job 809 table) Every first divergence of every port arm (section D of the report) is a near tie in the engine that picked the other token: the Original's margin at the divergence row is 0.05-0.25 (one 0.56: prompt 4 token 121, port margin 0.02); the port's margin 0.00-0.43. Divergence indices of the port's free run against the Original's job-809 pass 0 (identical = `=`): P1 static 19 / = / 4 / 100 / 121 / =; P5 4 / = / 4 / 10 / 10 / =; P2 adaptive 4 / = / 4 / 10 / 77 / 2; P6 4 / = / 4 / 100 / 77 / 7; P3 CPU 4 / = / 4 / 10 / 10 / 2; P4 4 / = / 4 / 10 / 77 / 2 (the earlier job-809 numbers 6 / 4 / 28 / 77 / 7 are the same kind). The Original's own arms diverge at 2-100 on the same prompts (section 2). The indices carry no signal beyond "an early near tie flips with any rounding change". ## 6. KAR level-2 PLE against GGUF PLE in the Original (context for the "KAR model quality" status) Same reads (static tier, windows), Original with `--ple-kar` level 2 versus without (PLE from the GGUF shard 2): * Teacher-forced on the 6 KAR-generated paths (612 rows): d_top1 median 0.001, p99 0.34, max 0.54; flips 21 (3.4 %), margins <= 0.43; on all 17 paths (1841 rows) p99 0.36, max 0.73, flips 3.7 %. The mean NLL of the KAR run's own tokens is 0.2536 (KAR) vs 0.2638 (GGUF) nats/token, a +0.010 difference that includes the bias of scoring KAR's own text. * Free greedy sequences (6 prompts x 128, both through the windows, static tier): GGUF vs KAR first differ at tokens 4 / 75 / 93 / 10 / 79 / = (identical on the 10-token prompt), the same range as the Original against itself in section 2. * This is ~1.6x the Original's other envelope arms (d_top1 p99 0.34 vs 0.19-0.22, flips 3.4 % vs 1.6-2.8 %): KAR L2 PLE is a real but small numerical perturbation of the same order as a change of the verify-window shape; not a quality collapse on these 6 prompts. It is no benchmark: 6 prompts, <= 128 tokens each, no perplexity, no tool-call or long-context test. The status in `docs/model-assets.md` stays "pending"; this is only the first number for it. ## 7. Open question 3: 16,000-token prompt, chunk 8192 against 2048 Logits after the 16,000-token prompt (`prefill-708/prompt16000.ids`), rows 15999-16001 (predicting 271, 248068, then 198 vs 271). Original: batched prefill at the stated chunk, the last prompt token and the answer through the verify windows (`--turn-token` = the last prompt token). Port: static tier, seed off, free run (first three tokens identical at both chunks). | chunk | engine | lp(198) | lp(271) | margin 198-271 | argmax @16001 | | --- | --- | --- | --- | --- | --- | | 2048 | Original | -0.687 | -0.699 | +0.011 | 198 | | 2048 | port | -0.523 | -0.898 | +0.375 | 198 | | 8192 | Original | -0.556 | -0.853 | +0.297 | 198 | | 8192 | port | -0.821 | -0.580 | -0.242 | 271 | * The Original itself moves by 0.15 nats per token between its chunks 2048 and 8192 (margin spread 0.29); the port by 0.30 per token (spread 0.62). The port's distance to the Original at the same chunk is 0.16-0.27 nats (lp(198)/lp(271)), inside the envelope (d_top1 max 0.43). * The answer differs only because the Original is at +0.30 and the port at -0.24 on a 0.25-nat near tie; at chunk 2048 both pick 198. * Verdict: rounding of the same size as the Original's own chunk dependence (the port is somewhat more chunk-sensitive on this one row; a single sample). Not a defect; switching the default chunk is still a deliberate answer-changing decision, as that doc says. The first rows 15999 and 16000 agree within 0.02 nats at both chunks. ## 8. Seed and adaptive tier: explicit verdict `LELEKA_ORIGINAL_SERVE_SEED` (prompt-routing seed, default on since 6b94e7c) and the adaptive tier change only the expert placement. Teacher-forced, 612 rows per arm, reference R1: | arm | d_top1 p99 / max | flips | verdict | | --- | --- | --- | --- | | static, seed off (P1) | 0.176 / 1.15 (the one row) | 1.6 % | baseline | | static, seed ON (P5) | 0.191 / 1.02 (the one row) | 1.6 % | same as P1; P5 vs P1: p99 0.146, max 0.447, flips 1.6 % | | adaptive, seed off (P2) | 0.202 / 0.84 | 1.8 % | inside | | adaptive + seed ON, the shipped default (P6) | 0.235 / 0.97 | 2.3 % | p99 +7 % over the Original's 0.219 (R4 repeat 2), flips inside; P6 vs P1: p99 0.187, max 0.291 | **Seed: PASS.** It moves the port's distribution by no more than the placement changes the Original and the port already show against themselves (P5 against P1 is smaller than P2/P3/P4 against P1), and it adds no row outside the envelope. Adaptive on/off: PASS likewise (P2, P6). ## 9. Defects found and fixed 1. **Stop set (fixed, `97227d8`).** `generate.cpp` stops on `<|endoftext|>` (248044) and `<|im_end|>` (248046) (`--eos-ids`); the port's serve backend, the smokes and the laptop probe used the GGUF `tokenizer.ggml.eos_token_id` alone = 248046. Evidence from the 100k/180k retrieval run (job 9966, before): after the answer `...**4817-QX**.` the model emits `<|endoftext|>`; the Original stops (83 and 63 tokens), the port went on emitting `<|im_start|>` until `max_new` (87 tokens at 100k, where it later hit `<|im_end|>`; **600 tokens at 180k**). After: `original_stop_tokens()` returns {eos, 248044} for the request and the text sink; unit test `the_stop_set_is_the_originals_endoftext_and_im_end`. After (job 9969, same prompts, same 600-token allowance): the free run stops on `<|endoftext|>` after **83** tokens at 100k (the Original's length) and **68** at 180k (was 600); the forced run produces exactly the Original's 83 and 63 tokens and stops there. Re-confirmed. 2. **Outlier row `` at position 66 of prompt 1: localised, not a defect.** Job 9970 dumped the residual after every layer half in both engines (port teacher-forced, `numerics-orig` Original through the windows, same path: prompt 1 + its first 22 tokens, 25 common rows). Relative L2 of port against Original at position 66, frame by frame: **0 at frame 0** (embedding / PLE of the `` input identical, which rules out the special-token input hypothesis), 1.2e-3 at frame 1 and then within 0.8-2.3x of the median over the other 24 rows at every frame (rank 4-17 of 25), 0.134 at the last frame against a median of 0.099 (rank 8/25). Rows 88, 77 and 81 differ more (mean 0.42 / 0.34 / 0.25 over frames 8-95) without any argmax flip. There is no frame where the row departs from the others, so there is no layer-level fault to fix: the 0.13 residual difference is the usual size (earlier port-vs-Original ladders: 0.055-0.09 median at the last frames), and this row is a high-gain row for the 198/271 pair (a 0.4-nat tie in the Original, whose own configurations already move it by 0.9 nats of margin). The port's six arms agree with each other because they share one dense path whose offset from the Original is fixed, while the Original's envelope arms share the Original's. Residual risk: one row of 612 per arm lies outside the Original's envelope; the evidence is that it is rounding on a sensitive row. A second sample of rows whose input is a decode-time special token (thinking-mode traffic) would tighten this; not done. ## 10. Long-context retrieval at 100k and 180k tokens (same ids as jobs 915/916: `long-180k/prompt{100000,180000}.ids`, needle `4817-QX`) Port (jobs 9966 before / 9969 after the stop-set fix; integrated defaults: adaptive tier + seed, chunk 8192, int8 KV streamed, up to 600 new tokens) against the Original (job 9964: static tier, `--prefill 8192`, same KV streaming, `GEN 600`). | prompt | engine | answer | tokens | | --- | --- | --- | --- | | 100k | Original | `` ... "Remember this: the secret passcode is 4817-QX" ... `` "The secret passcode is **4817-QX**." then `<|endoftext|>` | 83 | | 100k | port, before fix | same, then `<|endoftext|><|im_start|>` x3 `<|im_end|>` | 87 | | 100k | port, after fix | same, stops on `<|endoftext|>` | 83 | | 180k | Original | same structure, **4817-QX**, stop | 63 | | 180k | port, before fix | **4817-QX**, then `<|endoftext|>` and junk to the limit | 600 | | 180k | port, after fix | **4817-QX**, stops on `<|endoftext|>` | 68 | **Retrieval verdict: both engines retrieve the passcode at 100k and 180k.** The free answers first differ at token 61 (100k) and 30 (180k): at those rows the Original has 1151 at -0.717 over 6941 at -0.778 (100k; port -0.756 / -0.763) and 430 at -1.086 over 506 at -1.142 (180k; port 506 -1.112 over 430 -1.145), i.e. margins of 0.06 and 0.06 in the Original and 0.01 and 0.03 in the port: coin flips, not a long-context error. Teacher-forced along the Original's whole answers (Original: batched prompt, the answer through the verify windows, job 9968; port: forced pass, job 9969), top-16 per row: | prompt | rows | d_top1 med / p99 / max | dmax16 p99 / max | flips | stop token lp / rank (Original; port) | | --- | --- | --- | --- | --- | --- | | 100k | 82 | 0.000 / 0.230 / 0.328 | 2.77 / 3.30 | 0 | -0.003 / 1 ; -0.005 / 1 | | 180k | 62 | 0.000 / 0.100 / 0.137 | 1.46 / 1.55 | 1 (Original margin 0.124) | -0.003 / 1 ; -0.003 / 1 | Against the short-context tolerances: 180k is inside; at 100k the p99 (0.23, the largest or second largest of 82 values) is 0.01 over the 0.22 line, the maximum 0.33 is inside 0.43, no flips. The forced runs produced exactly 83 and 63 tokens and stopped on the stop token. The Original's row at position 99999 (first answer row) is not logged by its resumed request. ## 11. Rerun ``` # data and requests (server): scripts/quality/q_prep.py builds cases/ and force/ from the job-809 Original log and the port logs # Original: holder jobs scripts/quality/jobs/991..995, 9964, 9967, 9968, 9970 (orig_run in q-common.sh); port: 9216-9218, 9966, 9969, 9970, 9973 python3 scripts/quality/q_analyze.py ~/work/gpu-runs/quality --md report.md # envelope, port arms, divergences, EOS, verdict, long prompt python3 scripts/quality/q_ladder.py ~/work/gpu-runs/quality/ladder 66 # layer-level localisation of one row ``` Binaries: port test exe built in WSL from `claude/quality-gate` (`q-4`, sha256 8618cc61..., built from 97227d8). Everything under `scripts/quality/` is offline analysis or holder jobs; nothing there runs in production serving. ## 12. Caveats * The Original's logprobs exist only for rows read through the verify windows; the prompt part of R1 therefore goes through windows too (the real flow reads it batched). Prompts 0-2 were re-read with the batched path (job 9967) and agree with the windows read within d_top1 0.25. * Single token path per prompt, 6 prompts, 10-128 tokens: 612 rows per arm; p99 is the 6th largest value. Tolerances are the maximum over 5 Original arms, which is itself a small-sample bound. * The expert placement of the port and of the Original differ (different sets resident), which both sides' envelopes include.