UPSTREAM.md gets the two new source rows and a section on what was taken from Strata v0.2.4 and what was not; docs/DEEPSEEK41.md is rewritten for this fork (files, pack recipe, run line, what is and is not there) in place of upstream's installer-centred text; the README lists the third engine and its run line. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
216 lines
20 KiB
Markdown
216 lines
20 KiB
Markdown
# 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/robertkarl/llama.cpp, branch `UnbiasedStrata`, as the submodule `third_party/llama.cpp` | commit `385445fad49e42fa718b5e1f71668f35b7a08559`: ggml-org `3cf03257f219afbe7334045ff7c6a06ac68c627d` (the commit upstream pins) plus the six parser commits below |
|
|
| DeepSeek-V4.1 engine (`strata-dsv41`: `src/dsv41`, `include/strata/dsv41`, `tests/dsv41`, `tools/dsv41`, `data/dsv41`, `tools/trellis/tqenc.*`), the trellis and `iq*x_rows` CPU kernels it needs | https://github.com/Niko1221/Strata | tag `v0.2.4`, commit `96ca4383` (2026-10-24); see "DeepSeek-V4.1 engine" below |
|
|
| llama.cpp's DeepSeek V4.1 chat template detection and DSML parser | https://github.com/ggml-org/llama.cpp pull 30817, head `b72050d0` | the `common/chat.cpp`, `common/chat.h`, `common/parsers/deepseek.cpp` hunks only, as commit `44072a1` on the submodule branch `deepseek41-parser` (on `385445f`) |
|
|
|
|
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`)
|
|
|
|
- **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*`.
|
|
- **llama.cpp changes are commits on a fork, not configure-time patches.** The submodule points at
|
|
robertkarl/llama.cpp, branch `UnbiasedStrata`: ggml-org `3cf03257` plus the two commits under "Changes to llama.cpp"
|
|
below. Until 2026-10-19 the same changes were `patches/*.patch`, applied to the submodule's working tree by CMake at
|
|
configure (UnbiasedStrata 1 did it in `make` and in CMake both), which left the submodule dirty after every build and
|
|
meant the pinned commit alone did not name the sources compiled. The pin now does; `git status` is clean after a build.
|
|
- **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
|
|
(the step-9 record's README; records are in history at 7551f138, `bench/unbiased/`).
|
|
- **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
|
|
2026-10-18 on the A6000 (record in history at 7551f138).
|
|
- **`--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.
|
|
|
|
## Changes to llama.cpp (robertkarl/llama.cpp, branch `UnbiasedStrata`)
|
|
|
|
Six commits on top of ggml-org `3cf03257`; `git -C third_party/llama.cpp diff 3cf03257 HEAD` is exactly these.
|
|
|
|
- `9547d8d` (`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 from UnbiasedStrata 1 unchanged.
|
|
- `a6de9af` (`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.
|
|
|
|
- `1421694` (`tools/server/server-task.cpp`): a partial re-parse that reports fewer tool calls than the previous
|
|
one no longer throws (the request died with a 500 mid-stream, "Invalid diff: now finding less tool calls!"); the
|
|
previous message is kept, nothing is emitted for that token, and the raw generated text is logged. A non-partial
|
|
parse failure returns the raw text as content instead of failing the request (issue #17, 2026-10-20).
|
|
- `638a7e2` (`common/parsers/qwen3-coder.cpp`, `tests/test-chat.cpp`): the Qwen3-Coder grammar skips a stuttered
|
|
`</parameter>` close tag. Qwen3.8 Flash-Next Coder IQ1_M, sampled without the grammar, wrote the tag twice before
|
|
`</function>` in 7 of 673 requests of a BBW run (2026-10-20); each one failed the whole call and, through the diff
|
|
check above, the request. The value still ends at the first close. Test in the Qwen3-Coder section of test-chat.
|
|
- `4174b21` (`common/parsers/qwen3-coder.cpp`, `tools/server/server-task.cpp`, `tests/test-chat.cpp`): the same
|
|
shard also leaves a blank line between the last `</parameter>` and `</function>` (memcached-bisect-deep,
|
|
2026-10-21); the grammar now skips blank lines between arguments and before `</function>` and `</tool_call>`.
|
|
And the final, non-partial parse gets the same guard as the partial one: when it finds fewer tool calls than were
|
|
streamed, the streamed calls stand (arguments as last parsed) and the raw text is logged, instead of the diff
|
|
check throwing and the request ending in a 500 after the hold-delta guard had kept it alive. Two blank-line cases
|
|
in test-chat.
|
|
- `385445f` (`common/parsers/qwen3-coder.cpp`, `tests/test-chat.cpp`): the third shape (prime-frontend, 2026-10-21):
|
|
`</content>` and `</invoke>` after the real `</parameter>`, a blank line, `</parameter>` again. The stuttered-close
|
|
rule becomes general: any close tag that is not `</function>` or `</tool_call>` is skipped between arguments.
|
|
## 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 (harness `bench/correctness/`; record in history at 7551f138, `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.
|
|
|
|
## DeepSeek-V4.1 engine (`src/dsv41`, from Strata v0.2.4)
|
|
|
|
Added 2026-10-24 to run DeepSeek-V4.1-Flash-1017 (ISTA-DASLab's GSQ-RCO GGUF sets) on the A6000 VM. Neither engine of
|
|
this fork reads a `deepseek41` GGUF (`strata-poly` knows `deepseek4`, V4 Flash), and the pinned llama.cpp predates the
|
|
architecture, so the engine is upstream Strata's third one, `strata-dsv41` - itself a port of Project Maya's `maya-ds4`
|
|
(MIT; `third_party/project-maya/NOTICE.md`, the vendored EXL3 / sampler / window kernels under `src/dsv41/vendor/`).
|
|
|
|
- **Taken unmodified from Niko1221/Strata `v0.2.4` (96ca4383):** `src/dsv41/`, `include/strata/dsv41/`, `tests/dsv41/`,
|
|
`tools/dsv41/{pack_gguf,smoke,tune}.py`, `data/dsv41/` (the shipped hot-expert profiles), `tools/trellis/tqenc.{cpp,hpp}`
|
|
(the tests' encoder), `third_party/project-maya/`, `third_party/ggml/ggml-common-tq.h`, and upstream's `docs/DEEPSEEK41.md`
|
|
(rewritten for this fork afterwards). `diff -r` against the tag's tree is the check.
|
|
- **`src/kernels/cpu` and `include/strata/kernels/cpu`:** upstream's `iq_avx2.{cpp,hpp}`, `iq_avx2_rows.inl`,
|
|
`iq_avx512.{cpp,hpp}` replace this fork's v0.1.45-poly.1 copies - they add the engine's CPU lane rows `iq256x_rows` /
|
|
`iq512x_rows` (ggml's float order, so a token's dot is ggml-cpu's bit for bit) and, upstream states, leave `iq256_*` /
|
|
`iq512_*` as they were (`iq_avx2_parity` is the check here) - and the trellis CPU lane `tq_cpu.{hpp,cpp}`,
|
|
`tq_avx2.cpp`, `tq_avx512.cpp`, `tq_states.hpp`, `tq_computed.hpp` is new in `strata_kernels_cpu`. `expert_layout.hpp`
|
|
stays at layout version 4: upstream's 5 only adds Hadamard-folded packs, which nothing here makes or reads.
|
|
`iq_avx512.cpp` is built with `-mavx512vpopcntdq -mbmi2` as upstream does (`iq512x_rows` uses them).
|
|
- **`CMakeLists.txt`:** upstream's `strata-dsv41` block as it is, but ggml.h / ggml-cpu.h come through
|
|
`strata_kernels_cpu`'s `ggml-cpu` link from the submodule (no FetchContent, rule 1), and the option is turned on by the
|
|
`Makefile` (`STRATA_BUILD_DSV41=ON`; `strata-dsv41` is in `TARGETS`). The engine is compiled with
|
|
`STRATA_DSV41_TQ_CPU=1`, the ggml-cpu lane the IST-DAS sets' experts beyond VRAM run on.
|
|
- **Not taken:** upstream's `setup.py` / `strata launch` plumbing (rules 1 and 2), the signed engine-package feed, the
|
|
Python server's `serve/dsml.py` (this fork's front end parses DSML with llama.cpp's `common/parsers/deepseek.cpp`,
|
|
below) and the fixture template `serve/fixtures/deepseek41/chat_template.jinja` (the GGUF's own template is used).
|
|
- **Serving:** the front end starts it like the other two, `--engine strata-dsv41 -m <shard 1> ... -- --pack <pack>
|
|
--max-context N --dspark auto`; `--serve` is added. Its line protocol is the one `frontend/engine.hpp` speaks
|
|
(`READY`, `INFO`, `T`, `DONE`, `ERR`); its extra `STAT` and `NOTE` lines are ignored as `OTHER`. The front end's
|
|
vocabulary load falls back to the `general.architecture` override (USTRAT-6's path) because the pinned llama.cpp
|
|
does not know `deepseek41`.
|
|
|
|
## 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 the "Measured" section of `README.md` (records in history at 7551f138).
|
|
- **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`). Upstream's copies run against upstream.
|
|
- **Per-machine results and logs (decided 2026-10-19):** upstream's `bench/results/` (23 MB, one directory per
|
|
community machine) and the fork's own `bench/unbiased/` run directories (57 MB). A result from one machine is a
|
|
record, not source; the numbers that matter are in `README.md` "Measured", and the directories are in history at
|
|
7551f138. `bench/` keeps what is reusable: `bench_vs_llama.py` with `profile_corpus.json`, the kernel probes, and
|
|
`bench/correctness/` (the step-12 harness, moved from `bench/unbiased/correctness/scripts/`).
|