From ea34d7016a6b424b9e7aefe89b8ba785cfcdb330 Mon Sep 17 00:00:00 2001 From: Robert Karl Date: Sun, 18 Oct 2026 18:44:21 -0700 Subject: [PATCH] step 13 scope cut (sampled path + pi coding task per model family; DeepSeek V4 Flash and GLM on the 2x B200 pod); tools/pod/bringup.sh Co-Authored-By: Claude Fable 5.1 --- PLAN.md | 2 +- tools/pod/README.md | 16 ++++++++++++++++ tools/pod/bringup.sh | 40 ++++++++++++++++++++++++++++++++++++++++ tools/pod/hfget.py | 8 ++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tools/pod/README.md create mode 100755 tools/pod/bringup.sh create mode 100755 tools/pod/hfget.py diff --git a/PLAN.md b/PLAN.md index b5e046a..915df90 100644 --- a/PLAN.md +++ b/PLAN.md @@ -317,7 +317,7 @@ Expected diff shape: removals dominated by `setup.py`, `serve/`, translations an | 10 | `README.md`, `UPSTREAM.md` complete | every `src/`/`include/` hunk since the import appears in `UPSTREAM.md`; README has only numbers that have rows | Done 2026-10-18: README rewritten (build, run lines, pack chain, measured table from step 9 and 6 records only, limits, cut rule); UPSTREAM.md gains the front-end behaviour list; `src/`/`include/` diff since import is empty. | | 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 | Done 2026-10-18 on the A6000 VM (`bench/unbiased/correctness/`): 38 parity programs pass, `poly_expert_parity` fails its own bound on one UD-Q3_K_M expert (USTRAT-1); teacher-forced distributions of both engines on 16 sequences per model are within llama.cpp's own CPU-vs-GPU spread on every set and arm (T2); the greedy token agrees at every 0.5-nat-margin position but a handful of near ties per arm (USTRAT-3, USTRAT-5); drafting is not bitwise inert above 4-token windows (USTRAT-2); `strata`'s bits depend on the free VRAM at start unless the expert cache is pinned (USTRAT-4); `check-batch 4` passes. `docs/MODEL-FILES.md` has the per-file column. Not covered on 48 GB: the 24 GB tier pattern, a full-GPU Flash-Next reference. | -| 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 | +| 13 | **Model acceptance suite** (added 2026-10-17; scope cut 2026-10-19 after step 12: the model math is proven within llama.cpp's own spread, so this step checks what teacher-forced greedy cannot: the sampled path end to end and a coding agent doing real work against each model family). (a) For every model family the fork serves, on a box that holds it: Qwen3.8-Flash-Next IQ3_XXS (RTX 3090 pod), Qwen3.6-35B-A3B UD-Q3_K_M and UD-IQ4_XS (3090 pod, A6000 VM), DeepSeek V4 Flash UD-IQ2_XXS and GLM 5.3 Flash 3.0bit (the 2x B200 pod: first bring-up of both on this fork, `strata-poly`, `src/poly/deepseek4.cpp`, upstream's docs/DEEPSEEK.md and docs/GLM.md run lines). (b) The task: pi, with its tools, in a fresh sandbox directory on the pod, against the fork's server, told to write a minesweeper clone in html/js/css and make it run; sampled, not greedy (the model card's defaults, fixed seed; a second run at temperature 1.0). The page it leaves is rendered headless (lookingglass) and must load without a console error and expose a clickable grid; pi's transcript, the server log, token counts and wall time are the record. (c) The API-only variant of the same prompt for the row's decode and prompt tok/s against the step 6/9 numbers for that card, a 15 % band. One script, `frontend/tests/acceptance-real-engine.sh`, the same for every family; the pod setup downloads every file fresh from Hugging Face onto the container disk (the RunPod network volume is too slow to serve from), `tools/pod/bringup.sh`. Dropped from the 2026-10-17 stub: models whose files we do not have beyond those four families, judging the page beyond render and a click, and the first-run-sets-the-range machinery (step 14 owns performance) | per family: loaded, pi produced a page that renders and clicks, decode and PP inside the band; DeepSeek V4 Flash and GLM 5.3 Flash rows added to `docs/MODEL-FILES.md` with hashes and the box | | 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 | diff --git a/tools/pod/README.md b/tools/pod/README.md new file mode 100644 index 0000000..e77dd16 --- /dev/null +++ b/tools/pod/README.md @@ -0,0 +1,16 @@ +# Pod bring-up + +`bringup.sh ` provisions a fresh RunPod box for this fork: the fork is built from the tree +at `/opt/us2-build` (rsync it there first, submodule checkout included; the pod's own rsync is fine, macOS's +openrsync needs no `--info` flag), llama.cpp at the pin is built as the correctness reference with the dump tool +(`/opt/llamacpp-ref`), and every model file is downloaded fresh from Hugging Face at the pinned revision onto the +container disk (`/opt/us2-models`). Never serve from `/workspace`: the RunPod network volume read at 150 MB/s idle +and stalled to a few MB/s under the engine's expert-cache fill (2026-10-17). `small` is the two 24 GB-class models +(Flash-Next IQ3_XXS, Qwen3.6 UD-Q3_K_M and UD-IQ4_XS with the vision projector); `big` adds DeepSeek V4 Flash +UD-IQ2_XXS and GLM 5.3 Flash 3.0bit. The Flash-Next pack and MTP directory are made with upstream's tools as its +installer runs them. Logs under `/opt/us2-bringup/`; `BRINGUP_DONE` on the last line of `bringup.log`. + +Pod facts that matter: RunPod exposes every host CPU but enforces a cgroup quota (`/sys/fs/cgroup/cpu.max`: 31 cores +on the 3090 pod, 46 on the B200 pod), so `--pool-workers` must be set below it or the engine pins threads it cannot +run; `nvcc` lives in `/usr/local/cuda/bin`, not on PATH; `pip` needs `--break-system-packages` on Ubuntu 24.04; +`pkill -f` with an unanchored pattern over ssh kills the ssh session itself. diff --git a/tools/pod/bringup.sh b/tools/pod/bringup.sh new file mode 100755 index 0000000..f44be4e --- /dev/null +++ b/tools/pod/bringup.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# UnbiasedStrata 2 pod bring-up. bringup.sh +# small: the two 24 GB-class models (Flash-Next IQ3_XXS, Qwen3.6 UD-Q3_K_M + UD-IQ4_XS + mmproj); big: those plus +# DeepSeek V4 Flash UD-IQ2_XXS and GLM 5.3 Flash 3.0bit. Everything fresh from Hugging Face onto the container disk +# (/opt/us2-models; the RunPod network volume is too slow to serve from). The fork tree is expected at /opt/us2-build +# (rsync'd from the Mac, submodule checkout included). Logs: /opt/us2-bringup/*.log; BRINGUP_DONE at the end. +set -u +ARCH=${1:?cuda arch}; SIZE=${2:?small|big} +export PATH=/usr/local/cuda/bin:$PATH +B=/opt/us2-bringup; M=/opt/us2-models; F=/opt/us2-build; R=/opt/llamacpp-ref +mkdir -p $B $M $R; cd $B +echo "bringup start $(date -u +%FT%TZ) arch=$ARCH size=$SIZE" +pip install -q --break-system-packages huggingface_hub regex numpy > pip.log 2>&1 && echo "pip ok" || echo "pip FAILED (see pip.log)" +HF=$B/hfget.py +# --- downloads, in parallel --- +( python3 $HF unsloth/Qwen3.6-35B-A3B-MTP-GGUF 5bc3e238 $M/qwen36-mtp "Qwen3.6-35B-A3B-UD-Q3_K_M.gguf" "Qwen3.6-35B-A3B-UD-IQ4_XS.gguf" "mmproj-F16.gguf" ) > dl-qwen36.log 2>&1 & +( python3 $HF ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF ed59f92082b1e93c0e96d60a8b11aab089b52f09 $M "IQ3_XXS/*" "mmproj-Qwen3.8-Flash-Next-BF16.gguf" ) > dl-flash-next.log 2>&1 & +if [ "$SIZE" = big ]; then + ( python3 $HF unsloth/DeepSeek-V4-Flash-0731-GGUF fbbb5b93fb787c21338159b0af3318bb3f4d9768 $M/deepseek "UD-IQ2_XXS/*" ) > dl-deepseek.log 2>&1 & + ( python3 $HF neuralll/GLM-5.3-Flash-GSQ-RCO-3.0bit-Q4Kattn-GGUF 7feedfeb5ee924bfbe0064c63b124728b443ddc0 $M/glm "*.gguf" ) > dl-glm.log 2>&1 & +fi +# --- builds, while the downloads run --- +( cd $F && make build CUDA_ARCHS=$ARCH CMAKE_EXTRA=-DSTRATA_BUILD_TESTS=ON > $B/build-fork.log 2>&1 && echo "fork build ok" || echo "fork build FAILED (build-fork.log)" ) & +( cmake -S $F/third_party/llama.cpp -B $R/build -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=$ARCH -DLLAMA_CURL=OFF -DCMAKE_BUILD_TYPE=Release > $B/build-ref.log 2>&1 \ + && cmake --build $R/build --target llama -j 32 >> $B/build-ref.log 2>&1 \ + && mkdir -p $R/tools && g++ -O2 -std=c++17 $F/tools/qwen35/q36_llama_dump.cpp -I$F/third_party/llama.cpp/include -I$F/third_party/llama.cpp/ggml/include -L$R/build/bin -Wl,-rpath,$R/build/bin -lllama -lggml -lggml-base -o $R/tools/q36_llama_dump >> $B/build-ref.log 2>&1 \ + && echo "reference build ok" || echo "reference build FAILED (build-ref.log)" ) & +wait +echo "downloads and builds finished $(date -u +%FT%TZ)"; tail -n 1 dl-*.log +# --- Flash-Next pack and MTP draft directory (upstream's tools, as its installer runs them) --- +SH1=$M/IQ3_XXS/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_XXS-00001-of-00002.gguf +( cd $F && python3 tools/iq_pack.py --gguf $SH1 --out $M/pack-iq3-xxs > $B/pack.log 2>&1 && echo "pack ok" || echo "pack FAILED (pack.log)" ) & +( cd $F && STRATA_SOURCE=huggingface python3 tools/mtp_fetch.py fetch --out $M/mtp-src > $B/mtp.log 2>&1 \ + && python3 tools/mtp_pack.py --src $M/mtp-src --experts q2_0 --out $M/mtp-src/mtp-q2_0.gguf >> $B/mtp.log 2>&1 \ + && python3 tools/mtp_rt.py --gguf $M/mtp-src/mtp-q2_0.gguf --out $M/mtp >> $B/mtp.log 2>&1 \ + && cp data/draft_vocab.bin $M/mtp/draft_vocab.bin && echo "mtp ok" || echo "mtp FAILED (mtp.log)" ) & +wait +# --- hashes of what will be served --- +( cd $M && find . -name "*.gguf" -type f | sort | xargs sha256sum > SHA256SUMS ) 2>/dev/null +echo "bringup end $(date -u +%FT%TZ)"; echo BRINGUP_DONE diff --git a/tools/pod/hfget.py b/tools/pod/hfget.py new file mode 100755 index 0000000..b79a493 --- /dev/null +++ b/tools/pod/hfget.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 +"""hfget.py REPO REVISION LOCAL_DIR PATTERN [PATTERN...]: snapshot_download of the matching files at the pinned +revision into LOCAL_DIR (the repo's own paths under it). Fresh from Hugging Face every time, onto the local disk.""" +import sys +from huggingface_hub import snapshot_download +repo, rev, out, pats = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4:] +p = snapshot_download(repo_id=repo, revision=rev, local_dir=out, allow_patterns=pats, max_workers=8) +print("downloaded", repo, rev, "->", p, pats, flush=True)