From 20ece30f5437ffe135692be51f55dac55ca0103a Mon Sep 17 00:00:00 2001 From: Robert Karl Date: Sun, 18 Oct 2026 00:11:07 -0700 Subject: [PATCH] PLAN: steps 14-17, the ship bar (performance parity, accuracy vs llama.cpp with a measured noise floor, front-end equivalence, release gate; decided 2026-10-18) Co-Authored-By: Claude Fable 5.1 --- PLAN.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PLAN.md b/PLAN.md index 802a123..641736a 100644 --- a/PLAN.md +++ b/PLAN.md @@ -318,6 +318,15 @@ Expected diff shape: removals dominated by `setup.py`, `serve/`, translations an | 11 | **Correctness plan** (added 2026-10-17). An agent writes `docs/CORRECTNESS-PLAN.md`: how to check PolyStrata's engines against llama.cpp at the pinned commit for the kernels actually in use on our target (the expert MMQ paths for IQ3_XXS and the K-quants, the MTP draft layer, the Q8/int8 KV paths, the prompt path, `strata-poly`'s qwen35moe path), which of upstream's ~70 parity and bench programs cover them and what each compares against, the teacher-forced greedy id comparison against llama.cpp for Flash-Next and Qwen3.6 (same ids in, how many tokens, what divergence is tolerated and why), what a failure would mean for the fork, and the cost in machine time. Planning only: this step runs nothing on a GPU and changes no code | the document, with each proposed check naming the program or script, the reference it compares against and the pass criterion; your sign-off on which checks become a later step | | 12 | **Correctness checks** (added 2026-10-17). Run the checks step 11 proposed and you signed off: upstream's parity programs that cover the kernels in use, and the teacher-forced greedy id comparison of each engine against llama.cpp at the pinned commit for Flash-Next IQ3_XXS and Qwen3.6 UD-Q3_K_M. Results, commands and raw outputs under `bench/unbiased/correctness/`; a divergence is a bug to find, in the engine or in llama.cpp, before any README claim beyond "same output as upstream PolyStrata" | every signed-off check has a result on disk with its pass criterion met, or an open finding with the first diverging token, the inputs that reproduce it and which side is wrong; `docs/MODEL-FILES.md` says per file whether it passed | | 13 | **Model acceptance suite** (stub, added 2026-10-17; to be planned). For every model file in `docs/MODEL-FILES.md`, and for every model upstream supports once its file is on a box that can hold it (GLM 5.3 Flash, DeepSeek V4 Flash, Qwen3.6-35B-A3B, Qwen3.8 Flash-Next first): (a) load it through the front end; (b) ask for a program, sampled, not greedy (temperature 0.6 and 1.0, fixed seed), and run it: the prompt is "write a minesweeper clone in html/js/css", the output is saved as a page and opened in a headless browser (lookingglass), which must render it without a console error and find a clickable grid; (c) record decode and prompt tok/s and compare them with an expected range for that model and card, kept in the table. One script, `frontend/tests/acceptance-real-engine.sh`, the same for every file. Open: where the expected ranges come from for cards upstream never measured (first run sets them, later runs must stay within them?), how far the judging of the minesweeper page goes beyond rendering and a click (a mine count? a win?), and the ~200 GB of GLM and DeepSeek files the pod needs | per file: loaded, program produced and ran, decode and PP inside the expected range, all written to `docs/MODEL-FILES.md`; a file outside its range is a finding, not a pass | +| 14 | **Performance parity protocol** (added 2026-10-18; the ship bar is "within 5 % of upstream on decode and prompt processing", every model, every target card). Builds on step 9. (a) Same engine binary on both sides first: the fork front end driving upstream's engine binaries (the `forkfe-upengine-*` arms of 2026-10-18) separates the front end from the engine build; then both engines built with the same compiler, nvcc, flags and `-march` recorded, so the two binaries differ in nothing but the tree they were built in. (b) Workloads, each 5 runs, median and range, greedy: short chat decode; sustained 512-token decode; prefill 4K / 16K / 32K and the model's maximum context; agent turns with growing history, with the reused-token counts recorded (a front end that renders the template differently breaks the prompt cache, and that shows as `cache_n`, not as tok/s); time to first token; inter-token latency p50 and p99 from the client's timestamps; client-side tok/s next to engine-side tok/s (the SSE and JSON cost of each front end); cold start to READY and warm start. (c) Every file in `docs/MODEL-FILES.md`, on each target card (Pascal 1080 Ti, RTX 3090, A6000), upstream and fork back to back. (d) A 1-hour soak of mixed request shapes with RSS and VRAM sampled every minute. Pass: fork median within 5 % of upstream on every (model, card, workload) cell, or the ranges overlap; `cache_n` equal per turn; RSS and VRAM flat. Any cell outside is a finding with the arm directories that reproduce it | tables under `bench/unbiased/parity/-/` with provenance (engine sha256, compiler, flags) per arm; every cell filled or marked blocked with the reason | +| 15 | **Accuracy protocol against llama.cpp** (added 2026-10-18; extends step 12 with pass criteria). The reference is llama.cpp at the pinned commit, CUDA build, on the same GGUF. (a) Noise floor first: llama.cpp CUDA versus llama.cpp CPU on the same model and ids, per-position logits: max abs difference, KL(ref||other) per position, top-1 agreement. That floor is the tolerance, as the user put it: "as close as llama.cpp's GPU and CPU kernels are to each other". (b) Kernel level: upstream's parity programs that cover the kernels in use (step 11's list) at the pinned commit on each target arch, all green; the per-kernel error against the ggml reference recorded, not only pass/fail; target 1e-5 relative where the kernel is exact-arithmetic (norms, rope, residual), and the quant kernels within the floor from (a). (c) Logit level, teacher-forced: the engine's per-position logits along fixed ids (upstream's `--teacher-force` style diagnostics, `tools/canonical_xcheck.py`) against llama.cpp CUDA for Flash-Next IQ3_XXS and Qwen3.6 UD-Q3_K_M and UD-IQ4_XS: per-position KL median and p99, top-1 agreement rate, first position where the greedy argmax differs; 20 prompts of 512 to 4096 tokens including code and a tool-call transcript. Pass: median KL within 2x the floor from (a), top-1 agreement not below the floor's. (d) Perplexity on a fixed public text (a wikitext-2 slice, 64K tokens) engine versus llama.cpp CUDA: within 1 %. (e) Speculation is lossless: greedy ids with `--spec 0` equal to `--spec 4` and to the drafter off, for 20 prompts x 512 tokens; sampled with a fixed seed likewise. (f) Each speed knob upstream ships on by default that changes answers (`--tail-skip`, `STRATA_ROUTE_TAIL_SKIP`, int8 KV, `--spec-min-p`) measured off versus on with the (c) metrics, so the README states the accuracy cost of each default. (g) Long context: a needle test (`tools/needle_bench.py`) at 32K and the model's maximum, engine versus llama.cpp. Pass criteria written down before the runs | `bench/unbiased/correctness//` with the floor, every metric per model, the commands and the raw logits' checksums; `docs/MODEL-FILES.md` says per file: KL median and p99 against llama.cpp, top-1 agreement, PPL ratio | +| 16 | **Front-end equivalence to upstream's Python server** (added 2026-10-18; the part of the port that is not the engine). (a) Prompt rendering: a corpus of chat requests (system prompt, multi-turn, tools with optional arguments, tool results, `reasoning_content` on assistant turns, `enable_thinking` on and off, `preserve_thinking`, an image once step 8 lands) rendered by upstream's jinja2 path and by llama.cpp's template engine in the fork: the token id sequences must be identical, per model template. A difference changes what the model sees and breaks checkpoint reuse. (b) Output parsing: a corpus of raw model outputs (tool calls in both argument orders, parallel calls, reasoning blocks, truncated streams) parsed by upstream's per-family parsers and by llama.cpp's: same `tool_calls`, same `content`, same `reasoning_content`. (c) Streaming equals non-streaming: for the same seed, the concatenated deltas equal the non-streamed message, usage counts equal the engine's `DONE` counts. (d) API conformance: the HTTP-level tests of upstream's `serve/` (import commit, 58 files) that apply to the kept surface, ported to run against both servers; cancel and disconnect semantics (the engine is told to stop; the next request is clean) on both. (e) Task level: pi on 10 fixed coding tasks x 3 runs per server, pass rate and tokens per wall second; within noise | corpora and results under `bench/unbiased/frontend-equivalence/`; a rendering or parsing difference is a bug in the fork unless upstream is shown wrong, with the request that reproduces it | +| 17 | **Release gate** (added 2026-10-18). Steps 12 to 16 green or every open finding written in `README.md` with its size; the acceptance suite (13) run on every file on at least one card; `UPSTREAM.md` current; a tagged commit with the `bench/unbiased/` directories it was judged on | the tag; the README's measured table cites only those directories | + +Steps 14 to 17 (2026-10-18) are the ship bar for consumers of PolyStrata: as fast and as accurate as upstream within +5 % on decode and prompt processing, kernels within 1e-5 where exact and otherwise within the spread between +llama.cpp's own GPU and CPU kernels, logits close in KL, and the front end rendering and parsing exactly what the +Python server did. Step 8 (images) precedes them in order; step 5 stays on its fallback by decision. Step 13 is the minimum "does it work" bar per model file: load, a sampled program that runs, speed inside a known range. It is a sanity check, not a correctness proof: a kernel that is slightly wrong still writes a program that runs,