# Decode parity with the unmodified Original (`claude/decode-parity`) RTX 5090 (PCIe 5 x16), Ryzen 9 9950X3D, driver 595.99, CUDA 13.2; 6 prompts x 2 passes x 128 greedy tokens, spec 4 + suffix 3, `min_p` 0.5, 2048 per-layer slots from the placeholder profile unless stated, int8 KV, KAR PLE L2, adaptive tier on. "Decode tok/s" = produced tokens / decode phase ms over the requests of 100+ tokens, mean per pass. "Phase" is what the smoke prints (whole decode phase of the port, including the per-request verifier assembly); "serve" is the verify loop alone (what the Original's `decode_ms` measures). Jobs 980-985 (`~/work/gpu-runs/holder2/jobs`), scripts and parsers in the report branch's commit messages; analysis scripts were outside the repository. ## Findings 1. **The Original's pass-0 number in job 809 was depressed by a cold file.** The Original read the 52 GB KAR through its own page cache next to the holder's memfd copy; the two together pushed the memfd into swap (30-40 GB of swap in use, IO pressure 60 %). Reading the same memfd through `/proc/self/fd/N` removes that. Same configuration, three interleaved repetitions (job 984): Original 68.8 / 84.0 tok/s (pass 0 / pass 1; repetition ranges 68.7-68.9 and 83.9-84.1), not 52.8 / 74.7. 2. **Window cost, same prompts, static residency (GPU stage stamps, jobs 980/981):** every GPU stage is within 0.1 ms/window of the Original except the PCIe copy stage (`waitB`, copy kernel): port 32.4 vs Original 25.9 ms/window (prompt 0), 33-45 vs 27-36 on the others. That is the whole GPU-side gap (+7-10 ms/window). Isolated, the port's copy kernel moves 14 experts at 48.5 GB/s (microbenchmark job 980-a, 4 KiB pages = THP = cudaHostAlloc, kernel = DMA); inside a window it is slower, so the loss comes from contention with the CPU pool for host memory, not from the kernel or the page size. 3. **CPU leg:** 37 us per CPU entry in the port vs 35 us in the Original (same code); at the auto-sized cache the port's pool time is 9.6 ms/window vs 5.0 + 0.5 in the Original (fixed per-group host cost, not yet attributed; spans `cpu.plan/open/zero/compute/sink` are in the head but their job did not run). 4. **Per round outside the window:** port 2.2 ms (draft + commit) vs Original 1.2 ms. The port's MTP chain-step graph is GPU-bound at 0.68 ms (events), host overhead per step ~0.02 ms; why the Original's steps are shorter is not known. 5. **Per request:** verifier assembly 63 ms (capture 28-50 + instantiate 17-24 + canonical GDN upload 11) + teardown 10 ms, not part of the Original's `decode_ms`: 3.6 % (pass 0) to 4.6 % (pass 1) of the port's phase rate at 2048 slots, 6 % with the auto-sized cache. 6. Residency was not the cause: per-request hit rates agree (VRAM entries over VRAM + CPU entries, the Original's definition, 52 % / 74 % port vs 50 % / 69 % Original on prompt 0), and the adaptive policy is a literal port. The adaptation knobs (`LELEKA_ADAPT_*`, swaps) are within noise; only cadence 2 helps. ## What changed (all flag-gated; defaults noted) | change | flag | default | measured (adaptive, 2048 slots, port phase tok/s pass 0 / pass 1) | | --- | --- | --- | --- | | PCIe staging by DMA, one driver entry per group, one `cuMemcpyBatchAsync`, flag B by `cuStreamWriteValue32` (falls back to plain calls when the driver refuses; opt-in on WSL) | `--pcie-mode` auto = dma; `LELEKA_PCIE_DMA_MANY/_DMA_BATCH/_FLAGB` | on | 57.9 / 70.2 (copy kernel, head) -> 64.1 / 80.5 (3 interleaved repetitions each, ranges <= 0.5) | | unrolled copy kernels (`k1u16`, 16 loads in flight) | `LELEKA_PCIE_KERNEL`, `LELEKA_PCIE_GRID` | off (kernel mode only) | static +8 % over the sealed kernel | | adaptive tier every 2 rounds | `LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=2` | 4 (the Original's) | 67.3 / 81.9 vs 64.1 / 80.5 | | PCIe share controller | `LELEKA_PCIE_AUTO=on` | off | no better than the best fixed share | | opened-expert span cache for the CPU leg | `LELEKA_OPEN_CACHE=on` | off | not measured | | bank THP, CPU workers, adaptive min/margin/decay | `LELEKA_BANK_THP`, `..._CPU_WORKERS`, `LELEKA_ADAPT_*` | off | THP took no effect; workers > 15 fail at open; adaptation knobs within noise | PCIe share sweeps (static, jobs 981): kernel mode 0.55 -> 0.25 / 0.35 / 0.45 = 47.9 -> 52.0 / 53.9 / 54.9 tok/s (pass 0); DMA 0.45 / 0.55 / 0.65 / 0.75 = 56.9 / 55.4 / 49.0 / 44.6. Adaptive with DMA: 0.35 / 0.45 / 0.55 = 60.9 / 64.8 / 64.2, so the share default stays 0.55. ## Paired A/B (jobs 984, 985; three interleaved repetitions, order rotated; mean [min..max] of the per-repetition means) 2048 slots, decode tok/s pass 0 / pass 1: | arm | phase | serve only | | --- | --- | --- | | Original, shipped config (pcie 0.55, copy kernel) | 68.8 [68.7-68.9] / 84.0 [83.9-84.1] | same (its `decode_ms`) | | Original, `--pcie-frac 0.35` | 72.8 [72.6-72.9] / 89.1 [88.6-89.5] | | | port, previous head (`PCIE_MODE=kernel`) | 57.9 [57.6-58.1] / 70.2 [69.7-70.5] | 60.7 / 74.2 | | port, new defaults | 64.1 [63.9-64.4] / 80.5 [80.2-80.9] | 66.5 / 84.4 | | port, new defaults + cadence 2 | 67.3 [67.1-67.4] / 81.9 [81.8-82.0] | 69.8 / 85.9 | Auto-sized cache (all free VRAM; Original 9971 slots, port 8820): Original 94.4 [94.0-94.7] / 129.1 [127.8-130.3]; port 84.3 [83.7-84.7] / 110.1 [109.9-110.4] (serve only 88.2 / 117.2). The port does not reach the Original on this metric: -7 % / -4 % (defaults), -2 % / -2.5 % (cadence 2) against the shipped Original, -8 % / -8 % against the tuned Original, -11 % / -15 % with the auto-sized cache. In the loop alone cadence 2 is +1.4 % / +2.3 % over the shipped Original and -4 % / -3.5 % under the tuned one. Tokens: the adaptive placement depends on timing, so outputs differ between arms and between engines (static runs of the same binary agree 7-12 of 12 requests, depending on window-size timing); the Original and the port also take different numbers of tokens per window on the same prompt (2.2 vs 2.5), which moves a per-prompt rate by several percent either way. ## TTFT Prompt phase of the port: prefill read 550 ms + lent-slot refill 44 ms (+ 63 ms assembly counted in the decode phase) for 60-100 token prompts; the Original's `prompt_ms` 335-510 ms on repeats, 640 ms mean in job 809 (cold). The prefill agents own it. ## What remains (ordered by measured size) * PCIe copy stage 25-35 % slower than the Original's inside a window although isolated bandwidth is equal: needs a contention microbenchmark (CPU workers streaming while the GPU fetches; contiguous blobs vs three tensors) - `pcie_mb2` was written (`dec-mb/pcie_mb2.cu`, not in the repository) but its job was withdrawn. * Fixed per-group host cost of the CPU leg (4-5 ms/window at the auto cache): spans are in the head; `LELEKA_OPEN_CACHE=on` is the first candidate. * Draft + commit 1 ms/round above the Original (GPU-bound MTP step graph). * Per-request verifier assembly + teardown (about 75 ms): needs a verifier that persists across requests. * VRAM reserve: the auto-sized cache holds 1151 fewer slots than the Original's. # Round 2 (auto-sized cache, contention, controller, draft, assembly) Reference (fixed, recorded): Original shipped 68.8 / 84.0, tuned (pcie 0.35) 72.8 / 89.1, auto-sized cache 94.4 / 129.1 tok/s (pass 0 / pass 1; no Original run was repeated). Since round 1 the integrated head added the prompt-routing seed and prefix/memory work: the port's own previous head at the auto-sized cache moved from 84.3 / 110.1 to 104.4 / 122.4. * **VRAM (jobs 987/988/989, free-VRAM notes, `LELEKA_SERVE_PROFILE=1`):** 32 110 MiB visible; embedding 324, native head 506, dense 4 640, MoE prompt arena 942, prompt executor + MTP drafter 920-1 068, expert cache, then the per-request verifier assembly takes only ~450 MiB (also at 180k tokens, capacity 8192). The decode reserve of 1024 MiB left ~550 MiB idle. Default is now 300 MiB: 8820 -> 9144 slots (+324; 9104 with 450 MiB in the 180k smoke, prefill 3873 -> 3913 tok/s, free after assembly 701 MiB). The Original's 9971 slots are not reached: the remaining ~800 slots are the port's larger resident set (MoE prompt arena, drafter buffers, KV window); not shrunk. * **PCIe stage under contention (job 987-b, microbenchmark, 15 CPU streaming workers):** PCIe drops from 48 to 31.5-34.5 GB/s while the CPU gets 42 GB/s (one DRAM ceiling); contiguous blobs vs three tensors, 4 KiB vs THP, and kernel vs DMA differ by <= 3 % (DMA best). The in-window PCIe stage is therefore bounded by the host memory system, not by the port's layout or kernel. The optimal share is P/(P+C) = 0.45 (schedule agent, job 909): default now 0.45 (auto cache, 3 interleaved repetitions: 128.2 vs 122.4 tok/s pass 1, +4.7 %; pass 0 104.9 vs 104.4; equal at 2048 slots). * **Controller `LELEKA_PCIE_AUTO=lag`** (flag-B wait after the CPU leg): no gain (104.2 / 121.5 vs 104.4 / 122.4); the old hill climber (`=on`) is also no better than the fixed 0.45. Both stay off. * **Draft + commit (2.2 vs 1.2 ms/round):** the chain-step graph has 113 nodes (round graph 155-186) and is GPU-bound at 0.68 ms (events). The ledger agent attributes ~0.4-0.5 ms/round to the smokes and the daemon not binding the MTP draft-vocabulary subset (`--mtp-rt-dir`, 106 299 rows instead of the 248 320-row head): jobs 991/992 carry the arm `R` (`LELEKA_ORIGINAL_SERVE_RT_DIR`). * **Verifier persistence: not done.** The prompt executor's QSA layers own the index/KV objects the verifier journal also wraps (`take_qsa_owners` / `adopt_qsa_owners`, session lineage witnesses, `prepare<'index>` borrows); keeping graphs across requests needs the executor to use the owners through the journal. Assembly (63 ms) + teardown (10 ms) stay: 7-9 % of a pass-1 request at the auto-sized cache (serve-only 134 vs phase 123 tok/s). * **Not helpful:** opened-expert cache (`LELEKA_OPEN_CACHE=on`, no change), `min_p` 0.3 / 0.7 (both below 0.5), KV window 4096.