Files
UnbiasedStrata/UPSTREAM.md
T
Robert KarlandClaude Fable 5.1 f499b8cf37 correctness tooling for DeepSeek V4 Flash and GLM 5.3 Flash: @FILE id lists, per-model script roots, pi context note
- src/poly/main.cpp: --tokens/--eos-ids/--follow take @FILE (a 31K-id list is over Linux's 128 KiB argument limit);
  tools/qwen35/q36_llama_dump.cpp: the same for --tokens/--force. Test-only; documented in UPSTREAM.md.
- bench/unbiased/correctness/scripts: US2_CORR_ROOT / US2_DUMP / US2_POLY / US2_VOCAB overrides so the step-12 scripts
  run for another model, tokenizer and reference build; ids passed as @FILE; stderr decoded with errors='replace'
  (DeepSeek's vocabulary pieces are not all UTF-8); make-inputs-model.py (inputs through the fork front end's
  /apply-template + /tokenize); pull-record-2026-10-19.sh.
- README: pi's compaction defaults need a window well above 32K (USTRAT-8).

Runs on the 2x B200 pod in progress; record follows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-19 00:00:49 -07:00

13 KiB

Relationship to upstream

Sources

What Where Version
Engines (strata, strata-poly), tools, docs https://github.com/VecSzn/PolyStrata tag v0.1.45-poly.1, commit d0cd84dc6bd009d1d9e2191e4e28cc76b80f1ee3
ggml, llama, common, mtmd, cpp-httplib https://github.com/ggml-org/llama.cpp, as the submodule third_party/llama.cpp commit 3cf03257f219afbe7334045ff7c6a06ac68c627d, the one upstream pins

Commit 0197ae86 ("Import PolyStrata v0.1.45-poly.1 (d0cd84dc) unmodified") is the upstream tree, every tracked file, with the same tree hash as upstream's commit. git diff 0197ae86 HEAD is the whole story of this fork; git diff 0197ae86 HEAD -- src include is every change to the engines.

The history before that commit is UnbiasedStrata 1, a fork of Niko1221/Strata 0.1.39, ended at the tags unbiasedstrata-1 and unbiasedstrata-1-muse-spark-native.

Rules

A thing is removed only when it (1) reaches the network during setup, build or start-up, (2) puts Python between a request and a token, (3) breaks or complicates the one-command build, or (4) is marketing. Everything else stays, built or not. Engine changes are bug fixes for the target (Linux x86-64, one NVIDIA GPU, Pascal or newer, CUDA 12.x), each recorded below with the file, the reason and the measurement.

Build (CMakeLists.txt, Makefile, .gitmodules, .gitignore, patches/)

  • ggml from the submodule, not a fetch. STRATA_GGML_DIR defaults to third_party/llama.cpp and the configure stops with the git submodule update --init line if ggml/CMakeLists.txt is missing. Upstream's FetchContent of llama.cpp (the only network access of its build) is deleted. The three later if(STRATA_GGML_DIR) blocks are unchanged; their else() branches are now dead. .gitignore no longer ignores /third_party/llama.cpp*.
  • patches/*.patch applied at configure time. Each patch is checked in reverse first, so configuring twice applies it once. The submodule's working tree is therefore modified after a configure; git -C third_party/llama.cpp diff shows exactly the patches. UnbiasedStrata 1 applied its patch in make and in CMake both; here it is CMake only, so a tree configured directly gets it too.
  • llama.cpp's libraries for the front end. A second add_subdirectory of the submodule with LLAMA_BUILD_COMMON and LLAMA_BUILD_MTMD on and tests, tools, examples, server, app, UI, prebuilt UI, OpenSSL and llguidance off. It reuses the ggml targets configured above. Gated by STRATA_FRONTEND (default on), not by CUDA, so the front end also builds on a machine without a GPU.
  • The front end, unbiased-strata. Seven of llama.cpp's tools/server files are compiled unmodified from the submodule into a static library (server-http, server-queue, server-task, server-common, server-chat, server-schema, server-stream): the HTTP layer, the task queue, the OpenAI request and result types, SSE framing, the request schema. The eighth, server-context.cpp, is bound to llama_context and is replaced by frontend/strata_context.cpp, which runs the engine as a child process over its line protocol (docs/BACKENDS.md) and uses a vocab-only llama_model for tokenizing, the chat template and the output parsers. server-http.cpp references the web UI's asset table (ui.h, generated by tools/ui at build time, which downloads); frontend/ ui_stub/ provides an empty one. No patch to llama.cpp was needed for this; the undocumented internal API of tools/server is used as it is at the pinned commit.
  • Makefile. make build configures once and builds strata, strata-poly, strata_kq and unbiased-strata into build/bin/, not upstream's all, which also builds about 70 parity and bench programs. make frontend builds the front end alone without CUDA into build-frontend/; make test builds and runs the front end's tests there against a fake engine (frontend/tests/): the adapter's cases and the HTTP surface a coding agent touches. The nvcc check applies only to the build and configure goals. CUDA_ARCHS defaults to 61;75;86;89; an arch below 75 adds upstream's STRATA_EXPERIMENTAL_SM60 (upstream's default is 120, which needs CUDA 13). PORTABLE=1 gives the AVX2 baseline instead of -march=native. One GCC for the C, C++ and nvcc host sides: the Makefile probes g++-15, g++-14, ... with nvcc -ccbin and passes the newest accepted one as CMAKE_C_COMPILER, CMAKE_CXX_COMPILER and CMAKE_CUDA_HOST_COMPILER. Without that, on a box whose default g++ is newer than nvcc accepts (Debian 13 with CUDA 12.4: GCC 14 against a GCC 13 limit), the C++ files were compiled by GCC 14 and the CUDA files by GCC 13, and strata failed to link on __cxa_call_terminate (upstream's installer handles the same case, its #1645). HOSTCXX=/usr/bin/g++-13 overrides the probe.

Front end behaviour (frontend/), where it differs from llama-server or from upstream's server

Recorded here because a client written for one of the two may notice.

  • /health returns llama.cpp's {"status": "ok", "busy": ...} plus upstream's "service": "strata", "loaded": true, "model", "max_context" (commit 453d3015). Upstream's tools/strata_bench.py refuses a server without the first two; the first step-9 fork arm was lost to that (bench/unbiased/2026-10-17-3090pod-step9/README.md).
  • Streams always end with a usage chunk (empty choices, usage, timings), as upstream's server does, whether or not the client sent stream_options.include_usage; llama-server sends it only on request (96f4ef1f). Same reason: the bench client reads prompt_tokens from it.
  • One slot. Requests are served one at a time in arrival order, as upstream's server does with one engine.
  • No constrained decoding. response_format and tool schemas are parsed and used for output parsing, not enforced at the sampler, because the engine samples; logged once per such request.
  • Pictures are encoded in the front end (--mmproj FILE, commit 71886db0 and after): llama.cpp's mtmd runs the projector and the front end writes upstream's SVE1 record file and sends GENI … image_pad=<id> <file>, the protocol upstream's Python server spoke to strata-vision. Projector width is checked against the model's embedding width at start. The default row budget is upstream's installer's (300 on the CPU, 1024 on the GPU; --image-max-tokens overrides). The encoder runs on the CPU: the front end's ggml is built without CUDA, and --mmproj-gpu is refused when ggml has no GPU device (17e27213). Measured in bench/unbiased/2026-10-18-a6000-qwen36-iq4xs-images-step8/.
  • --sse-ping-interval is llama-server's (default 30 s); the measured Flash-Next runs used 10.
  • SIGTERM exits 1, not 0, after stopping the engine: the engine child dies with the process group and the front end reports it as an engine death with an empty message. Open; matters only to a service manager.
  • Default min_p is llama-server's 0.05 when a request omits it; upstream's server sends none. pi sends 0.

Patches to llama.cpp (patches/)

  • llama.cpp-qwen3-coder-any-argument-order.patch (common/parsers/qwen3-coder.cpp): the Qwen3-Coder tool-call grammar accepts a call's arguments in any order. Upstream takes the required ones first and the optional ones after; Qwen3.8 Flash-Next often writes the optional ones first (limit, offset, path), and because the grammar's tool-call group is optional and has no end anchor, such a call was dropped silently: the client got finish_reason=stop and an empty answer (UnbiasedStrata 1, 2026-10-08, REGINA-104). Qwen3.6's template routes to the same parser. Carried over unchanged; it applies cleanly at this pin.
  • llama.cpp-any-argument-order.patch (common/chat-auto-parser-generator.cpp, common/parsers/deepseek.cpp): the same for every template the auto-generated PEG grammar serves (DeepSeek V4 Flash's DSML, GLM 5.3 Flash's <arg_key> form, and the rest). Upstream accepts the required arguments only in the schema's order, which holds when its own sampler is constrained by the grammar; this engine samples unconstrained, and both models wrote content before path for a write tool that declares path first, so a finished, well-formed call was reported to the client as "output does not match the expected peg-native format" (PLAN.md step 13, 2026-10-19, USTRAT-7). Whether every required argument is present is left to the tool, as upstream already leaves it for optional-only tools.

Engine source (src/, include/)

No changes: git diff 0197ae86 HEAD -- src include is empty (checked 2026-10-18). The engines measured in step 9 are these sources built in this tree; their binaries differ from upstream's build of the same sources, and the step-9 record says so where it matters.

Step 12 (bench/unbiased/correctness/, 2026-10-18) checked these builds against llama.cpp 3cf03257: upstream's parity programs that cover the kernels in use (38 pass, poly_expert_parity fails its own bound on one UD-Q3_K_M expert), and teacher-forced per-step distributions on 16 sequences per model (within llama.cpp's own CPU-vs-GPU spread on every set and arm). Two upstream claims did not hold and are not repeated here: the draft block is not bitwise inert above 4-token windows, and strata's output is not reproducible across starts unless the expert cache is pinned. Tickets USTRAT-1 to 5.

One test-only hunk since (2026-10-19, correctness checks of DeepSeek V4 Flash and GLM 5.3 Flash): src/poly/main.cpp --tokens, --eos-ids and --follow accept @FILE (the comma-separated ids read from that file), because a 31K-id list is over Linux's 128 KiB single-argument limit. tools/qwen35/q36_llama_dump.cpp (upstream's llama.cpp-side parity program, not part of the build) takes the same @FILE for --tokens and --force. Nothing on the serve path changes.

Removed

Each entry names the rule above that it satisfies.

  • Rule 1, installers and downloaders: setup.py (8,223 lines: hardware detection, pip, CUDA, llama.cpp zips, prebuilt engines from GitHub releases, model files from Hugging Face or ModelScope, pack and MTP orchestration, run-config JSON, start), setup.sh, SETUP.bat, START-HERE.bat, UPDATE.bat, update.sh, Dockerfile, docker-entrypoint.sh, .dockerignore, flake.nix, flake.lock, requirements.txt (replaced by tools/requirements.txt: numpy and regex, for the offline tools only), conftest.py (pytest root for setup.py's tests), tools/strata_mcp.py (an installer driven over MCP), tools/image/ (stable-diffusion.cpp, Vulkan SDK and model downloads), tools/hip/package_windows.py (AMD nightly wheels), and their tests (tools/test_setup_*.py with two golden JSONs, test_strata_mcp.py, test_qimage.py, test_docker_entrypoint.py, test_poly_prebuilt.py). The jobs of setup.py that were not downloads (choosing engine flags per card, RAM and context) become documented flags in README.md.
  • Rule 2, Python in the serving path: serve/ (92 files, 33.9k lines: the HTTP server with the OpenAI, Anthropic and Responses dialects, the jinja2 chat templating, the Python tokenizer path, the per-family reasoning and tool-call parsers, MCP, structured output, replicas, Prometheus, the hardware monitor, the web UI and 58 test files) and polystrata.py (the terminal front end, which imports serve/). Replaced by the C++ front end in frontend/, built from the pinned llama.cpp's common, mtmd, cpp-httplib and the engine-agnostic files of tools/server. The engines' stdin/stdout protocol is unchanged.
  • Rule 4, marketing: the six translated READMEs (383 KB), docs/media/ (12 MB: a 9.6 MB demo video still, a 1.8 MB GIF, the figure SVGs and their generator), .github/ (issue and PR templates), SECURITY.md (the upstream project's advisory process) and AGENTS.md (contributor notes for upstream's tests and installers). README.md is rewritten for this fork (PLAN.md step 10); the fork's model-file record is docs/MODEL-FILES.md, its measurements are under bench/unbiased/.
  • Documents only removed components (decided 2026-10-17): docs/INSTALL.md, AI_SETUP.md, MCP_SERVER.md, IMAGES.md, LLAMA_SWAP.md, COMMUNITY_BENCHMARKS.md, FAQ.md; chat.py (a terminal client) and tools/calibrate.py (imports setup and serve.server), with their tests.
  • Scripts that imported removed modules (decided 2026-10-17): the engine gate scripts that drove the engine through the Python server's StrataEngine class (tools/batch_groups_cache_test.py, cancel_park_test.py, conversation_cache_*.py, conversation_restore_speed.py, logit_bias_english_example.py, logit_bias_http_probe.py, session_pressure_test.py), tools/strata_bench.py with bench.sh and BENCH.bat (one helper from setup), tools/make_poly_release.py, and the tests that imported setup or serve (test_mtp_fetch.py, test_shards.py, test_strata_tokenizer.py, test_effort_end_args.py, test_research_run.py, test_benchmark_prompt.py, test_dll_closure.py, test_windows_amd_gpu.py, the test_conversation_cache_* and test_strata_bench.py). The benchmark scripts under bench/results/*/ stay as the record they are. Upstream's copies run against upstream.