# CPU lane measurements on focalor The baseline is e5331100. The machine is a Ryzen 7 5800X (Zen 3, AVX2, 8 cores / 16 threads). These runs used random expert blocks, not model outputs. Every run held `/tmp/ds41-bench.lock`; no GPU kernels ran. ## Build ISA The Nix GCC wrapper removed `-march=native`: preprocessing with that flag showed SSE2, but no AVX2/FMA/F16C. ggml therefore used scalar dots. Strata's AVX2 rows failed the bitwise check against those scalar float reductions, so both `auto` and `own` silently fell back to scalar ggml. Configure with `-DSTRATA_PORTABLE=ON` to request AVX2/FMA/F16C explicitly. `ds4_gg_bench` now prints ggml's compiled ISA and warns when it is missing. `--k256` checks the AVX2 implementation directly, without fallback. With `--expert --type T --dtype T --nt 1 --mb 1500 --reps 2`, auto GB/s before / after the build correction were: | Type | 1 thread | 8 threads | | --- | --- | --- | | IQ2_XXS (16) | 0.5 / 4.9 | 3.9 / 34.8 | | IQ2_XS (17) | 0.6 / 4.9 | 4.5 / 35.2 | | IQ1_M (29) | 0.4 / 2.7 | 3.0 / 18.9 | The before figures are the parent experiment's streaming runs (IQ1_M 0.4 GB/s was independently reproduced here). After figures were measured in this worktree before the singleton change below. Raw logs are under `build/avx2-type{16,17,29}-t{1,8}.log`. The build correction changes floating-point reduction order, not integer sums or precision. It is NOT bit-identical to scalar ggml. On roughly 1,300-1,800 random rows/type, 79% differed in bits; maximum absolute errors were 1.53e-5 (16,17) and 1.91e-6 (29), or 1.6-2.1e-7 of maximum output magnitude. See `build/scalar-vs-avx2-floats.log`. All Strata AVX2 results were bit-identical to the corrected ggml AVX2 build. ## IQ1_M singleton chunks At one token, consume each decoded 64-weight chunk immediately instead of storing four decoded chunks (1 KiB/block) and then rereading them. The integer lanes, float scale products, FMA order and reduction stay unchanged. Multi-token calls retain the decoded-chunk sharing path. Paired 1.5 GB ABBA runs gave own throughput at one thread of 2.7 / 3.0 / 2.8 / 2.5 GB/s (baseline / candidate / candidate / baseline); the last baseline also suffered a large ggml slowdown, so these are noisy. At eight threads the corresponding figures were 13.7 / 16.4 / 15.9 / 13.5 GB/s. Within-process ggml throughput stayed 10.8-11.1 GB/s for those four eight-thread runs. This supports a roughly 17-20% eight-thread gain from the kernel change; it is not a second several-fold improvement. Logs: `build/confirm-{base,direct,direct2,base2}-iq1m-t{1,8}.log`. Direct `--k256 --mb 10` checks passed bitwise for 16/17/29 at 1,2,4,8 tokens, with no exactness fallback. Expert pipeline comparisons also passed. See `build/direct-exact-validation.log`. A ternary activation LUT prototype was exact but slower (0.4 vs 2.7 GB/s single-thread own throughput), and was discarded. Its table occupied about 207 KiB per thread at gate width; scalar lookup/index work and preparation did not pay off. Log: `build/lut-iq1m-t1.log`. ## Per-call scheduling `--expert --lane` uses the production `ds4::Pool`, one expert per gate/up and down dispatch, and serial h quantization. It does not emulate disk reads, slot copies, NUMA splits, CUDA synchronization or other engine work. It changes no production scheduling. At `--nt 1 --threads 8 --mb 256 --reps 2`, corrected AVX2 auto throughput was 31.2 / 28.1 GB/s for type 16, 30.7 / 29.8 for 17, and 19.6 / 18.3 for 29 (batched / one-expert calls). All pipeline results were bitwise identical to ggml. This synthetic per-call cost is modest; the engine's old two-fold gap cannot be attributed to dispatch alone from this test. Reprofile the corrected full engine before tuning production row chunks. Logs: `build/scheduling-type{16,17,29}-lane{0,1}.log`. ## Store completion wait race The store checked a slot's pending-read count before `IoQueue::wait_any` snapshotted its completion generation. A completion in between could make the waiter sleep until the two-millisecond timeout. The optional pending count is now checked in the wait predicate under the notification mutex. This changes neither expert arithmetic nor output accumulation order. The `ds4_pool_test` regression passes for completed requests, a successful copy and cancellation. Restoring the old notification-only predicate makes the completed-request case fail (one-second timeout, 500-ms threshold). CTest passed 1/1 on focalor. This is not a measured decode-throughput improvement. On the 64-token full-engine recipe, exact routing was 8.34 tok/s baseline and about 8.3 with the fix; Cache-Prior lambda=0.3/keep=3 remained about 12.1 tok/s. The fix's two 64-token runs matched each other and the baseline stdout for both routing configurations. The first 48-token exact baseline had different tokens from later runs, so its apparent 8.03-to-8.37 increase is not evidence for the change. Artifacts: `build/lane-{base64-exact,io64-exact-a,io64-exact-b,base64-cp, io64-cp-a,io64-cp-b}.{stdout,stderr,json}`, `build/io-old-predicate-test.log`, `build/io-fix-test-summary.txt`. Baseline source: b0185826; immutable baseline and candidate executables are `build/strata-dsv41-lane-base` and `build/strata-dsv41-io-wait`. The CPU pool's source diff is preserved in `build/io-wait-candidate.patch`. ## CPU store without relocation copies `DS4_STORE_INPLACE=1` leaves each CPU-only matrix at the address where its aligned read lands it. `ExpertStore::mat` returns that address. This avoids an extra full-matrix memmove on every cache miss. Prompt staging now reads the store's three matrix pointers rather than assuming a canonical blob. GPU-mapped slots retain the canonical layout; the option is disabled with `DS4_STORE_ZC`. The default remains unchanged. On the same 64-token recipe, canonical versus two in-place runs: | Routing | Canonical tok/s | In-place tok/s | GPU ms/token canonical / in-place | | --- | --- | --- | --- | | Exact | 8.27 | 8.83, 8.73 | 119.79 / 112.10, 113.44 | | Cache-Prior 0.3, keep 3 | 12.01 | 12.62, 12.63 | 82.22 / 78.18, 78.16 | For Cache-Prior, GPU waiting for the CPU lane fell from 61.10 to 57.09/57.07 ms/token, and store read waiting from 29.7 to 27.0/26.9 ms. At the final profile checkpoint the per-call IQ gate/up stage fell from 0.410 to 0.357/0.362 ms, down from 0.214 to 0.191/0.194 ms (prefill calls are included in these running averages). Miss counts, cache movement and bytes/token were identical in this confirmation batch. Each routing recipe's three 64-token stdout files compare byte-for-byte: canonical versus in-place and repeated in-place. No integer arithmetic, precision or floating reduction order changed. The synthetic `ds4_store_layout_test` checks unaligned offsets, buffered and direct reads, slot reuse, read failures, and canonical GPU-mapped layout even when the in-place option was requested. CTest passed 2/2 with this and `ds4_pool_test`. The 48-token screening run gave exact 7.77 -> 9.01 tok/s and Cache-Prior 12.17 -> 12.84, but use the 64-token confirmation above for the gain. Logs are `build/lane-raw64-{canonical,exact-a,exact-b,canonical-cp,cp-a, cp-b}.{stdout,stderr,json}` and `build/lane-raw-{canonical,inplace, canonical-cp,inplace-cp}.*`. Runs were batched under the approved `gpu_run.py` service lease inside `/tmp/ds41-bench.lock`. ## Streamed CPU-lane batches (ana/lane2) `DS4_LANE_STREAM=1` (NH 1, i-quant experts, RAM store) computes a window's CPU-lane experts in one pool batch: the entries whose reads are done first, then the misses in the order their reads started; each entry's gate/up jobs, then its down jobs. `DS4_STORE_PIECE_KB=n` (in place only) reads each missed matrix in n KB pieces (gate and up interleaved, then down), and a job waits only for the pieces holding its rows; a piece whose read failed is read from the file's mapping. An entry's last gate/up job quantizes its h, which its down jobs wait for. Every row is the same call on the same rows into the same slot as `cpu_experts_iq`: no integer, precision or float-order change. Paired 64-token runs (frozen profile, `DS4_PROF=1` in every arm), with `DS4_STORE_THREADS=16`: | Recipe | Before tok/s | Stream + 1 MB pieces tok/s | GPU ms/token | | --- | --- | --- | --- | | Exact | 9.01, 9.01 | 9.71-9.80 | 110 -> 101 | | Exact + read-ahead (top-3) | - | 9.80-9.90 | | | lambda 0.3, keep 3, read-ahead | 13.89, 13.89 | 14.71-14.93 | 70.7 -> 66.4 | Stdout hashes matched the baseline in every run (exact 36c021ba70, Cache-Prior b2838ebf36). Measured and discarded: stream without pieces (+2.7% only); 256 KB pieces with 8 reader threads (8.47); 2 MB pieces, 512 KB pieces, 8/12/24/32 reader threads (all within 9.5-9.8); the store arena on transparent huge pages (72 s of compaction at preload, 7.56 tok/s); `DS4_CPU_SMT` pool on both hardware threads of each core (exact 9.62 -> 9.26, Cache-Prior 14.93 -> 14.49); a dynamic order taking a missed expert's job as soon as its pieces land and RAM hits otherwise (unchanged, 9.80 / 14.93); capping concurrent guess reads at 4 or 8 (unchanged). Where the exact lane's time goes now (`ds4 prof CPU lane (IQ stream)`): 32 calls a token, 2.97 ms each, the last missed piece in at 2.19 ms on average and ~0.8 ms of compute after it. fio on /strata-fast: 1 MB direct reads at queue depth 16 give 7.9 GB/s with 2.1 ms mean latency; depth 8: 6.3 GB/s; depth 4: 4.9 GB/s. A layer's ~12 MB of misses arrive together, so the exact recipe is bound by the miss bytes per layer, not by compute order. IQ1_M rows: maddubs by ones instead of |g| (sign(q8, g) is already 0 where g is: the same int16 pair sums). `ds4_gg_bench --expert --type 29 --dtype 29 --nt 1`, two rounds: 1 thread 3.0/3.1 -> 3.2/3.1 GB/s, 8 threads 19.8/20.3 -> 20.7/20.7. `--k256` bit-identical at 1, 2, 4 and 8 tokens. Gathered grid loads (18.5/17.9) and movq/movhps pairs (19.0/18.8) were slower and were dropped.