# Strata upstream provenance
**Status:** `engine/strata/` was brought to upstream `41cf05a0` (engine 0.1.50, app 0.2.5) on 2026-10-25 on branch
`claude/upstream-sync`, with the local patches re-applied. The previous pin (`d9ab8435`, engine 0.1.35) is kept below and in Git
history (`570201a:engine/strata`). Nothing was pushed. The quality-gate reference build (`stra169-ladder` Original) stays a build of the
OLD pin plus the old local patches; the new subtree is not that reference (see "What this does to the quality reference").
## Current pin
| Field | Value |
| --- | --- |
| Upstream repository URL | https://github.com/Niko1221/Strata.git |
| Upstream commit SHA | `41cf05a06a25dd29103b7b27a2279a3f60c21876` |
| Upstream commit date | 2026-10-25 11:35 +0100 ("README (all 7 languages): models in the order Qwen3.8-Flash-Next, Qwen3.6-35B-A3B, DeepSeek V4.1-Flash") |
| Upstream version at the pin | engine and Control 0.1.50, Terminal and app 0.2.5 (`1aff6d14`, 2026-10-24) |
| Upstream tree object of the pin | not recorded (the subtree is the pin plus local patches and omissions; the exact differences are listed below) |
| Local repository path | `engine/strata/` |
| Update date | 2026-10-25 |
| Update method | documented tree replacement: 3-way `git merge-tree` of the old subtree against the new upstream, base = the old pin (see "How this update was made") |
| Hosted project repository URL | https://github.com/paveldhq/strata-next (private) |
| Engine build instructions | `scripts/build-cpu.sh` for source checks (needs network once: it fetches llama.cpp `3cf03257f` through CMake FetchContent); CUDA builds: see `deploy/README.md` and `docs/build-validation.md`. Upstream's `packaging/build_cuda_linux.sh` and `packaging/build_dsv41_cuda.sh` are the reference recipes and have not been run here |
## Pin history
| Pin | Upstream commit | Date | Engine | In this repository |
| --- | --- | --- | --- | --- |
| 1 (initial import) | `d9ab8435f654c368c586340d490915f6addf56a3` | 2026-10-02 | 0.1.35 | `engine/strata/` up to `570201a` (git subtree merge `c4e2137` of squash `906afc5de9dd` in the pre-squash history; later squashed into `4013e0c`) |
| 2 (this update) | `41cf05a06a25dd29103b7b27a2279a3f60c21876` | 2026-10-25 | 0.1.50 | `engine/strata/` on `claude/upstream-sync` |
**Upstream rewrote its history.** `d9ab8435` is not an ancestor of upstream `origin/main` (`git merge-base --is-ancestor` fails). Its
tree is identical (`git diff` is empty, tree `487c4cc0`) to upstream commit `5b734e42` ("Engine 0.1.35", same date), which is an
ancestor of `41cf05a0`. So the real distance from the old pin to the new one is 3630 commits (`git rev-list 5b734e42..origin/main`), not
the 4175 that `git rev-list d9ab8435..origin/main` prints. Both SHAs identify the same source tree; record both when comparing.
The local Git remote `strata-upstream` points to the URL above. Do not silently advance to whatever happens to be latest: choose a
specific commit, fetch it, review the diff from the pin, and update this file in the same commit.
## How this update was made (repeat it the same way)
The pre-squash `git subtree` metadata does not exist in this repository's history (the project history was rebuilt from snapshots),
so `git subtree pull` has nothing to anchor on. The update therefore used a tree replacement that still keeps a true 3-way merge:
1. In a scratch clone of upstream: `base` = tree of the old pin, `ours` = `git rev-parse 570201a:engine/strata` (the old subtree with
the local patches), `theirs` = upstream `41cf05a0`.
2. `git merge-tree --write-tree --merge-base= `; conflicts were resolved by hand (below); the result was checked by
listing every blob that differs from upstream `41cf05a0` (only the 21 patched files, the 4 added files and the left-out files differ).
3. The result tree went into `engine/strata/` with `git read-tree --prefix=engine/strata/ -u` (`core.autocrlf=false`, LF kept), then the
left-out files were removed from the index and the working tree.
4. `docs/upstream/local-patches-on-0.1.35.patch` is the patch that was re-applied (old pin to old subtree, 25 files);
`docs/upstream/local-patches-on-0.1.50.patch` is the same patches as they stand on the new pin (new pin to new subtree, 25 files).
The next update should treat the second file as its `ours` side: the merge base is then `41cf05a0`.
## Local patches (as re-applied, 2026-10-25)
All of them are default-off or build-profile only. None changes the default behaviour of the engine.
| Local patch | Files | Status after the update |
| --- | --- | --- |
| `STRATA_CUDA_STATIC` CMake profile (static CUDA toolkit libraries and GNU C++ runtime, Linux; STRA-23, `a36e45a`) | `CMakeLists.txt` | Re-applied. Added `OR STRATA_HIP_GFX906` to its refusal condition (upstream added a gfx906 compat build that also sets `STRATA_ENABLE_CUDA`). Upstream's own tests that link `CUDA::cudart` directly are not switched to the static target (as before) |
| `STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS`: native verifier cache-miss callback to the external `gpu/kar` component (`87fdec7`, `53c9d7b`, `33f075f`, `b6563e3`) | `CMakeLists.txt`, `include/strata/core/expert_source.hpp`, `src/core/expert_source.cpp`, `src/program/generate.cpp` | Re-applied. The callback now runs before the CPU-work scan so `any_cpu` sees what is left; a completed row (`kind == 3`) is excluded from the new zeroing, offload-count and peer-count rules. Compiles (sm_86 objects, with `STRATA_NEXT_KAR_DIR=gpu/kar` of this repository); never run, and not exercised against upstream's new device-plan and route-tail-skip paths |
| Experimental KAR PLE CPU quality arm and compressed GPU row cache, PLE row trace (`80f6670`, `e4d0c2d`, `36e512a`, `78e92d5` telemetry) | `include/strata/kernels/ngram.hpp`, `src/kernels/ngram.cpp`, `src/prefill/prefill.cpp`, `src/program/generate.cpp`, `CMakeLists.txt` | Re-applied on top of upstream's table-driven PLE formats (`fmt->dequant`, recursive mutex, `wait_prefetches`). The GPU-cache arm lands its rows through upstream's new `ple_land` path. Compiles with `STRATA_NEXT_EXPERIMENTAL_KAR_PLE=ON` and `STRATA_NEXT_EXPERIMENTAL_PLE_TRACE=ON` (sm_86 objects); never run |
| Keyless V-only QSA arm (`a8411b5`; failed its quality gate, see `docs/experiments/2026-10-04-keyless-runtime.md`, `docs/keyless-runtime.md`) | `include/strata/core/keyless.hpp`, `src/core/keyless.cpp`, `src/kernels/cuda/keyless.cu`, `src/kernels/keyless_parity.cpp` (new files), plus `layer.cpp/.hpp`, `verify.cpp/.hpp`, `prefill.cpp`, `src/prefill/kernels.cu`, `kv_q8.cu`, `kv_stream.cu/.hpp`, `qsa_decode_attn.cu/.hpp`, `kv_stream_parity.cpp`, `conversation_snapshot.cpp/_test.cpp`, `mtp.cpp`, `generate.cpp` | Re-applied by hand (see conflicts). Needs `STRATA_KEYLESS_ROUTING` and `--kv int8`; refuses K8V4 and the new fused norm+rope; no slots / rows attention variant (falls back to per-query calls) |
| Mode bits | `setup.sh` | The 0644 mode our 2026-10-14 snapshot (`7f896a8`) set on `setup.sh` and `docker-entrypoint.sh` is not carried: `setup.sh` is 0755 as upstream; upstream deleted `docker-entrypoint.sh` (it is `docker/entrypoint.sh` now) |
Other commits that touched `engine/strata` in the pre-squash history (`b1da05f` first-window logits capture, `78e92d5` telemetry) are
either not part of the tracked snapshot at `570201a` or are the telemetry line listed above; `git grep` for the capture finds nothing in
`570201a:engine/strata`, so nothing was lost by this update.
### Conflicts and how they were resolved
Content conflicts (15 files, 44 hunks) and one modify/delete. Everything else in the 25 patched files merged cleanly.
| File | Conflict | Resolution |
| --- | --- | --- |
| `CMakeLists.txt` (4) | STATIC option next to upstream's new gfx906 block; PLE/KAR targets next to upstream's new gfx1100 score test; `strata_engine` source list (upstream added `remote_expert_opt.cu`, `dflash2`, `peer_experts`, `vmm`, ...); `strata` link options next to upstream's Windows HIP delay-load and the whole `strata-dsv41` block | Union. `keyless.cpp` added to upstream's longer `strata_engine` source list. `STRATA_CUDA_STATIC` refuses `STRATA_HIP_GFX906` |
| `kv_stream.hpp` | Our `kKvValueInt8 = 4` against upstream's new `kKvHybrid = 3` (K8V4 streaming) and its two helper functions | Both: `kKvF16=0, kKvInt8=1, kKvQ4=2, kKvHybrid=3, kKvValueInt8=4` |
| `layer.hpp` | `qsa_kv_format()`: our hard refusal of hybrid state vs upstream's `kKvHybrid` | Upstream's hybrid line first, then ours for `without_key`. The old "hybrid never reaches the block movers" exit is gone because it is now false |
| `kv_stream.cu` (2) | `runs_of()` and `kv_block_bytes()` | Chain `kKvHybrid`, `kKvValueInt8`, `kKvQ4`, `kKvInt8` |
| `kv_q8.cu` | `is_v` computation vs upstream's `MULTI` template parameter | `k_q == nullptr \|\| (MULTI ? (z & 1) : z == 1)`. With keyless + `kv_append_q8_steps` the grid is 2 x tokens and both halves write the same V (redundant, correct) |
| `qsa_decode_attn.cu` (4) | Upstream split the dispatch into `launch_chunks_batch`, `launch_merge_batch`, `qsa_decode_attn_slots`, `qsa_decode_attn_batch_rows`, added lane-cell/gfx906/`attn_v3`/daily variants | Took upstream's structure; `attn_kv_mode()` knows mode 4; mode 4 is dispatched in `launch_chunks_batch` and `qsa_decode_attn_step`; lane-cell is disabled for it; the slots variant returns false and the rows variant goes per row so they fall back to the per-query calls |
| `verify.hpp` / `verify.cpp` (7 hunks) | Our keyless trace members and query routing against upstream's new fused norm+rope, `side_proj`/`q_chain`, `mm()` helper, `collect_profile()`, `launch_o->finish()` | Query routing moved into `norm_rope_on` (between norm and RoPE, all callers go through it); `fuse_nr` is off for keyless; K projection and K norm skipped for keyless; trace members renamed `kl_trace_*` because upstream already owns `trace_h_` (found only by compiling: a clean textual merge produced a duplicate member); the trace writer was re-added after the window's synchronize |
| `layer.cpp` (3) | `qsa_layer` is one giant line; upstream dropped `n_bid`/`width` and re-wrapped the gemv lines | Upstream's text with our `without_key` guards re-inserted |
| `expert_source.cpp` (2) | KAR miss callback vs upstream's `dec_batch`/`gpu_zeroes_hits`/`any_cpu`/`kind == -2` tail skip | Callback first, then upstream's block; kind 3 handled as above |
| `ngram.cpp` (5) | KAR PLE vs `PleFormat` table, `std::recursive_mutex`, `wait_prefetches()` | Upstream's format table; KAR decode and cleanup kept under their macro; `close()` waits for prefetches first; `format()` falls back to `fmt->name` |
| `prefill.cpp` (3) | PLE gpu-cache branch vs upstream's `ple_land`, `C`, pageable PLE ring | GPU-cache branch gathers on the device; else upstream's code |
| `generate.cpp` (9) | Includes, options struct, keyless trace check vs upstream's host-core / pool-cores / aux-cpus / memory-guard blocks, KAR PLE open vs the new direct-read probe, `Drive` setup, request keys, serve-loop epilogue | Union; the PLE direct-read probe is skipped for the KAR PLE arm |
| `kv_stream_parity.cpp` (2) | `append()` and the format name | Both formats |
| `expert_source.hpp`, `verify.hpp`, `kv_stream.hpp` | adjacent member / enum additions | Union |
| `docker-entrypoint.sh` | modified (mode only) by us, deleted by upstream | Deleted (upstream moved it to `docker/entrypoint.sh`) |
### What this does to the quality reference
`engine/strata/` on this branch is a different engine from the one the `stra169-ladder` Original was built from: with default flags it
behaves differently from the old pin (upstream flipped defaults on: route tail skip, PcieAuto, sm_120 and sm_86 kernel sets, fused int8
prompt experts, auto conversation cache; see `docs/upstream-digest-2026-10-25.md`). Do not use a build of this subtree for the greedy/tensor
baselines of `docs/quality-gate.md`. The old pin remains reproducible from `git show 570201a:engine/strata` and from the upstream tree
`487c4cc0` (upstream commit `5b734e42` / `d9ab8435`). Anything compared against the new subtree must set the old behaviour explicitly
(the digest lists the switches).
## Left out of the subtree (rule: weights, captures, credentials, logs, media and generated artifacts stay out of Git)
Upstream content at `41cf05a0` that was not committed (2140 files in total; everything else in the upstream tree is committed byte for byte).
The root `.gitignore` already drops `*.bin`, `*.gguf`, `*.log` and `models/`; the rest was left out by the rules below.
| Group | Files | Why | Where it is |
| --- | --- | --- | --- |
| New `bench/results/**` (community benchmark runs: request captures `requests/*.json.gz`, `*-request.json` prompts, engine logs `*.log`, monitor screenshots, build recipes, fixtures) | 2022 added | request captures and logs; 23 MB; the 162 older files of that directory that the first import carried are unchanged | upstream `bench/results/` |
| Binary media and assets added by upstream | 61 | `apps/desktop/src-tauri/icons/**` and `nsis/*.bmp` (app icons), `apps/host/public/**` (favicons, three GT Walsheim Pro `*.woff2` commercial fonts, an example gif/mp4/pdf), `docs/terminal-previews/*.png` (7), `docs/media/*.png` (2), `docs/media/models/*` | upstream |
| `docs/work/evidence/**` | 24 | test-run transcripts and JSON self-test output (logs) | upstream |
| Model-adjacent binaries that the root `.gitignore` also matches | `data/dsv41/profile-2.00.bin`, `profile-2.25.bin` (hot-expert profiles for the DeepSeek packs), `data/draft_vocab_fr.bin`, `data/expert-profile-sycl.bin`, `tests/fixtures/dsv41/engram-final-header.gguf` | binary data files; needed only to run the DeepSeek engine or its SYCL path | upstream |
| Already left out by the first import and still left out | `data/draft_vocab.bin`, `data/draft_vocab_cyrillic.bin`, `data/draft_vocab_en.bin`, `data/expert-profile.bin`, `data/expert-profile-coder.bin`, `data/experimental-speed-projection/*.gguf`, `bench/results/2026-09-30-community-rtx-5090/engine.log` | same rule | upstream |
Kept on purpose although they look large: `apps/host` and `apps/desktop` source (TypeScript / Rust text; 8 MB), `tools/qwen35/pictures/*.png`
(three small test inputs), `docs/work/*.md`, `bench/prompts/**` (frozen benchmark prompts, hashed byte for byte), `sycl/`, `metal/`,
`packaging/` (installer scripts, text), `third_party/` (ggml-tq headers, Project Maya license and notice). A scan of every kept blob found
no private key, token or credential pattern. The kept scripts and installers are source only; none of them was run.
Consequences to know: `data/dsv41/profile-*.bin` must be fetched from upstream if the DeepSeek engine is ever built from this tree;
`apps/host`, `apps/desktop` and the packaging flow will not build from this tree without the left-out icons and fonts. Neither is used by
Leleka. Also, upstream's own `AGENTS.md` and `docs/AI_SETUP.md` tell an agent to run installers and `strata launch --yes`; they are
upstream's instructions for its product and do not apply to work in this repository.
## Verification of this update
| Check | Result |
| --- | --- |
| Tree identity: every blob of `engine/strata/` compared with upstream `41cf05a0` | identical except the 21 patched files + 4 new files (and the left-out files) |
| `git diff --stat` for line-ending churn | none (LF kept, `core.autocrlf=false`; the nested `.gitattributes` of the subtree sets `eol=crlf` for `*.bat/*.cmd/*.ps1` as upstream does) |
| `scripts/build-cpu.sh` in WSL Ubuntu 24.04, GCC 13.3, CMake 3.31.6 | 16 of 16 ctest tests pass (the script's target list had to be extended: upstream registers 11 more CPU tests than the old pin; `Not Run` otherwise) |
| CUDA compile (sm_86 only, `nvcc` 13.2, no GPU use) of the patched translation units: `kv_q8.cu`, `kv_stream.cu`, `qsa_decode_attn.cu`, `keyless.cu`, `prefill/kernels.cu`, `prefill.cpp`, `layer.cpp`, `verify.cpp`, `expert_source.cpp`, `mtp.cpp`, `conversation_snapshot.cpp`, `keyless.cpp`, `ngram.cpp`, `generate.cpp`, `kv_stream_parity.cpp`, `keyless_parity.cpp` | all 17 objects compile (warnings only) in the default configuration; the 7 objects that depend on the KAR/PLE macros (`ngram.cpp`, `expert_source.cpp`, `prefill.cpp`, `generate.cpp`, `kar_ple_cache.cu`, `kar_expert.cu`, `kar_expert_miss.cpp`) also compile with `STRATA_NEXT_EXPERIMENTAL_KAR_PLE=ON`, `STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS=ON`, `STRATA_NEXT_EXPERIMENTAL_PLE_TRACE=ON`. The compile found one error a textual merge cannot (a duplicate `trace_h_` member in `verify.hpp`), fixed by renaming ours to `kl_trace_*`. Not built: link, the `strata` binary, the parity tests, the sm_120 PTX |
| GPU parity, quality gate, any model run | not run (by instruction); the keyless, KAR and PLE arms are default off and unexercised |
| Port crates that `include_str!` files from `engine/strata` | none of those files changed upstream (`LICENSE`, `serve/chat_template.jinja`, `serve/chat_golden.json`, `tests/data/native_experts/*.txt`, `serve/mcp_fake_server.py`, `tools/mtp_rt.py`) |
## Local CUDA validation, 2026-10-04
The upstream identity above is unchanged. The local Keyless opt-in fork compiled
on Linux with CUDA 13.2.86 for RTX 5090 (SM 120). Query-routing numerical parity,
V-only streaming and conversation snapshots passed. Pretrained-model quality
failed; see [the report](experiments/2026-10-04-keyless-runtime.md). The ordinary
K+V profile remains the production choice.
(That validation was on the 0.1.35 sources; it has not been repeated on the merged tree.)
## Local Linux packaging profile, 2026-10-04
STRA-23 adds the default-off `STRATA_CUDA_STATIC` CMake profile: static toolkit
runtime/BLAS targets and GNU C++ runtime linkage for Linux. The imported source
commit above remains unchanged; this is a local build-policy patch. A complete
CUDA 13.2/SM 120 compilation and ELF audit passed without GPU inference. The
candidate still needs host glibc 2.43 and an NVIDIA driver; model qualification
is pending. See `deploy/README.md` and `docs/build-validation.md` for the exact
scope, artifact identity and remaining packaging limits.
(Re-applied on the 0.1.50 `CMakeLists.txt`; the ELF audit has not been repeated.)
## Experimental KAR expert integration, 2026-10-05
The pinned upstream commit remains unchanged. Local default-off
`STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS` adds a native verifier cache-miss callback,
linked to the separate `gpu/kar` component. Resident native hits and batched prefill
retain their IQ weights; short prompt ingestion uses the verifier and therefore
also exercises KAR misses. The runtime requires explicit archive and precision
environment settings, validates the archive payload and expert geometry, and
rejects unsupported pool/multi-device configurations. This is an experimental
quality arm, not full compressed-model residency or a qualified speedup.
(Written against the 0.1.35 sources; re-applied on 0.1.50, see the table above.)
## Port provenance, 2026-10-25
The Leleka runtime under `crates/`, `desktop-core/` and `control-plane/` is a Rust/CUDA port of the Original mode17 serve path written
for this project; it shares the model artifacts and the algorithms (not the C++ code) with Strata. The Original used as the quality
reference and for the vanilla baselines is a separate build of the OLD pin (`d9ab8435` / `5b734e42`, engine 0.1.35) plus the local
patches that were in `engine/strata/` before this update; `engine/strata/` itself is no longer that source. The agreement of the port
with the Original is measured in `docs/quality-gate.md`; the request-end prefix checkpoints (`docs/prefix-cache.md`) and the chain
kernels (`docs/chain-kernels.md`) are port-side additions with their own gates.
A digest of what changed upstream and what is worth taking is in [upstream-digest-2026-10-25.md](upstream-digest-2026-10-25.md).