Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/docs/persistent-kv/BENCH.md # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / docs / persistent-kv / BENCH.md` 96 lines ยท 10594 bytes Raw Blame History Rendered 1 # Persistent KV benchmark (cut C9, sc#485) 2 3 Binding design: ADR 0003 (sections 10, 15.1, 16.5). Cut and schema: CUTS.md C9 (B6, B7, B8). Evidence rules: ADR 0001 decisions 2 and 3. 4 5 ## What this measures 6 7 `bench_persistent_kv` runs conversations through the real runtime: the spine, the scheduler, `NativeTransformerBackend` over `ReferenceCpuBackend` (host CPU arithmetic, bf16 KV pool) with the synthetic reference test weights, and, for the restore mode, the C4 host filesystem store switched on through the daemon wiring (`shared_kv::enable_persistent_kv`). Host only: no GPU, no CUDA, no root. 8 9 Each row is one mode at one concurrency (1, 2, 4, 8 conversations) and one prompt length (512, 2048 tokens), repeated for a number of rounds: 10 11 | mode | workload | what happens | cache_state | 12 |---|---|---|---| 13 | `resident-only` | `single_turn` | one request per conversation, store off; nothing ever leaves memory | `none` | 14 | `cold-prefill` | `second_turn` | turn 1, then turn 2 (turn-1 prompt + turn-1 output + 16 new tokens), store off; turn 2 prefills everything | `none` | 15 | `restore-from-page-cache` | `second_turn` | the same turns with the store on: turn 1 parks, turn 2 restores the stored prefix and prefills only the rest. The objects were written moments before and no cache was dropped. A row is refused unless every measured request committed a restore | `page_cache` | 16 | `restore-from-device` | | NOT_RUN: a device read needs the page cache dropped (root) and verified empty (ADR 15.1); the harness never uses sudo | `device` | 17 | `native-physical` (Spark, Pi 5) | | NOT_RUN in every report (B8): a host run cannot speak for native hardware | `device` | 18 19 Only the turn-2 requests (or the single turn of `resident-only`) are timed. Every report records, per row: completed and failed requests, request latency p50/p95, time to first token p50/p95, decode tokens per second, the KV pool allocation, the peak holder bytes, the staging bytes, the peak RSS, the store dispatch depth, the restored token count, and every raw sample. The exact definition of each field is written into the report itself (`definitions`). 20 21 Rules the binary enforces (tests in `crates/aien-kv-bench/tests/bench_persistent_kv_test.rs`): 22 23 - no row without its mode, platform and cache_state labels, and no default mode (B7); 24 - no measured row without every metric of the B6 schema, percentiles that match the raw samples, and at least one completed request (B6); 25 - latency summaries never mix cache states (ADR 15.1); 26 - every report carries the Spark-native and Pi 5 physical rows as NOT_RUN with a reason, and refuses measured numbers for any platform other than `hosted` (B8); 27 - a report is never overwritten; it records the commit, whether the tree was clean, the machine, the nice value, the exact command and the sha256 of the raw samples. 28 29 ## How to reproduce 30 31 ``` 32 cargo build --release -p aien-kv-bench --bin bench_persistent_kv 33 nice -n 19 ./target/release/bench_persistent_kv \ 34 --modes resident-only,cold-prefill,restore-from-page-cache,restore-from-device \ 35 --concurrency 1,2,4,8 --prompt-tokens 512,2048 --rounds 10 \ 36 --out benchmarks/data/persistent_kv_host_.json --store-root target/pkv-bench-store 37 ./target/release/bench_persistent_kv --render benchmarks/data/persistent_kv_host_.json 38 ``` 39 40 `--render` re-checks the report (schema, labels, NOT_RUN rows, samples digest) and prints the table below. 41 42 ## Where the numbers live (ADR 0001) 43 44 The canonical record is the JSON file in `benchmarks/data/`, named by its measurement id. ADR 0001 names `benchmarks/data/benchmarks_latest.json` and a `sync-docs` tool; neither exists in the repository (also recorded in `docs/plans/public-surface-cleanup.md`). DOCS SILENT choice, narrowest rule: this bench writes its own file and never edits `latest.json`, `master_benchmark_results.json` or the inference sweep files, and the table below is generated by `--render` from that file, not typed by hand. 45 46 ## Results (host, generated from `benchmarks/data/persistent_kv_host_20261014T010721Z.json`) 47 48 49 Measurement `BENCH-PKV-HOST-20261014T010721Z-`5a07c36``, commit ``5a07c36ab753276f760494863f9a2b7585bb57ff``, 2026-10-14T01:07:21Z UTC, platform `hosted`, backend `NativeTransformerBackend over ReferenceCpuBackend (host CPU, FP32 arithmetic, bf16 KV pool)`, host: the DGX Spark (aarch64, 20 CPUs, kernel 7.0.0-1019-nvidia, nice 19). 50 51 Command: `bench_persistent_kv --modes resident-only,cold-prefill,restore-from-page-cache,restore-from-device --concurrency 1,2,4,8 --prompt-tokens 512,2048 --rounds 10 --out benchmarks/data/persistent_kv_host_20261014T010721Z.json --store-root target/pkv-bench-store` 52 53 | mode | status | cache_state | conc | prompt | done/failed | p50 us | p95 us | ttft p50 us | ttft p95 us | decode tok/s | restored tok | pool bytes | holder peak | staging | peak RSS | queue depth | 54 |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---| 55 | resident-only | OK | none | 1 | 512 | 10/0 | 26885 | 30765 | 21703 | 27365 | 3503 | 0 | 528384 | 0 | 0 | `6914048` | 0 | 56 | resident-only | OK | none | 2 | 512 | 20/0 | 67801 | 77390 | 43922 | 50057 | 1247 | 0 | 860160 | 0 | 0 | `7282688` | 0 | 57 | resident-only | OK | none | 4 | 512 | 40/0 | 120314 | 128336 | 86016 | 91213 | 1692 | 0 | `1523712` | 0 | 0 | `8007680` | 0 | 58 | resident-only | OK | none | 8 | 512 | 80/0 | 212563 | 236190 | 158525 | 188198 | 2343 | 0 | `2850816` | 0 | 0 | `9412608` | 0 | 59 | resident-only | OK | none | 1 | 2048 | 10/0 | 224236 | 229344 | 211023 | 216721 | 1180 | 0 | `1413120` | 0 | 0 | `13832192` | 0 | 60 | resident-only | OK | none | 2 | 2048 | 20/0 | 477043 | 486085 | 422782 | 435221 | 592 | 0 | `2629632` | 0 | 0 | `15171584` | 0 | 61 | resident-only | OK | none | 4 | 2048 | 40/0 | 944657 | 959201 | 447167 | 866841 | 116 | 0 | `5062656` | 0 | 0 | `17678336` | 0 | 62 | resident-only | OK | none | 8 | 2048 | 80/0 | `1850602` | `1886412` | 862684 | `1730094` | 84 | 0 | `9928704` | 0 | 0 | `22790144` | 0 | 63 | cold-prefill | OK | none | 1 | 512 | 10/0 | 25947 | 30202 | 21395 | 25301 | 3562 | 0 | 528384 | 0 | 0 | `13389824` | 0 | 64 | cold-prefill | OK | none | 2 | 512 | 20/0 | 73385 | 85255 | 45830 | 59546 | 1151 | 0 | 860160 | 0 | 0 | `13721600` | 0 | 65 | cold-prefill | OK | none | 4 | 512 | 40/0 | 115292 | 139358 | 85367 | 100550 | 1758 | 0 | `1523712` | 0 | 0 | `14385152` | 0 | 66 | cold-prefill | OK | none | 8 | 512 | 80/0 | 239925 | 250341 | 172002 | 189685 | 1742 | 0 | `2850816` | 0 | 0 | `15712256` | 0 | 67 | cold-prefill | OK | none | 1 | 2048 | 10/0 | 232470 | 236956 | 219789 | 224248 | 1163 | 0 | `1413120` | 0 | 0 | `15151104` | 0 | 68 | cold-prefill | OK | none | 2 | 2048 | 20/0 | 491399 | 519864 | 437217 | 456114 | 431 | 0 | `2629632` | 0 | 0 | `16408576` | 0 | 69 | cold-prefill | OK | none | 4 | 2048 | 40/0 | 948655 | 962056 | 839660 | 870338 | 113 | 0 | `5062656` | 0 | 0 | `18948096` | 0 | 70 | cold-prefill | OK | none | 8 | 2048 | 80/0 | `1871585` | `1906118` | `1267748` | `1753110` | 82 | 0 | `9928704` | 0 | 0 | `24383488` | 0 | 71 | restore-from-page-cache | OK | page_cache | 1 | 512 | 10/0 | 10063 | 11884 | 3712 | 4969 | 2682 | 5120 | 528384 | 101376 | 3072 | `15319040` | 4 | 72 | restore-from-page-cache | OK | page_cache | 2 | 512 | 20/0 | 33386 | 38450 | 3769 | 7329 | 1020 | 10240 | 860160 | 202752 | 3072 | `15843328` | 4 | 73 | restore-from-page-cache | OK | page_cache | 4 | 512 | 40/0 | 45491 | 56199 | 12347 | 14196 | 1356 | 20480 | `1523712` | 405504 | 3072 | `16506880` | 4 | 74 | restore-from-page-cache | OK | page_cache | 8 | 512 | 80/0 | 75847 | 82291 | 23789 | 28650 | 1634 | 40960 | `2850816` | 811008 | 3072 | `17854464` | 4 | 75 | restore-from-page-cache | OK | page_cache | 1 | 2048 | 10/0 | 36360 | 40269 | 11278 | 15391 | 749 | 20480 | `1413120` | 396288 | 3072 | `16416768` | 4 | 76 | restore-from-page-cache | OK | page_cache | 2 | 2048 | 20/0 | 76298 | 87144 | 12971 | 23796 | 447 | 40960 | `2629632` | 792576 | 3072 | `17645568` | 4 | 77 | restore-from-page-cache | OK | page_cache | 4 | 2048 | 40/0 | 135964 | 156081 | 38842 | 53965 | 486 | 81920 | `5062656` | `1585152` | 3072 | `20094976` | 4 | 78 | restore-from-page-cache | OK | page_cache | 8 | 2048 | 80/0 | 215189 | 248743 | 72130 | 91416 | 560 | 163840 | `9928704` | `3170304` | 3072 | `25022464` | 4 | 79 | restore-from-device (hosted) | NOT_RUN | device | - | - | - | - | - | - | - | - | - | - | - | - | - | - | 80 | native-physical (native_physical) | NOT_RUN | device | - | - | - | - | - | - | - | - | - | - | - | - | - | - | 81 | native-physical (native physical (Pi 5)) | NOT_RUN | device | - | - | - | - | - | - | - | - | - | - | - | - | - | - | 82 83 NOT_RUN reasons: 84 85 - restore-from-device (hosted): a device read needs the page cache dropped (root: /proc/sys/vm/drop_caches) and verified empty with mincore (ADR 0003 section 15.1); this harness never uses sudo, and O_DIRECT reads are cut X1/X2 86 - native-physical (native_physical): Spark-native physical run is blocked on aienos#336 (not authorized); a host run cannot stand in for it 87 - native-physical (native physical (Pi 5)): Pi 5 physical lane is cut P3 (ADR 16), needs Drake's authorization and a free Pi; not run 88 89 90 ## What the run shows, and what it does not 91 92 - The numbers come from a tiny synthetic model on the CPU. They show how the harness and the persistent KV path behave against each other on this machine; they say nothing about real model speed, GB10 speed, or NVMe speed. 93 - Turn-2 requests that restore their prefix from the page cache reach their first token sooner than the same requests prefilled cold, at every concurrency of this run (compare `ttft` of `cold-prefill` and `restore-from-page-cache` in the table). 94 - Store bounds (finding of the first full run, refused by the row guard and not recorded): with the default per-class bounds (48 restore, 16 park at the time, ADR 7.1), 8 conversations finishing in the same step submit 24 chunk parks and 8 are refused `QueueFull`. That is the designed behaviour (not parked this turn, the next turn prefills), but it means the defaults are too small for 8 simultaneous finishes. The bench now sets `AIEN_KV_STORE_MAX_RESTORE_OPS` and `AIEN_KV_STORE_MAX_PARK_OPS` to concurrency times the chunks per turn plus one; the park default is now 64 (ADR 0003 section 18.4). 95 - `resident-only` is a single turn, so its latency is not a turn-2 number; it is the reference for a conversation that never leaves memory (this runtime has no cross-request resident prefix reuse to measure a resident turn 2). 96 - Not measured: device reads, O_DIRECT, the queue-depth sweep, CPU time per MiB and the device ceiling (cut X1), and every native row.