CI workflows (oracle numpy pin per interpreter, copy-source test harness), ignore rules, root files without docs/ links; AGENTS.md is a local pointer to the MCP (STRA-382)

This commit is contained in:
Pavlo Ratushnyi
2026-11-23 09:34:33 +01:00
parent 3f22c4ae29
commit 7c000ce93f
16 changed files with 5504 additions and 304 deletions
-1
View File
@@ -13,7 +13,6 @@ engine/strata/*
engine/strata/serve/* engine/strata/serve/*
!engine/strata/serve/chat_template.jinja !engine/strata/serve/chat_template.jinja
benchmarks/ benchmarks/
docs/
target/ target/
dist/ dist/
**/target/ **/target/
+3 -3
View File
@@ -8,9 +8,9 @@ scripts/gpu-bringup/**/*.py text=auto eol=lf
scripts/e2e/codex/tasks/** -text scripts/e2e/codex/tasks/** -text
scripts/e2e/codex/delta/** text eol=lf scripts/e2e/codex/delta/** text eol=lf
# Release reproducibility (docs/release/5090-v0.1-checklist.md): the sealed PTX files are pinned by SHA-256 in the sources, so the bytes in the # Release reproducibility: the sealed PTX files are pinned by SHA-256 in the sources, so the bytes in the
# working tree must be the bytes in the index on every platform. Without this line a Windows checkout with core.autocrlf=true turns 212 of the # working tree must be the bytes in the index on every platform. Without this line a Windows checkout with core.autocrlf=true turns 212 of the
# 273 .ptx files into CRLF (the other 61 end in a NUL byte, which git treats as binary) so the embedded PTX is not the sealed one (a CRLF checkout built a binary 9 MB smaller than every earlier one, docs/experiments/baseline-pair-5090.md part d). # 273 .ptx files into CRLF (the other 61 end in a NUL byte, which git treats as binary) so the embedded PTX is not the sealed one (a CRLF checkout built a binary 9 MB smaller than every earlier one).
*.ptx -text *.ptx -text
# The release packager and the files it copies into the tarball are POSIX shell and systemd text: LF everywhere. # The release packager and the files it copies into the tarball are POSIX shell and systemd text: LF everywhere.
scripts/release/** text eol=lf scripts/release/** text eol=lf
@@ -19,7 +19,7 @@ deploy/rust-runtime/** text eol=lf
# The embedded expert profile is pinned by SHA-256 in the sources: the bytes in the working tree must be the bytes in the index on every platform. # The embedded expert profile is pinned by SHA-256 in the sources: the bytes in the working tree must be the bytes in the index on every platform.
crates/deploy/data/expert-profile.bin -text binary crates/deploy/data/expert-profile.bin -text binary
# CI entry points run on Linux runners: LF whatever the checkout host's autocrlf says (docs/ci-audit.md). # CI entry points run on Linux runners: LF whatever the checkout host's autocrlf says.
scripts/ci/** text eol=lf scripts/ci/** text eol=lf
scripts/check-local.sh text eol=lf scripts/check-local.sh text eol=lf
scripts/check-clippy-limits.sh text eol=lf scripts/check-clippy-limits.sh text eol=lf
+1 -1
View File
@@ -29,7 +29,7 @@ jobs:
- name: Tests - name: Tests
run: cargo test --locked --manifest-path desktop-core/Cargo.toml run: cargo test --locked --manifest-path desktop-core/Cargo.toml
- name: Lints - name: Lints
# --no-deps: the path dependencies (leleka-model-format, leleka-cuda-driver, leleka-runtime) carry reported Clippy debt of their own (docs/ci-audit.md) # --no-deps: the path dependencies (leleka-model-format, leleka-cuda-driver, leleka-runtime) carry reported Clippy debt of their own
run: cargo clippy --locked --manifest-path desktop-core/Cargo.toml --all-targets --no-deps -- -D warnings run: cargo clippy --locked --manifest-path desktop-core/Cargo.toml --all-targets --no-deps -- -D warnings
- name: Hardware smoke (no inference) - name: Hardware smoke (no inference)
# desktop-core ships six binaries and no default-run: name the one this smoke test runs # desktop-core ships six binaries and no default-run: name the one this smoke test runs
+22 -3
View File
@@ -1,6 +1,6 @@
name: Rust port name: Rust port
# Checks for the Rust port of the Original engine (docs/port-status.md). Everything here runs without a GPU, model # Checks for the Rust port of the Original engine. Everything here runs without a GPU, model
# weights or tokens. The existing "Linux" workflow is unchanged; the jobs below add the port-specific gates: # weights or tokens. The existing "Linux" workflow is unchanged; the jobs below add the port-specific gates:
# port-fast fmt, Clippy and tests on the host-buildable crates (scripts/check-local.sh --fast) # port-fast fmt, Clippy and tests on the host-buildable crates (scripts/check-local.sh --fast)
# port-typecheck Linux-only crates (cuda-driver with the cuda-driver feature, leleka-runtime) type-checked, not run # port-typecheck Linux-only crates (cuda-driver with the cuda-driver feature, leleka-runtime) type-checked, not run
@@ -54,7 +54,7 @@ jobs:
cargo clippy --locked --target x86_64-unknown-linux-gnu --no-deps -p leleka-cuda-model -p leleka-cuda-driver --features cuda-driver -p leleka-engine-qwen35-cuda -p leleka-runtime --all-targets -- -D warnings cargo clippy --locked --target x86_64-unknown-linux-gnu --no-deps -p leleka-cuda-model -p leleka-cuda-driver --features cuda-driver -p leleka-engine-qwen35-cuda -p leleka-runtime --all-targets -- -D warnings
port-oracles: port-oracles:
# CPU oracle differentials: the Rust side against the UNMODIFIED Python tools (docs/offline-port.md) and the # CPU oracle differentials: the Rust side against the UNMODIFIED Python tools and the
# sampler host shim. Optional until it has run green on the hosted runner; the committed goldens are replayed by # sampler host shim. Optional until it has run green on the hosted runner; the committed goldens are replayed by
# port-fast regardless. # port-fast regardless.
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -66,9 +66,22 @@ jobs:
- name: Install pinned Rust - name: Install pinned Rust
run: scripts/install-pinned-rustup.sh rustup toolchain install 1.99.0 --profile minimal --component rustfmt --component clippy run: scripts/install-pinned-rustup.sh rustup toolchain install 1.99.0 --profile minimal --component rustfmt --component clippy
- name: Oracle Python environment (no model data) - name: Oracle Python environment (no model data)
# numpy 2.5.x needs Python >= 3.12 and the runner's distro Python is older, so the numpy pin follows the
# interpreter exactly as engine/strata/requirements.txt does (2.5.4 on 3.12+, 2.4.6 on 3.11, 2.2.6 below).
# The oracle differentials compare against recorded goldens with tolerances, not against a numpy build.
run: | run: |
python3 -m venv "$RUNNER_TEMP/oracle-venv" python3 -m venv "$RUNNER_TEMP/oracle-venv"
"$RUNNER_TEMP/oracle-venv/bin/pip" install --disable-pip-version-check numpy==2.5.4 PyYAML==6.0.3 tqdm==4.70.1 Jinja2==3.1.6 regex==2026.9.10 cat > "$RUNNER_TEMP/oracle-requirements.txt" <<'EOF'
numpy==2.5.4; python_version >= "3.12"
numpy==2.4.6; python_version == "3.11"
numpy==2.2.6; python_version < "3.11"
PyYAML==6.0.3
tqdm==4.70.1
Jinja2==3.1.6
regex==2026.9.10
EOF
"$RUNNER_TEMP/oracle-venv/bin/python" --version
"$RUNNER_TEMP/oracle-venv/bin/pip" install --disable-pip-version-check -r "$RUNNER_TEMP/oracle-requirements.txt"
- name: Fetch the pinned llama.cpp gguf-py - name: Fetch the pinned llama.cpp gguf-py
run: | run: |
commit="$(sed -n 's/^LLAMA_CPP_COMMIT = "\(.*\)"$/\1/p' engine/strata/setup.py)" commit="$(sed -n 's/^LLAMA_CPP_COMMIT = "\(.*\)"$/\1/p' engine/strata/setup.py)"
@@ -104,7 +117,13 @@ jobs:
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io
- name: Linux test harness - name: Linux test harness
if: steps.present.outputs.present == 'true' if: steps.present.outputs.present == 'true'
# The job runs in a container and uses the host's Docker daemon: the checkout path does not exist on that host,
# so the harness copies the source into the test container instead of bind-mounting it.
env:
LELEKA_TEST_COPY_SOURCE: '1'
run: scripts/linux-tests/run.sh run: scripts/linux-tests/run.sh
- name: Fake-libcuda mock gates (CPU-only ELF protocol tests of the driver) - name: Fake-libcuda mock gates (CPU-only ELF protocol tests of the driver)
if: steps.present.outputs.present == 'true' if: steps.present.outputs.present == 'true'
env:
LELEKA_TEST_COPY_SOURCE: '1'
run: scripts/linux-tests/run.sh --mocks run: scripts/linux-tests/run.sh --mocks
+3 -3
View File
@@ -1,6 +1,6 @@
name: Product name: Product
# Builds and tests what actually ships (docs/ci-audit.md). The other workflows cover the legacy Strata-Next static CLI (linux.yml), # Builds and tests what actually ships. The other workflows cover the legacy Strata-Next static CLI (linux.yml),
# the host-buildable port crates (port.yml) and desktop-core (desktop.yml); none of them built the `leleka` deploy binary, ran the # the host-buildable port crates (port.yml) and desktop-core (desktop.yml); none of them built the `leleka` deploy binary, ran the
# tests of leleka-deploy, leleka-memory, leleka-runtime-client, leleka-runtime or leleka-cuda-driver, or compiled the six release # tests of leleka-deploy, leleka-memory, leleka-runtime-client, leleka-runtime or leleka-cuda-driver, or compiled the six release
# binaries. This job runs `scripts/check-local.sh --product`, the same command a developer runs locally: # binaries. This job runs `scripts/check-local.sh --product`, the same command a developer runs locally:
@@ -8,12 +8,12 @@ name: Product
# - scripts/check-architecture.py: dependency direction between layers, adapter edges, no new .rs over 400 lines, source ratchets # - scripts/check-architecture.py: dependency direction between layers, adapter edges, no new .rs over 400 lines, source ratchets
# (architecture.json is the policy, architecture-baseline.json the debt that may only fall; self-tests in check_architecture_test.py) # (architecture.json is the policy, architecture-baseline.json the debt that may only fall; self-tests in check_architecture_test.py)
# - cargo build --locked (every default-member) and the release build of leleka, leleka-api, leleka-inference, leleka-daemon, # - cargo build --locked (every default-member) and the release build of leleka, leleka-api, leleka-inference, leleka-daemon,
# leleka-cli, leleka-seal-exec (docs/deploy.md section 8) # leleka-cli, leleka-seal-exec
# - cargo check of the CUDA-feature crates (leleka-cuda-driver --features cuda-driver, leleka-runtime) # - cargo check of the CUDA-feature crates (leleka-cuda-driver --features cuda-driver, leleka-runtime)
# - cargo test of the product crates; the deploy end-to-end tests run against scripts/ci/nvidia-smi, a hermetic stand-in # - cargo test of the product crates; the deploy end-to-end tests run against scripts/ci/nvidia-smi, a hermetic stand-in
# - rustfmt and Clippy -D warnings on the shipped crates; the known debt is reported (STRICT_DEBT=1 makes it fatal) # - rustfmt and Clippy -D warnings on the shipped crates; the known debt is reported (STRICT_DEBT=1 makes it fatal)
# No GPU, model weights or token is used. A green run proves the product compiles, links and passes its CPU-side tests; it does not # No GPU, model weights or token is used. A green run proves the product compiles, links and passes its CPU-side tests; it does not
# prove any GPU kernel, model quality or speed (docs/ci-audit.md, section "What CI cannot prove"). # prove any GPU kernel, model quality or speed.
on: on:
push: push:
+5
View File
@@ -45,3 +45,8 @@ dist/
# The one binary kept in Git: upstream Strata's ranked expert profile (196,632 B, MIT, sha256 8f59b4aa...388975baf), embedded in `leleka` # The one binary kept in Git: upstream Strata's ranked expert profile (196,632 B, MIT, sha256 8f59b4aa...388975baf), embedded in `leleka`
# (crates/deploy/src/expert_profile.rs; attribution in crates/deploy/data/expert-profile.NOTICE). Every other *.bin stays ignored. # (crates/deploy/src/expert_profile.rs; attribution in crates/deploy/data/expert-profile.NOTICE). Every other *.bin stays ignored.
!crates/deploy/data/expert-profile.bin !crates/deploy/data/expert-profile.bin
# LeaseVibe (generated, host-local)
/AGENTS.md
/.leasevibe.yaml
/.claude/hooks/
-58
View File
@@ -1,58 +0,0 @@
# Repository instructions
Read `PROJECT_CHARTER.md` before changing architecture, performance policy, or scope. The charter is the source of truth for goals and milestones.
## Priorities
1. Preserve protocol correctness and successful task completion.
2. Preserve model quality and tool-call integrity.
3. Improve end-to-end agent throughput, then decode/prefill throughput.
## Change rules
- Keep production serving independent of Python. Python is allowed for offline conversion, calibration, experiments, and evaluations.
- Keep model weights, request captures, credentials, logs, and generated artifacts out of Git. Use external volumes or ignored local paths. Sanitize any fixture committed to the repository.
- Do not enable lossy optimizations by default until their separate quality gate passes. Mark experimental modes explicitly. Recorded exception: the 5090 profiles run the lossy route tail skip by default, an explicit owner decision of 2026-11-13 that overrode the open points of its quality gate (`docs/deploy.md` section 4).
- For non-lossy changes, compare greedy output or tensor values against the defined baseline and record numerical tolerances.
- Do not label a change as a performance improvement without paired A/B measurements on the same workload and a quality result. Record hardware, software, model digest, configuration, cache state, token counts, and distributions as required by the charter.
- Do not conflate a synthetic kernel gain with an end-to-end agent workload gain. Report both when relevant.
- Dependency direction, file sizes and source patterns are gated by `scripts/check-architecture.py` (policy `architecture.json`, debt `architecture-baseline.json`, run by `scripts/check-local.sh --product`). A number in the baseline may only fall; lower it with `--update-baseline`, never raise it without `--allow-increase` and a reason in review.
- Keep the Strata upstream commit and local changes traceable. Do not overwrite or silently replace the upstream provenance record.
## Repository state
The Strata source is present under `engine/strata/` at the commit recorded in `docs/upstream.md` and is not modified. `engine/strata` is the
reference (the "Original"); the product is the Rust/CUDA port of its Original mode17 serve path:
* `crates/engine-qwen35-cuda` (the Qwen3.5 CUDA engine family: prefill, MTP speculative decode, expert tiers, KV streaming; `crates/leleka-runtime` is its facade), `crates/engine-core` (the pure engine domain: prefix cache, conversation policy, prompt plan, speculative-decoding policies, request lifecycle, the `EngineFamily` seam), `crates/engine-fake` (the scripted engine family for GPU-free tests), `crates/cuda-driver`
(CUDA Driver API, sealed PTX, NVML sampler; its pure host-side models are `crates/cuda-model`), `crates/leleka-memory` (memory governor, pressure gate, telemetry), `desktop-core` and
`crates/runtime-client` (the gRPC contract between the engine process and the gateway), `control-plane` (HTTP/Responses gateway), `crates/deploy`
(the `leleka` binary: `up/run/status/verify`, memory profiles, resource presets).
* The layers (L0 to L4), the ports, how to add an engine family and what the architecture gates check: `docs/architecture/hexagonal.md`.
* Measured on an RTX 5090 server with real Codex CLI sessions (`docs/e2e-run.md`, `docs/ledger.md`, `docs/quality-gate.md`, `docs/prefix-cache.md`,
`docs/deploy.md`, `docs/roofline.md`); the RTX 3080 laptop is a secondary, experimental target (`docs/laptop-profile.md`).
* The port is complete for the 5090 serve path; open work is listed in `docs/port-remaining.md` and the ledger.
* The CPU/iGPU/NPU runtime for gpt-oss (`crates/cpu-*`, `gptoss*`, `harmony`, `igpu*`, `npu-*`, `gguf`, `kar-codec`; `docs/cpu-runtime.md`) is served through the same
control plane: `codec::TextCodec` selects the family (Qwen3.5 or gpt-oss/Harmony) and `engine.extra_workers` runs a worker pool (`docs/worker-pool.md`).
The pool, `lazy_load`/`idle_unload_s`, `vision` and the `runtime` block are separate modes; the config rejects combining them (`docs/api-contract.md`).
## Worktrees
- Create worktrees inside the main repository's git directory, never as sibling folders of `~/work`: `scripts/dev/worktree.sh new <name> [<branch>]` makes `.git/wt/<name>`. The files are ordinary; only the location is hidden from the file listing.
- Clean up when a branch has been merged: `scripts/dev/worktree.sh clean` lists the clean, merged worktrees and `--yes` removes them. Uncommitted changes block the removal; commit them to the branch first. Do this at the end of every task that created a worktree and before starting a new batch, so no more than a handful exist at a time.
- Build output (`target/`, `dist/`) lives in the worktree and goes with it; a removed worktree never deletes its branch.
## Workspace layout
One folder per machine (owner rule, 2026-10-29). Outside it, read only: no creating, moving, renaming or deleting anything, and no relocating other people's files.
- Laptop: `C:\Users\pavel\work\leleka` (worktrees, build output and run directories under `.git/wt`). Never create, list or clean sibling folders of the repository, and keep WSL builds inside it too (`CARGO_TARGET_DIR` inside the worktree).
- 5090 server (`rnr5090`): `~/work/leleka/` only, the same name as on the laptop. It is a symlink to `/data/leleka-e2e/` because the root disk is small; the data lives on `/data`. Do not add anything to `~/work` itself or to any other folder. Known exception until the holder is re-homed: the GPU queue (`~/work/gpu-runs/holder2/jobs/` stubs and `PRIORITY`) is written there, nothing else.
- Models live inside the work folder too (owner decision, 2026-10-29): server `~/work/leleka/models/{leleka-gates,deepseek-v41-flash}/` (absolute `/home/para/work/leleka/models/...`), laptop `C:\Users\pavel\work\leleka\models\`. Scripts, profiles and docs name those paths; a model path outside the work folder is a bug.
- Name each path after its task (`<task-id>` or `<task-id>-<purpose>`); one directory per task, not one per attempt.
- Clean up your own paths at the end of the task. Do not hard-delete: anything deletable goes into the `garbage/` folder inside the work folder (laptop `leleka/garbage`, server `~/work/leleka/garbage`) with a line in `garbage/LOG.txt`. The owner empties it.
- Evidence cited in a task record keeps its path until the cited change is merged; after a move, update the record with the new path.
- An agent's final report lists every path it created, and any path outside the places above is moved in before the task is closed.
- Measurement inputs are not scratch: a corpus, expert profile, prompt set, binary or helper script that a measurement depends on lives in one named directory (server: `/data/leleka-e2e/decode/` or the task's own directory), is frozen read-only, and is recorded with its sha256 in a manifest and in the run metadata. A run refuses to start when an input is missing or its digest differs. Never read an input from `~/work`, a home directory or a sibling folder that nobody owns. The 2026-10-29 incident: the 245k corpus lived in an unowned folder, a cleanup removed it, and the "256k" session silently became ~300 tokens.
Read `engine/strata/AGENTS.md` before modifying imported engine code.
+1 -1
View File
@@ -14,7 +14,7 @@ unsafe_code = "forbid"
[workspace.lints.clippy] [workspace.lints.clippy]
all = "warn" all = "warn"
# Opt-in profile for paired A/B builds (STRA-245 parity audit, docs/experiments/parity-audit-5090.md item 10). The workspace has no # Opt-in profile for paired A/B builds (STRA-245 parity audit). The workspace has no
# [profile] section, so every shipped binary (bin-e2e4, crates/deploy) is the cargo release default: opt-level 3, no LTO, # [profile] section, so every shipped binary (bin-e2e4, crates/deploy) is the cargo release default: opt-level 3, no LTO,
# 16 codegen units, panic=unwind, no RUSTFLAGS and no target-cpu (the last on purpose: the CPU kernels select their GGML # 16 codegen units, panic=unwind, no RUSTFLAGS and no target-cpu (the last on purpose: the CPU kernels select their GGML
# arithmetic branches with cfg!(target_feature), see crates/native-cpu-expert/src/rust_ggml_native.rs, so target-cpu would change bits). # arithmetic branches with cfg!(target_feature), see crates/native-cpu-expert/src/rust_ggml_native.rs, so target-cpu would change bits).
+2 -2
View File
@@ -10,7 +10,7 @@ This is a bounded core-path ledger, not a whole-project completion certificate.
| Original source / function | Current Rust boundary | Required completion | | Original source / function | Current Rust boundary | Required completion |
| --- | --- | --- | | --- | --- | --- |
| `src/core/mtp.cpp:143` `MtpDrafter::load`; `:380` `bind`; `:677` `kv_restore`; `include/strata/core/mtp.hpp` `idle/device/tensor_*` | SOURCE-COMPLETE, NOT GPU-RUN (2026-10-14, branch `claude/port-mtp-loader`). `original_mtp_rt.rs` reads dense.txt/dense.bin/experts.bin/draft_vocab.bin; `original_mtp_bank.rs` places them (Original order, nine-name check last); `original_mtp_loader.rs` plans geometry/session/KV/coupled and admits the retained ring; `original_mtp_draft_head.rs` gathers the subset head; `original_mtp_actor_loaded.rs` adopts the genuine drafter and links `idle/device/kv_restore/set_*/draft*/coupled`. Runtime: `RetainedOriginalMtpWeights::from_rt_bank`, `OriginalMtpFullOwner::assemble_rt`, `OriginalPromptExecutor::select_rt_mtp` and the actor-driven `draft_committed_mtp`/`draft_first_committed_mtp`. | Remaining is GPU-only evidence: run the ignored `original_mtp_bank_gpu` tests (`LELEKA_MTP_RT_BANK_GPU=yes`), a real-pack load, and compare drafts with the Original. `OriginalServeStack::open` (`qwen_forward/original_serve_stack.rs`) now calls `select_rt_mtp` (option `--mtp-rt-dir`) or the pinned-pack assembly, and the serve loop drives `draft_committed_mtp` (`OriginalServeHost::draft_committed`); `draft_first` stays CLI-only (the serve loop never reaches it). Not repeated: Original `cudaMemset(cring_, 0xff)`; the Original single-allocation `dense_` (each indexed tensor is its own allocation, same total bytes); `tensor_f32/bf16/q8` host accessors (roles are the retained `Rc<DeviceBuffer>` bank). | | `src/core/mtp.cpp:143` `MtpDrafter::load`; `:380` `bind`; `:677` `kv_restore`; `include/strata/core/mtp.hpp` `idle/device/tensor_*` | SOURCE-COMPLETE, NOT GPU-RUN (2026-10-14, branch `claude/port-mtp-loader`). `original_mtp_rt.rs` reads dense.txt/dense.bin/experts.bin/draft_vocab.bin; `original_mtp_bank.rs` places them (Original order, nine-name check last); `original_mtp_loader.rs` plans geometry/session/KV/coupled and admits the retained ring; `original_mtp_draft_head.rs` gathers the subset head; `original_mtp_actor_loaded.rs` adopts the genuine drafter and links `idle/device/kv_restore/set_*/draft*/coupled`. Runtime: `RetainedOriginalMtpWeights::from_rt_bank`, `OriginalMtpFullOwner::assemble_rt`, `OriginalPromptExecutor::select_rt_mtp` and the actor-driven `draft_committed_mtp`/`draft_first_committed_mtp`. | Remaining is GPU-only evidence: run the ignored `original_mtp_bank_gpu` tests (`LELEKA_MTP_RT_BANK_GPU=yes`), a real-pack load, and compare drafts with the Original. `OriginalServeStack::open` (`qwen_forward/original_serve_stack.rs`) now calls `select_rt_mtp` (option `--mtp-rt-dir`) or the pinned-pack assembly, and the serve loop drives `draft_committed_mtp` (`OriginalServeHost::draft_committed`); `draft_first` stays CLI-only (the serve loop never reaches it). Not repeated: Original `cudaMemset(cring_, 0xff)`; the Original single-allocation `dense_` (each indexed tensor is its own allocation, same total bytes); `tensor_f32/bf16/q8` host accessors (roles are the retained `Rc<DeviceBuffer>` bank). |
| `src/core/verify.cpp:405` `record_window`, `:925` `capture`, `:988` `capture_commit`, `:1054` `run` | `original_verify.rs:235` defines `OriginalVerifyGraphResources`; `original_verify_schedule.rs` owns real streams/graphs/doorbells and accepts a caller recording closure. The concrete aggregate is `OriginalVerifyWindowResources` (`original_verify_window_ops.rs`). | `OriginalVerifyWindowOps` now has capture-time producers for every former `UNBOUND_PRODUCERS` entry (pure planners over SHA-pinned sealed PTX: projections/head, GR, GDN, QSA, MoE; unit-tested against verify.cpp order). Still open: seal `original_verify_window_moe_experts.ptx` and `original_verify_window_qsa_gate.ptx` (`docs/cuda-seal-plan-additions-window.json`; the window fails closed with those names until then), GPU smokes/golden comparisons per kernel and for a whole window, the fast-math re-seal question listed in that JSON, and the hardware run. The runtime-side wiring (weights, QSA/PLE journals, CPU pool callbacks, graph registration before `run`) is SOURCE-WIRED, NOT GPU-RUN on `claude/port-serve-host`: `original_serve_verifier::assemble` builds the canonical GDN image, the QSA journal over the prompt executor's twelve resident owners, the PLE history and the window/commit aggregates per decode phase; `original_serve_pool` is the CPU callback (all-CPU expert tier: the driver publishes the empty plan). The asset probe (`original_serve_asset_status`) lists the unsealed assets and any producer still unbound, so `--backend-mode auto` stays on the preview path until they are sealed and `original` refuses naming them. | | `src/core/verify.cpp:405` `record_window`, `:925` `capture`, `:988` `capture_commit`, `:1054` `run` | `original_verify.rs:235` defines `OriginalVerifyGraphResources`; `original_verify_schedule.rs` owns real streams/graphs/doorbells and accepts a caller recording closure. The concrete aggregate is `OriginalVerifyWindowResources` (`original_verify_window_ops.rs`). | `OriginalVerifyWindowOps` now has capture-time producers for every former `UNBOUND_PRODUCERS` entry (pure planners over SHA-pinned sealed PTX: projections/head, GR, GDN, QSA, MoE; unit-tested against verify.cpp order). Still open: seal `original_verify_window_moe_experts.ptx` and `original_verify_window_qsa_gate.ptx` (`crates/cuda-driver/seal-plans/cuda-seal-plan-additions-window.json`; the window fails closed with those names until then), GPU smokes/golden comparisons per kernel and for a whole window, the fast-math re-seal question listed in that JSON, and the hardware run. The runtime-side wiring (weights, QSA/PLE journals, CPU pool callbacks, graph registration before `run`) is SOURCE-WIRED, NOT GPU-RUN on `claude/port-serve-host`: `original_serve_verifier::assemble` builds the canonical GDN image, the QSA journal over the prompt executor's twelve resident owners, the PLE history and the window/commit aggregates per decode phase; `original_serve_pool` is the CPU callback (all-CPU expert tier: the driver publishes the empty plan). The asset probe (`original_serve_asset_status`) lists the unsealed assets and any producer still unbound, so `--backend-mode auto` stays on the preview path until they are sealed and `original` refuses naming them. |
| `mtp.cpp` `draft/draft_first` and `verify.cpp` `run/commit/wait_commit`, used together by mode17 generation | SOURCE-WIRED, NOT GPU-RUN. `OriginalServeEngine` implements `OriginalSpecEngine` over `NativeServePort`, which binds the driver `OriginalVerifier`; `OriginalServeHost` (`original_serve_host.rs`) supplies the owners (window PLE rows, penalty-history sampling, expert pool, lineage ledger, session publication of the accepted prefix, MTP history/restore/drain) and `OriginalServeStack` drives prompt + decode. `OriginalServeSettings::controller` is called by the stack; `--backend-mode` selects it in the serving owner. Commit and draft are serialized (the commit event completes and the session is published before the draft launches), so the Original's commit/draft overlap is not reproduced. | Hardware run of `backend_original_serve_smoke.rs` (`LELEKA_ORIGINAL_SERVE_SMOKE=yes`), then parity and a keep-the-overlap pass. | | `mtp.cpp` `draft/draft_first` and `verify.cpp` `run/commit/wait_commit`, used together by mode17 generation | SOURCE-WIRED, NOT GPU-RUN. `OriginalServeEngine` implements `OriginalSpecEngine` over `NativeServePort`, which binds the driver `OriginalVerifier`; `OriginalServeHost` (`original_serve_host.rs`) supplies the owners (window PLE rows, penalty-history sampling, expert pool, lineage ledger, session publication of the accepted prefix, MTP history/restore/drain) and `OriginalServeStack` drives prompt + decode. `OriginalServeSettings::controller` is called by the stack; `--backend-mode` selects it in the serving owner. Commit and draft are serialized (the commit event completes and the session is published before the draft launches), so the Original's commit/draft overlap is not reproduced. | Hardware run of `backend_original_serve_smoke.rs` (`LELEKA_ORIGINAL_SERVE_SMOKE=yes`), then parity and a keep-the-overlap pass. |
| `include/strata/core/verify.hpp` `set_stage/set_next`; `src/core/verify.cpp:191,1054,1382,1412`; `core/on_device.hpp` | `OriginalVerifier` loops all 48 layers, has no next-stage owner or stage handoff fields. Context identity exists, but the unselected MTP actor cannot infer an actual current CUDA device ordinal. | Port stage bounds, mapped portable R+pending-bo+inject handoff, next-user CPU dispatch and last-stage head/sampling/final_R/commit forwarding. This is an absent multi-GPU mode17 leaf, not a single-device quality defect. | | `include/strata/core/verify.hpp` `set_stage/set_next`; `src/core/verify.cpp:191,1054,1382,1412`; `core/on_device.hpp` | `OriginalVerifier` loops all 48 layers, has no next-stage owner or stage handoff fields. Context identity exists, but the unselected MTP actor cannot infer an actual current CUDA device ordinal. | Port stage bounds, mapped portable R+pending-bo+inject handoff, next-user CPU dispatch and last-stage head/sampling/final_R/commit forwarding. This is an absent multi-GPU mode17 leaf, not a single-device quality defect. |
| `verify.cpp:137,158,899,1323,1422` public release/diag/profile/logprob/logit APIs | Internal Rust bounded wait release, commit event and completed-row bridge are present. No equivalent public diagnostic/watchdog registry, profile report, window_logprobs or copy_logits API was found in the inspected Original Rust modules. | Expose the actual live verifier release/diagnostic owner; port literal GPU-stage stamps and completed logit/logprob readout (including LOGPOS_TOPK). Keep capture-only graphs inadmissible for readout. Do not call the existing internal release absent. | | `verify.cpp:137,158,899,1323,1422` public release/diag/profile/logprob/logit APIs | Internal Rust bounded wait release, commit event and completed-row bridge are present. No equivalent public diagnostic/watchdog registry, profile report, window_logprobs or copy_logits API was found in the inspected Original Rust modules. | Expose the actual live verifier release/diagnostic owner; port literal GPU-stage stamps and completed logit/logprob readout (including LOGPOS_TOPK). Keep capture-only graphs inadmissible for readout. Do not call the existing internal release absent. |
@@ -21,7 +21,7 @@ This is a bounded core-path ledger, not a whole-project completion certificate.
mapped/fallback embedding, T1..8 head rows, request sampling/history and MTP mapped/fallback embedding, T1..8 head rows, request sampling/history and MTP
head-weight loans. `model-format/src/gguf_native_head.rs` has shard/architecture head-weight loans. `model-format/src/gguf_native_head.rs` has shard/architecture
and `strata-embd` override parsing. The owners are bound by `OriginalServeStack`/`OriginalServeHost` and `strata-embd` override parsing. The owners are bound by `OriginalServeStack`/`OriginalServeHost`
(see docs/original-serve.md); the remaining gap is the unbound window producers and the GPU run. (see spec node original-serve.md); the remaining gap is the unbound window producers and the GPU run.
- NativeHead's earlier penalties-off empty-history refusal is already corrected - NativeHead's earlier penalties-off empty-history refusal is already corrected
in current `native_head.rs:140..158`; do not reopen that stale finding. in current `native_head.rs:140..158`; do not reopen that stale finding.
- Verifier GDN/QSA accepted-prefix journals, stream release and async commit event - Verifier GDN/QSA accepted-prefix journals, stream release and async commit event
+10 -10
View File
@@ -3,11 +3,11 @@
Leleka is a Rust/CUDA inference runtime for coding agents. Release **0.1** serves one model, **Qwen3.8-Flash-Next IQ3_S** (KAR level-2 PLE, MTP speculative Leleka is a Rust/CUDA inference runtime for coding agents. Release **0.1** serves one model, **Qwen3.8-Flash-Next IQ3_S** (KAR level-2 PLE, MTP speculative
decode), on **one RTX 5090 (32 GB)** at **262,144 tokens of context**, to Codex CLI and other clients over the Responses, Chat Completions and Messages APIs. decode), on **one RTX 5090 (32 GB)** at **262,144 tokens of context**, to Codex CLI and other clients over the Responses, Chat Completions and Messages APIs.
It is a Rust/CUDA port of the Original mode17 serve path of [Strata](https://github.com/Niko1221/Strata) (reference copy in `engine/strata/`, pinned at It is a Rust/CUDA port of the Original mode17 serve path of [Strata](https://github.com/Niko1221/Strata) (reference copy in `engine/strata/`, pinned at
upstream `41cf05a0`, see `docs/upstream.md`). Serving needs no Python and no CUDA toolkit on the host. upstream `41cf05a0`, see `engine/upstream.md`). Serving needs no Python and no CUDA toolkit on the host.
**Status of 0.1.** It runs real Codex sessions to completion and decodes about 155 tok/s on the 245k-token benchmark of the 5090 server (section "Numbers"). **Status of 0.1.** It runs real Codex sessions to completion and decodes about 155 tok/s on the 245k-token benchmark of the 5090 server (section "Numbers").
It is **not a formally quality-gated profile**, only the RTX 5090 is supported, and the limits below are real. Release notes: `docs/release/RELEASE-NOTES-5090-v0.1.md`; It is **not a formally quality-gated profile**, only the RTX 5090 is supported, and the limits below are real. Release notes: `spec node release/RELEASE-NOTES-5090-v0.1.md`;
every gate and its evidence: `docs/release/5090-v0.1-checklist.md`. every gate and its evidence: `spec node release/5090-v0.1-checklist.md`.
## Requirements ## Requirements
@@ -30,21 +30,21 @@ curl -H "Authorization: Bearer $(cat STATE/api-key)" http://127.0.0.1:8081/v1/mo
``` ```
The API listens on loopback only (use an SSH tunnel); the key is in `STATE/api-key`. Codex CLI: `wire_api = "responses"`, `base_url = "http://127.0.0.1:8081/v1"`, `web_search = "disabled"`. The API listens on loopback only (use an SSH tunnel); the key is in `STATE/api-key`. Codex CLI: `wire_api = "responses"`, `base_url = "http://127.0.0.1:8081/v1"`, `web_search = "disabled"`.
Details, every flag, upgrade and rollback: `docs/deploy.md`, `docs/unattended.md` (running it as a boot-time service: `scripts/ops/`, installed by the owner of the machine, never by the release). Details, every flag, upgrade and rollback: `spec node deploy.md`, `spec node unattended.md` (running it as a boot-time service: `scripts/ops/`, installed by the owner of the machine, never by the release).
Upgrade: stop the service, keep a copy of `STATE/*.json`, unpack the new release, run its `install.sh` with the same flags. Rollback: restore the copies and run the previous release's `install.sh`. Upgrade: stop the service, keep a copy of `STATE/*.json`, unpack the new release, run its `install.sh` with the same flags. Rollback: restore the copies and run the previous release's `install.sh`.
## Numbers (measured, paired, one workload) ## Numbers (measured, paired, one workload)
Decode tok/s on the frozen 245k-token corpus (5 turns x 300 output tokens, greedy, RTX 5090, Ryzen 9 9950X3D), ours against vanilla Strata 0.2.6 on fresh boots, vanilla in its good Decode tok/s on the frozen 245k-token corpus (5 turns x 300 output tokens, greedy, RTX 5090, Ryzen 9 9950X3D), ours against vanilla Strata 0.2.6 on fresh boots, vanilla in its good
huge-page state (`docs/experiments/baseline-pair-5090.md`, section 10, 3 balanced blocks): **ours 155.4** (sd 2.4), vanilla v1 (its shipped lossy defaults) 137.0 (ahead of it in 3 of 3 blocks, +13.5 %), huge-page state (`spec node experiments/baseline-pair-5090.md`, section 10, 3 balanced blocks): **ours 155.4** (sd 2.4), vanilla v1 (its shipped lossy defaults) 137.0 (ahead of it in 3 of 3 blocks, +13.5 %),
vanilla v2 (lossless-comparable) 144.7 (ahead in **2 of 3** blocks, +9.2 %; vanilla v2 is bimodal and ran 171.2 once, 10.8 % faster than ours). Later changes: the faster draft attention is bitwise identical and vanilla v2 (lossless-comparable) 144.7 (ahead in **2 of 3** blocks, +9.2 %; vanilla v2 is bimodal and ran 171.2 once, 10.8 % faster than ours). Later changes: the faster draft attention is bitwise identical and
shortens a round by 2.7 % (tok/s +0.5 % +- 0.6 %, not significant); the window policy default +1.1 % +- 1.2 % (not resolved, no speedup claimed); the single-copy memory layout shortens a round by 2.7 % (tok/s +0.5 % +- 0.6 %, not significant); the window policy default +1.1 % +- 1.2 % (not resolved, no speedup claimed); the single-copy memory layout
(`docs/kar-sparse-memfd.md`) is identical in output (2057/2057 logprob rows, 1036/1036 draft traces) and frees 36.6 GiB of RAM at 245k (MemAvailable 8.5 to 45.1 GiB; tok/s +0.58 %, n.s.). (`spec node kar-sparse-memfd.md`) is identical in output (2057/2057 logprob rows, 1036/1036 draft traces) and frees 36.6 GiB of RAM at 245k (MemAvailable 8.5 to 45.1 GiB; tok/s +0.58 %, n.s.).
These are decode speeds of a benchmark, not agent-task times. These are decode speeds of a benchmark, not agent-task times.
## Quality and limits ## Quality and limits
* Not bit-identical to the Original; deviations are inside the Original's own rounding envelope where tested (`docs/quality-gate.md`), and **there is no 245k port-versus-Original equality gate yet** (STRA-337). * Not bit-identical to the Original; deviations are inside the Original's own rounding envelope where tested (`spec node quality-gate.md`), and **there is no 245k port-versus-Original equality gate yet** (STRA-337).
KAR level-2 PLE, chain kernels, prefill chunk 8192, request-end prefix checkpoints and the adaptive expert tier have no 256k gate. All evidence is greedy. KAR level-2 PLE, chain kernels, prefill chunk 8192, request-end prefix checkpoints and the adaptive expert tier have no 256k gate. All evidence is greedy.
* Lossy modes are **off**: route tail skip gave +15 % decode but failed its quality gate; keyless KV failed too. Tool calls are the model's: malformed ones are refused, not repaired. * Lossy modes are **off**: route tail skip gave +15 % decode but failed its quality gate; keyless KV failed too. Tool calls are the model's: malformed ones are refused, not repaired.
* One generation at a time (queue of 16); images and `reasoning_budget_tokens` are refused; RTX 3080 and Windows are not part of 0.1; no multi-hour soak on the release commit (post-release feedback). * One generation at a time (queue of 16); images and `reasoning_budget_tokens` are refused; RTX 3080 and Windows are not part of 0.1; no multi-hour soak on the release commit (post-release feedback).
@@ -78,7 +78,7 @@ What the service is doing, and why a request was slow or failed, is in its logs;
- `control-plane/`, `desktop-core/` — the HTTP/Responses gateway (`leleka-api`) and the engine/daemon processes. - `control-plane/`, `desktop-core/` — the HTTP/Responses gateway (`leleka-api`) and the engine/daemon processes.
- `engine/strata/` — the pinned upstream Strata, the reference (unmodified by Leleka). - `engine/strata/` — the pinned upstream Strata, the reference (unmodified by Leleka).
- `deploy/`, `scripts/` — profiles, service templates, release packager (`scripts/release/`), test and measurement tooling (Python is allowed there, never in serving). - `deploy/`, `scripts/` — profiles, service templates, release packager (`scripts/release/`), test and measurement tooling (Python is allowed there, never in serving).
- `PROJECT_CHARTER.md`, `docs/` — requirements, provenance, decisions, gates and measurements. Architecture: `docs/architecture/hexagonal.md`. - `PROJECT_CHARTER.md`, the LeaseVibe spec (imported repository documentation) — requirements, provenance, decisions, gates and measurements. Architecture: spec node `architecture/hexagonal.md`.
Model weights, request captures, credentials, logs and generated artifacts stay outside Git. Model weights, request captures, credentials, logs and generated artifacts stay outside Git.
@@ -87,9 +87,9 @@ Model weights, request captures, credentials, logs and generated artifacts stay
```sh ```sh
cargo test --workspace --locked cargo test --workspace --locked
cargo clippy --workspace --all-targets --all-features -- -D warnings cargo clippy --workspace --all-targets --all-features -- -D warnings
scripts/release/package-5090.sh check # the release gates; `package` builds the release set (docs/release/5090-v0.1-checklist.md) scripts/release/package-5090.sh check # the release gates; `package` builds the release set (spec node release/5090-v0.1-checklist.md)
``` ```
## Licence ## Licence
MIT (`LICENSE`). A commercial licence is available on request. Third-party notices: `docs/release/licence-and-secrets-audit-5090-v0.1.md`; the Strata reference is MIT (`engine/strata/LICENSE`). MIT (`LICENSE`). A commercial licence is available on request. Third-party notices: `spec node release/licence-and-secrets-audit-5090-v0.1.md`; the Strata reference is MIT (`engine/strata/LICENSE`).
@@ -1,222 +1,222 @@
{ {
"schema": 1, "schema": 1,
"note": "Additions for the experimental Strata modes. None of these six .cu files has been compiled; PINS in experimental.rs are all zero and admit_ptx refuses every asset until Root builds the PTX and freezes the digests. Flags follow engine/strata/CMakeLists.txt: none of the six Original TUs is in the --use_fast_math list (native_* only) and the strata_kernels target adds no other CUDA flag besides CUDA_STANDARD 17, so the build is precise (no --use_fast_math) with default -fmad contraction.", "note": "Additions for the experimental Strata modes. None of these six .cu files has been compiled; PINS in experimental.rs are all zero and admit_ptx refuses every asset until Root builds the PTX and freezes the digests. Flags follow engine/strata/CMakeLists.txt: none of the six Original TUs is in the --use_fast_math list (native_* only) and the strata_kernels target adds no other CUDA flag besides CUDA_STANDARD 17, so the build is precise (no --use_fast_math) with default -fmad contraction.",
"assets": [ "assets": [
{ {
"cu": "crates/cuda-driver/src/experimental_kv_q4.cu", "cu": "crates/cuda-driver/src/experimental_kv_q4.cu",
"cu_pin": { "cu_pin": {
"sha256": "378058e82084b697e13e8ac3cd25520372d2848ed3ebec78ac5e369ee9a91720", "sha256": "378058e82084b697e13e8ac3cd25520372d2848ed3ebec78ac5e369ee9a91720",
"bytes": 17507 "bytes": 17507
}, },
"ptx": "crates/cuda-driver/src/experimental_kv_q4.ptx", "ptx": "crates/cuda-driver/src/experimental_kv_q4.ptx",
"flags": [ "flags": [
"-ptx", "-ptx",
"-O3", "-O3",
"-arch=sm_120", "-arch=sm_120",
"-std=c++17" "-std=c++17"
], ],
"policy": "EXPERIMENTAL, off by default (OptIn). FWHT-256 + Q4_0 append (step/batched) + gather; Original kv_q4.cu precise (default flags, not in the fast-math list); K8V4's Q4_0 V half and rotated INT8's FWHT", "policy": "EXPERIMENTAL, off by default (OptIn). FWHT-256 + Q4_0 append (step/batched) + gather; Original kv_q4.cu precise (default flags, not in the fast-math list); K8V4's Q4_0 V half and rotated INT8's FWHT",
"direct_original_headers": [], "direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/kv_q4.cu", "original": "engine/strata/src/kernels/cuda/kv_q4.cu",
"rust_consumers": { "rust_consumers": {
"experimental.rs": { "experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981", "sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
"bytes": 36646 "bytes": 36646
}, },
"experimental_gpu.rs": { "experimental_gpu.rs": {
"sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4", "sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4",
"bytes": 32785 "bytes": 32785
} }
}, },
"rust_fields_to_fill": { "rust_fields_to_fill": {
"experimental.rs": [ "experimental.rs": [
"PINS[0].source_sha256", "PINS[0].source_sha256",
"PINS[0].ptx_sha256" "PINS[0].ptx_sha256"
] ]
}, },
"encoding": "concat_include_str", "encoding": "concat_include_str",
"seal_sha256": "74665b016fde9dc4f50a36e62cbf2e578c735e48e3be51b70734e9e53942cde7", "seal_sha256": "74665b016fde9dc4f50a36e62cbf2e578c735e48e3be51b70734e9e53942cde7",
"seal_length": 36319 "seal_length": 36319
}, },
{ {
"cu": "crates/cuda-driver/src/experimental_kv_q8.cu", "cu": "crates/cuda-driver/src/experimental_kv_q8.cu",
"cu_pin": { "cu_pin": {
"sha256": "007f00692c702313a79dee0f1aa433c3412f6b4d73de620b02e136d960203c9f", "sha256": "007f00692c702313a79dee0f1aa433c3412f6b4d73de620b02e136d960203c9f",
"bytes": 13448 "bytes": 13448
}, },
"ptx": "crates/cuda-driver/src/experimental_kv_q8.ptx", "ptx": "crates/cuda-driver/src/experimental_kv_q8.ptx",
"flags": [ "flags": [
"-ptx", "-ptx",
"-O3", "-O3",
"-arch=sm_120", "-arch=sm_120",
"-std=c++17" "-std=c++17"
], ],
"policy": "EXPERIMENTAL, off by default (OptIn). INT8 append (K+V, K8V4 K half, V-only) + gather; Original kv_q8.cu precise", "policy": "EXPERIMENTAL, off by default (OptIn). INT8 append (K+V, K8V4 K half, V-only) + gather; Original kv_q8.cu precise",
"direct_original_headers": [], "direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/kv_q8.cu", "original": "engine/strata/src/kernels/cuda/kv_q8.cu",
"rust_consumers": { "rust_consumers": {
"experimental.rs": { "experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981", "sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
"bytes": 36646 "bytes": 36646
}, },
"experimental_gpu.rs": { "experimental_gpu.rs": {
"sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4", "sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4",
"bytes": 32785 "bytes": 32785
} }
}, },
"rust_fields_to_fill": { "rust_fields_to_fill": {
"experimental.rs": [ "experimental.rs": [
"PINS[1].source_sha256", "PINS[1].source_sha256",
"PINS[1].ptx_sha256" "PINS[1].ptx_sha256"
] ]
}, },
"encoding": "concat_include_str", "encoding": "concat_include_str",
"seal_sha256": "43c308960830833e29329907e27be5203ef3bc89cc7d0a9176270dc18732d600", "seal_sha256": "43c308960830833e29329907e27be5203ef3bc89cc7d0a9176270dc18732d600",
"seal_length": 32973 "seal_length": 32973
}, },
{ {
"cu": "crates/cuda-driver/src/experimental_kv_stream.cu", "cu": "crates/cuda-driver/src/experimental_kv_stream.cu",
"cu_pin": { "cu_pin": {
"sha256": "8c9fe1c0e4164ac2b40304a389710615829842a2ac47ab4b4ef92b3ace5d5a4f", "sha256": "8c9fe1c0e4164ac2b40304a389710615829842a2ac47ab4b4ef92b3ace5d5a4f",
"bytes": 12456 "bytes": 12456
}, },
"ptx": "crates/cuda-driver/src/experimental_kv_stream.ptx", "ptx": "crates/cuda-driver/src/experimental_kv_stream.ptx",
"flags": [ "flags": [
"-ptx", "-ptx",
"-O3", "-O3",
"-arch=sm_120", "-arch=sm_120",
"-std=c++17" "-std=c++17"
], ],
"policy": "EXPERIMENTAL, off by default (OptIn). CLOCK residency resolver, block copy, ring table, u4 copy; Original kv_stream.cu precise; integer only", "policy": "EXPERIMENTAL, off by default (OptIn). CLOCK residency resolver, block copy, ring table, u4 copy; Original kv_stream.cu precise; integer only",
"direct_original_headers": [], "direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/kv_stream.cu", "original": "engine/strata/src/kernels/cuda/kv_stream.cu",
"rust_consumers": { "rust_consumers": {
"experimental.rs": { "experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981", "sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
"bytes": 36646 "bytes": 36646
}, },
"experimental_gpu.rs": { "experimental_gpu.rs": {
"sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4", "sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4",
"bytes": 32785 "bytes": 32785
} }
}, },
"rust_fields_to_fill": { "rust_fields_to_fill": {
"experimental.rs": [ "experimental.rs": [
"PINS[2].source_sha256", "PINS[2].source_sha256",
"PINS[2].ptx_sha256" "PINS[2].ptx_sha256"
] ]
}, },
"encoding": "concat_include_str", "encoding": "concat_include_str",
"seal_sha256": "4f71e720e0ca950d321ba3cbb20082ca473e9839b76d08898e95b6623bfffe50", "seal_sha256": "4f71e720e0ca950d321ba3cbb20082ca473e9839b76d08898e95b6623bfffe50",
"seal_length": 34329 "seal_length": 34329
}, },
{ {
"cu": "crates/cuda-driver/src/experimental_keyless.cu", "cu": "crates/cuda-driver/src/experimental_keyless.cu",
"cu_pin": { "cu_pin": {
"sha256": "77c50e5baff842e31f0d71624a5706f46ed74a56cdfc5e4211086d2ef08671c5", "sha256": "77c50e5baff842e31f0d71624a5706f46ed74a56cdfc5e4211086d2ef08671c5",
"bytes": 1987 "bytes": 1987
}, },
"ptx": "crates/cuda-driver/src/experimental_keyless.ptx", "ptx": "crates/cuda-driver/src/experimental_keyless.ptx",
"flags": [ "flags": [
"-ptx", "-ptx",
"-O3", "-O3",
"-arch=sm_120", "-arch=sm_120",
"-std=c++17" "-std=c++17"
], ],
"policy": "EXPERIMENTAL, off by default (OptIn). per-head query routing (fmaf-ordered 256x256); Original keyless.cu precise", "policy": "EXPERIMENTAL, off by default (OptIn). per-head query routing (fmaf-ordered 256x256); Original keyless.cu precise",
"direct_original_headers": [], "direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/keyless.cu", "original": "engine/strata/src/kernels/cuda/keyless.cu",
"rust_consumers": { "rust_consumers": {
"experimental.rs": { "experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981", "sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
"bytes": 36646 "bytes": 36646
}, },
"experimental_gpu.rs": { "experimental_gpu.rs": {
"sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4", "sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4",
"bytes": 32785 "bytes": 32785
} }
}, },
"rust_fields_to_fill": { "rust_fields_to_fill": {
"experimental.rs": [ "experimental.rs": [
"PINS[3].source_sha256", "PINS[3].source_sha256",
"PINS[3].ptx_sha256" "PINS[3].ptx_sha256"
] ]
}, },
"encoding": "concat_include_str", "encoding": "concat_include_str",
"seal_sha256": "1ab8b8156e8c824131c00cecda177fe57d74b286a02b7e5afdfa39acadaa33e6", "seal_sha256": "1ab8b8156e8c824131c00cecda177fe57d74b286a02b7e5afdfa39acadaa33e6",
"seal_length": 3760 "seal_length": 3760
}, },
{ {
"cu": "crates/cuda-driver/src/experimental_qsa_attn.cu", "cu": "crates/cuda-driver/src/experimental_qsa_attn.cu",
"cu_pin": { "cu_pin": {
"sha256": "907ffc8f7504efd0655d2311ac4787fb131dfd1ef7cbf1aebfdddf1b9d31c505", "sha256": "907ffc8f7504efd0655d2311ac4787fb131dfd1ef7cbf1aebfdddf1b9d31c505",
"bytes": 23119 "bytes": 23119
}, },
"ptx": "crates/cuda-driver/src/experimental_qsa_attn.ptx", "ptx": "crates/cuda-driver/src/experimental_qsa_attn.ptx",
"flags": [ "flags": [
"-ptx", "-ptx",
"-O3", "-O3",
"-arch=sm_120", "-arch=sm_120",
"-std=c++17" "-std=c++17"
], ],
"policy": "EXPERIMENTAL, off by default (OptIn). experimental attention modes 2/3/4 + merge; Original qsa_decode_attn.cu precise (expf/exp2f exact, not in the fast-math list)", "policy": "EXPERIMENTAL, off by default (OptIn). experimental attention modes 2/3/4 + merge; Original qsa_decode_attn.cu precise (expf/exp2f exact, not in the fast-math list)",
"direct_original_headers": [], "direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/qsa_decode_attn.cu", "original": "engine/strata/src/kernels/cuda/qsa_decode_attn.cu",
"rust_consumers": { "rust_consumers": {
"experimental.rs": { "experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981", "sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
"bytes": 36646 "bytes": 36646
}, },
"experimental_gpu.rs": { "experimental_gpu.rs": {
"sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4", "sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4",
"bytes": 32785 "bytes": 32785
} }
}, },
"rust_fields_to_fill": { "rust_fields_to_fill": {
"experimental.rs": [ "experimental.rs": [
"PINS[4].source_sha256", "PINS[4].source_sha256",
"PINS[4].ptx_sha256" "PINS[4].ptx_sha256"
] ]
}, },
"encoding": "concat_include_str", "encoding": "concat_include_str",
"seal_sha256": "5623a5ae9b2ebd2fa010c334367ffc54879ac6df76aef08381dbd32b0f7ef311", "seal_sha256": "5623a5ae9b2ebd2fa010c334367ffc54879ac6df76aef08381dbd32b0f7ef311",
"seal_length": 128247 "seal_length": 128247
}, },
{ {
"cu": "crates/cuda-driver/src/experimental_cvec.cu", "cu": "crates/cuda-driver/src/experimental_cvec.cu",
"cu_pin": { "cu_pin": {
"sha256": "d4fe221b11569db73247644bb79118b34d040b49c14897e0bac158dcd4ca356e", "sha256": "d4fe221b11569db73247644bb79118b34d040b49c14897e0bac158dcd4ca356e",
"bytes": 4783 "bytes": 4783
}, },
"ptx": "crates/cuda-driver/src/experimental_cvec.ptx", "ptx": "crates/cuda-driver/src/experimental_cvec.ptx",
"flags": [ "flags": [
"-ptx", "-ptx",
"-O3", "-O3",
"-arch=sm_120", "-arch=sm_120",
"-std=c++17" "-std=c++17"
], ],
"policy": "EXPERIMENTAL, off by default (OptIn). control-vector apply; Original cvec.cu default flags (its own __expf in sigmoidf_ is explicit in the source)", "policy": "EXPERIMENTAL, off by default (OptIn). control-vector apply; Original cvec.cu default flags (its own __expf in sigmoidf_ is explicit in the source)",
"direct_original_headers": [], "direct_original_headers": [],
"original": "engine/strata/src/kernels/cuda/cvec.cu", "original": "engine/strata/src/kernels/cuda/cvec.cu",
"rust_consumers": { "rust_consumers": {
"experimental.rs": { "experimental.rs": {
"sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981", "sha256": "efdff8bf38d53c7b3825316a86169a56c8d3ca166e39a2ed889872de52c15981",
"bytes": 36646 "bytes": 36646
}, },
"experimental_gpu.rs": { "experimental_gpu.rs": {
"sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4", "sha256": "8ef8c9a74092e2b273c9caa49a6af7d190f844d139ffc89a61f038690d2131b4",
"bytes": 32785 "bytes": 32785
} }
}, },
"rust_fields_to_fill": { "rust_fields_to_fill": {
"experimental.rs": [ "experimental.rs": [
"PINS[5].source_sha256", "PINS[5].source_sha256",
"PINS[5].ptx_sha256" "PINS[5].ptx_sha256"
] ]
}, },
"encoding": "concat_include_str", "encoding": "concat_include_str",
"seal_sha256": "193add5cb448f5e193f20ff248ca4459abb962b472663c00d18941313bfa3ebc", "seal_sha256": "193add5cb448f5e193f20ff248ca4459abb962b472663c00d18941313bfa3ebc",
"seal_length": 28943 "seal_length": 28943
} }
] ]
} }
+178
View File
@@ -0,0 +1,178 @@
# 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/leleka-api (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=<base> <ours> <theirs>`; 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` (since the embedded-profile commit it is in Git at `crates/deploy/data/expert-profile.bin`, the one `.gitignore` exception, compiled into `leleka` and written by `leleka up` after a SHA-256 check; download from the pinned commit is the fallback; `crates/deploy/src/expert_profile.rs`), `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).
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+35
View File
@@ -0,0 +1,35 @@
# Рукопис Leleka для arXiv
**Leleka: Model Compression and Session Multiplexing for Long-Context Coding Agents on One GPU.**
Англомовний рукопис містить метод, виміри, аналіз якості, пов’язані роботи та додаток із походженням експериментів. У `leleka.tex` вбудовано бібліографію. Для компіляції достатньо стандартних пакетів LaTeX.
## Що саме додає Leleka
- **KAR.** Вкладене кодування походить із Koference. Han та співавтори вже квантують ту саму n-грамну таблицю Qwen3.8-Flash-Next до 13,4 ГБ за двобітного коду й відновлюють лише вибрані рядки. Внесок Leleka — шлях від конверсії GGUF з обмеженою пам’яттю до обслуговування з розрідженого `memfd`. Він зберігає вихідні офсети архіву та перевіряє хеш списку діапазонів і їхніх байтів. Виміряні 36,6 ГіБ стосуються повної та розрідженої копій **того самого** KAR. [N-Gram Memories at Two Bits](https://arxiv.org/abs/2610.21810v3), [SlackTier](https://arxiv.org/abs/2611.13413), [реалізація розрідженого завантаження](../kar-sparse-memfd.md).
- **Мультиплексування.** Strata вже паркує сесії в RAM і дозволяє запозичити чекпойнт, SGLang уже вирівнює певні рекурентні чекпойнти за сіткою, а Marconi та HiState оцінюють вартість рекомп’ютації та пам’яті. Внесок Leleka — конкретний спосіб відновлення одного слота Qwen: спільні блоки K/V та індексу, узгоджені стани GDN, історії PLE і MTP, імпорт лише відсутніх блоків та оцінка витіснення за приростом повторної обробки відносно найближчого вцілілого предка на байт, який справді вивільниться. 5-кратна різниця p95 TTFT виміряна проти контрольного режиму з однією активною історією. [Strata](https://github.com/Niko1221/Strata/blob/41cf05a06a25dd29103b7b27a2279a3f60c21876/docs/DETAILS.md), [SGLang](https://github.com/sgl-project/sglang/blob/99e4233f633a9835987308e6f0a7fb262fc34d62/python/sglang/srt/managers/schedule_policy.py), [Marconi](https://arxiv.org/abs/2411.19379), [HiState](https://arxiv.org/abs/2610.41508), [заміри Leleka](../prefix-cache.md).
## Джерела результатів
| Твердження | Запис і прив’язка до історії |
| --- | --- |
| Архів KAR level 2 займає 55,296 ГБ проти 83,618 ГБ вихідних GGUF. Розмір і відносну похибку також виміряли для рівнів 2 і 3 на двох вибраних зрізах. | [Перевірка повної конверсії та зрізів](../build-validation.md). Техніка вкладених бітових площин походить із Koference, ревізія `806d2398`. Походження декодера зафіксовано в [GPU KAR](../../gpu/kar/README.md). |
| Таблиця PLE займає 16,0 ГБ проти 28,8 ГБ. У парному replay prefill становить 4 206 проти 3 741 токенів/с. Різниця у швидкості decode невизначена, зміна логітів вимірювана. | `740d84113`, `5cc2257ea`. [Парні заміри KAR і GGUF](../experiments/kar-off-ab-5090.md), [швидкість](../e2e-data/kar-off-ab/speed/speed.md), [числова якість](../e2e-data/kar-off-ab/quality-a-kar-vs-gguf.txt). |
| Розріджений `memfd` вивільняє 36,6 ГіБ проти повної копії того самого KAR. Записані top-16 log-probabilities і draft traces збігаються побітно. | `4c1b10e2b`, `2a23976c5`, `0111c3dc6`. [Перелік діапазонів](../kar-sparse-memfd.md), [релізні результати Q12 та A6](../release/5090-v0.1-checklist.md). |
| У синтетичній трасі чотирьох сесій p95 TTFT зменшується з 27,6 до 5,5 с. Для двох сесій із приблизно 180k токенів TTFT повернення становить 2,72–4,76 с, імпорт стану — 175–194 мс. | `8ad4dd5d7`, `d53db650f`, `25538a830`, `44e57ee30`. Контроль — режим одного активного стану в тестовому рушії. [Префіксний кеш, розділ Results](../prefix-cache.md). |
| Живий Codex із трьома сесіями здійснив 48 перемикань, медіана імпорту 29 мс. Максимум черги 51 с. | `7d580590d`, `b54e334a8`. [Звіт живого запуску](../experiments/orchestrator-subagents-smoke.md). |
Усі наведені GPU-результати взято з історії репозиторію. Числові висновки в рукописі розрізняють розмір файлів, резидентну пам’ять, швидкість prefill, TTFT і час завершення задачі. Порівняння з іншими реалізаціями кешування подано в огляді літератури. Походження коду Strata описано в [upstream.md](../upstream.md).
## Збірка й подання
Команди для TeX Live з кореня репозиторію.
```powershell
New-Item -ItemType Directory -Force dist/leleka-arxiv | Out-Null
pdflatex -interaction=nonstopmode -halt-on-error -output-directory=dist/leleka-arxiv docs/paper/leleka.tex
pdflatex -interaction=nonstopmode -halt-on-error -output-directory=dist/leleka-arxiv docs/paper/leleka.tex
tar.exe -czf dist/leleka-arxiv/leleka-source.tar.gz -C docs/paper leleka.tex
```
Робоча основна категорія `cs.DC`. Ім’я **Pavlo Ratushnyi** взято з історії Git. Перед поданням узгодьте список авторів, афіліації й контакт, а також посилання на матеріали, які можна відкрити читачам. Пакет вихідного коду містить лише `leleka.tex`. [Вимоги arXiv до TeX](https://info.arxiv.org/help/submit_tex.html), [інструкції з подання](https://info.arxiv.org/help/submit/index.html).
+632
View File
@@ -0,0 +1,632 @@
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[letterpaper,margin=0.95in]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage[hidelinks]{hyperref}
\urlstyle{same}
\setlength{\emergencystretch}{2em}
\title{Leleka: Model Compression and Session Multiplexing\\
for Long-Context Coding Agents on One GPU}
\author{Pavlo Ratushnyi}
\date{November 2026}
\begin{document}
\maketitle
\begin{abstract}
Leleka serves long-context coding agents on one RTX 5090. It
integrates Koference's nested bit-plane encoding with a verified
sparse archive view for a 51.2-billion-weight n-gram embedding table.
The view preserves file offsets and materializes only the pages
covering the serving path's reads. Level-2 KAR reduces the per-layer
embedding (PLE) representation from 28.8 to 16.0~GB relative to GGUF.
Separately, sparse materialization reclaims 36.6~GiB relative to a
full copy of the same KAR archive, with bitwise agreement on recorded
output traces. The KAR--GGUF comparison changes 4.27\% of teacher-forced
argmaxes against 1.50--1.87\% across same-encoding runs.
Leleka multiplexes sessions at request boundaries using
reference-counted attention blocks and checkpoints of recurrent,
embedding-history and speculative draft state on a common prefill
grid. It imports only blocks absent from the live slot and ranks
checkpoints by marginal prefill savings per reclaimable byte. On 96
synthetic requests from four interleaved sessions, p95 time to first
token falls from 27.6 to 5.5~s against a single-active-history cache.
Returning sessions at about 180k tokens see 2.72--4.76~s versus
53.1--53.7~s, with agreement on tested greedy continuations against a
full read on the same grid. A live Codex run records a 29~ms median
state import on session switches and a 51~s maximum queue wait.
\end{abstract}
\section{Introduction}
Coding agents repeatedly send histories of source files, model replies
and tool results. Interleaving requests can overwrite a reusable
history when the engine keeps one active slot. For a hybrid model,
each reused prefix needs its matching recurrent state as well as
attention data.
Leleka serves Qwen3.8-Flash-Next IQ3\_S in one active slot with a
262,144-token context limit. It inherits Strata's quantized experts,
attention-cache streaming, multi-token prediction (MTP), and sparse
PLE lookup \cite{strata,leleka}. Strata supports conversation parking,
and prior work compresses this same Qwen table \cite{strata,twobitngram}.
Leleka adds two serving mechanisms.
\begin{enumerate}
\item \textbf{Verified sparse loading of KAR.} Leleka converts GGUF to
Koference's KAR with bounded memory \cite{koference} and stages
packed PLE rows for CUDA reconstruction. Its sealed memory file
preserves offsets and contains only verified ranges used in
serving. We measure re-encoding and sparse loading separately.
\item \textbf{Single-slot restoration of hybrid model state.} Sessions
share attention and index blocks and checkpoint recurrent, PLE
and MTP state on the same grid as cold prefill. Leleka imports
missing blocks into the live slot and scores eviction by marginal
prefill work per byte actually released. We check greedy output
agreement and measure both state import and queue latency.
\end{enumerate}
\section{Weight encoding and selective materialization}
\label{sec:encoding}
\paragraph{Koference encoding and the Leleka converter.}
KAR-2 is the container version used in the Koference reference
\cite{koference}. A quantization \emph{level} is the number of bit planes
read for a tensor. Leleka ports the offline encoder and range decoder.
For a group of $g$ source weights, it rounds the maximum absolute weight
to an FP16 scale $s$ and uses a small positive scale for an all-zero group.
It fits a tree of scalar partitions to a sample of the normalized weights.
At each depth it splits each parent cell at a boundary minimizing the
sum of squared errors of the two child cells. The reconstruction value
for a cell is its sample mean rounded to FP16. The encoder stores the
leaf index most-significant plane first. Reading the first $\ell$ planes
selects an ancestor cell and reconstructs $\hat{w}_i^{(\ell)}$ as
\[
\hat{w}_i^{(\ell)} =
s_{\lfloor i/g \rfloor}\,
c_\ell\!\left[\sum_{j=0}^{\ell-1} 2^{\ell-1-j} b_j(i)\right],
\]
where $c_\ell$ is the table of $2^\ell$ reconstruction values, and $b_j(i)$
is the bit for weight $i$ in plane $j$. Ignoring padding, codebooks and
metadata, the encoding costs $\ell + 16/g$ bits per weight. The serving
experiment uses $\ell=2$ and $g=32$ throughout the PLE table. The streamed
converter reads bounded GGUF chunks, samples at most 65,536 normalized
values per tensor or partition, and writes per-tensor sections. It splits
the PLE tensor at row boundaries to respect the container's 32-bit plane
stride. The converter hashes the physical GGUF data and the decoded FP32
stream without writing that expanded stream to disk. It verifies the
archive and its tensor checksums.
\paragraph{Random access in the PLE table.}
The evaluated level-2 table has 320,001,536 rows of 160 weights, stored
in two partitions. Each row needs 10 bytes of scales and two 20-byte
plane slices, for 50 bytes per row or 2.5 bits per weight. The native
IQ4\_NL GGUF PLE table uses 90 bytes per row. The CUDA-serving path
stages the packed rows selected by the PLE lookup, maintains a bounded
device row cache, and gathers and reconstructs rows on the device.
The routed experts in both serving arms come from the same native
quantized GGUF bank. The full KAR archive is also measured as an offline
artifact, which establishes a storage rate for that encoding.
\paragraph{Verified sparse archive view.}
The loader derives the union of the metadata and all codebook, scale
and bit-plane ranges reachable by any legal PLE row lookup. It rounds
that union to page boundaries and merges the resulting extents. The
loader copies only those extents into a sealed Linux memory file
(\texttt{memfd}) of the original length. The engine can therefore
use the archive's existing offsets and row decoder. The sparse
verifier derives the same extents, checks that they cover all allowed
reads, and validates a pinned SHA-256 digest that binds their lengths,
offsets and bytes. The residency guard uses the verified extent list.
Direct I/O avoids a second copy in the disk page cache, and the memory
governor locks and repopulates only the copied extents. This last detail
matters because populating holes would allocate zero pages. The sparse
view serves the same encoded PLE bytes as the full in-memory KAR archive.
\section{Request-boundary session multiplexing}
\label{sec:mux}
\paragraph{Canonical checkpoints.}
One request owns the execution state from prefill to completion or
cancellation. For a prompt with $n$ tokens, grid-mode prefill ends
chunks on a fixed global token grid, with the final chunk ending at
$n-1$ before the first verification step. Chunk boundaries can affect
floating-point arithmetic. A continuation restored from a grid point
therefore follows the same suffix chunk schedule as a full grid-mode
prefill of that prompt.
The store holds two kinds of records. A shared block holds quantized
attention K/V cells and pooled attention-index rows for one consecutive
token span. A checkpoint holds the model's Gated DeltaNet (GDN)
recurrent state, PLE history, attention-index tails and MTP draft state,
plus references to its blocks. Blocks are indexed by a hash chain over
the token prefix. The runtime compares the token IDs on lookup so a
collision cannot produce a cache hit. In the measured configuration,
shared block data costs 14,208 bytes per token and each checkpoint
carries about 127~MB of additional state.
\paragraph{Restoring into one slot.}
The runtime uses the deepest matching checkpoint at or before $n-1$.
It tracks the valid leading span of that prefix in the live slot,
skips its complete blocks, and imports the remaining blocks up to the
checkpoint. The restore refreshes
the device attention index, invalidates stale resident K/V entries, and
installs the recurrent, embedding and draft state before prefilling the
suffix. A continuing session can reuse the live K/V without copying it.
The engine publishes completed chunks and discards an invalid cache on
restore failure so it can read the full prompt again. A separate
request-end mode can save the committed reply state with decode-generated
cells. The grid-mode equality results apply to prefills on the same grid.
\paragraph{Eviction under a shared byte cap.}
Under a byte cap, the policy ranks each candidate for eviction by a
heuristic
\[
\frac{p_v\,(\ell_v-\ell_{\mathrm{ancestor}(v)})}{m_{\mathrm{freed}}(v)}.
\]
Here $\ell_v$ is the length of the node's prefix,
$\ell_{\mathrm{ancestor}(v)}$ is that of its nearest surviving ancestor,
$p_v$ incorporates recency, evidence of branch reuse and a prior for
session frontiers, and $m_{\mathrm{freed}}(v)$ counts the checkpoint
and any blocks that would lose their last reference, excluding blocks
needed by the incoming checkpoint. After selecting a victim, the policy
recomputes both the fallback ancestor and the reclaimable bytes for the
remaining candidates. Thus the score reflects work that the next
eviction would add and memory it would free in the shared host store.
\section{Evaluation}
The experiments use one RTX 5090 (32~GB) and a Ryzen 9 9950X3D host
with approximately 121~GiB of usable RAM. We compare KAR against native
GGUF PLE inside the same runtime, sparse against full materialization of
identical KAR bytes, and grid checkpointing against a legacy
single-active-history policy. A live gateway smoke test exercises three
Codex sessions. The appendix gives the software and model
identities available from the measurement records \cite{leleka}. GB
denotes $10^9$ bytes and GiB denotes $2^{30}$ bytes.
\subsection{Size and numerical cost of compression}
\begin{table}[ht]
\centering
\small
\begin{tabular}{@{}lrrr@{}}
\toprule
Comparison & Reference & KAR or sparse & Reduction \\
\midrule
Complete source shards vs.\ level-2 archive (GB) & 83.618 & 55.296 & 33.87\% \\
GGUF vs.\ level-2 PLE representation (GB) & 28.800 & 16.000 & 44.44\% \\
Full vs.\ sparse KAR memory file (GiB) & 51.50 & 14.90 & 36.60 GiB \\
\bottomrule
\end{tabular}
\caption{Three byte comparisons at different boundaries. The first
measures offline conversion. The second measures the serving table.
The third measures allocated archive pages at the same encoding.}
\label{tab:size}
\end{table}
The complete level-2 archive contains 1,225 records at an accounted
2.500025 bits per source weight (Table~\ref{tab:size}). The largest
per-tensor relative $\ell_2$ reconstruction error is 0.6801. A separate
57.64~MB sample containing expert and embedding slices illustrates
the rate--distortion trade-off. Level 2 produces 36.97~MB with a maximum
relative $\ell_2$ error of 0.334. Level 3 produces 51.76~MB with error
0.160. These errors are relative to decoded source GGUF weights. For
serving, the sparse view copies 16,000,348,672 bytes of the level-2
archive in two extents.
In the paired sparse/full comparison, six balanced blocks use the same
five-turn, roughly 245k-token workload. At the end of turn five,
system \texttt{Shmem} is 55.2~GiB with the full archive and 18.6~GiB
with the sparse view, and \texttt{MemAvailable} rises from 8.5 to
45.1~GiB. The output check compares 2,057 top-16 log-probability rows
and 1,036 draft-trace entries with bitwise agreement. The measured
decode-rate difference is $+0.58\%$ (standard error 0.91 percentage
points).
\begin{table}[ht]
\centering
\small
\begin{tabular}{@{}lrr@{}}
\toprule
Replay metric & GGUF PLE & KAR level-2 PLE \\
\midrule
Prefill (tokens/s) & $3{,}741 \pm 5$ & $4{,}206 \pm 28$ \\
Decode (tokens/s) & $181.6 \pm 0.8$ & $180.5 \pm 1.2$ \\
Per-request prefill p10/p50/p90 & 1,394 / 2,366 / 4,717 & 1,440 / 2,560 / 5,449 \\
Per-request decode p10/p50/p90 & 149.5 / 170.3 / 209.0 & 140.9 / 167.8 / 207.6 \\
\bottomrule
\end{tabular}
\caption{Paired replay with 59 fixed requests and three interleaved
passes per arm. Aggregate rates are pass means $\pm$ sample standard
deviation. Per-request prefill percentiles use requests with at least
1,000 uncached tokens and decode percentiles use requests with at
least 100 generated tokens.}
\label{tab:replay}
\end{table}
Table~\ref{tab:replay} holds the request sequence fixed across arms.
The prefix store starts empty for each pass, both PLE tables are in
host memory, and each pass processes 555,449 uncached prompt tokens.
KAR increases prefill tokens/s by 12.4\% relative to GGUF, or about
16.5 seconds less prefill across the trace. With three paired passes,
the descriptive 95\% $t$ interval for the prefill difference is roughly
$[383,547]$ tokens/s and that for the decode difference is
$[-3.8,1.6]$ tokens/s, calculated from the rounded paired summaries.
The sample comes from a single boot. The arms generate their own replies
without feeding them into subsequent prompts, so total decode times
reflect different output token counts.
\begin{table}[ht]
\centering
\small
\begin{tabular}{@{}lrrrr@{}}
\toprule
PLE comparison & Top-1 $\lvert\Delta\log p\rvert$ p99
& Argmax flips & Margin $\geq 0.25$ & Top-5 overlap \\
\midrule
GGUF vs.\ GGUF & 0.162 & 56 (1.87\%) & 5 & 0.967 \\
KAR vs.\ KAR & 0.146 & 45 (1.50\%) & 3 & 0.968 \\
KAR vs.\ GGUF & 0.468 & 128 (4.27\%) & 44 & 0.919 \\
\bottomrule
\end{tabular}
\caption{Teacher-forced numerical comparison at 3,000 positions per
arm. Top-1 change measures the reference argmax's log-probability
where it is present in both traces. The margin column counts flips
where the reference top two tokens differ by at least 0.25 nats.}
\label{tab:quality}
\end{table}
The teacher-forced experiment uses two recorded 300-token continuations
at each of five prompt lengths from 45,766 to 242,849 tokens. It uses
repeated same-source runs to estimate the numerical variation of this
configuration. The cross-encoding comparison exceeds the same-source
variation (Table~\ref{tab:quality}). The two other cross-encoding
pairings give 4.20\% and 4.70\% argmax flips. In a separate live
comparison, two coding tasks with three runs per encoding give 12
completions. All pass the final static acceptance checks, including
re-scoring both arms after a shared acceptance-check correction.
Browser probes identify a restart-button defect in one KAR-generated
solution and inconclusive interaction failures in two others. This
small task sample leaves the impact on agent quality unresolved.
\subsection{Interleaved session latency}
\begin{table}[ht]
\centering
\small
\begin{tabular}{@{}lrr@{}}
\toprule
Four-session trace metric & Legacy & Shared prefix store \\
\midrule
Prompt tokens reused & 580,618 (26.5\%) & 1,927,168 (88.0\%) \\
Prompt tokens processed anew & 1,608,955 & 262,405 \\
TTFT mean / p50 (s) & 12.5 / 11.3 & 2.5 / 1.7 \\
TTFT p95 / max (s) & 27.6 / 27.6 & 5.5 / 5.8 \\
Sum of per-request TTFT (s) & 1,200 & 244 \\
\bottomrule
\end{tabular}
\caption{A seeded synthetic coding-agent workload of 24 requests
per session. TTFT is time to first token. The sum aggregates request
latencies across the trace.}
\label{tab:short}
\end{table}
The four-session test models interleaved coding histories with
heavy-tailed tool outputs. Each session grows from roughly 3k to 40k
tokens and shares about 2.5k initial tokens with the other sessions.
Both modes use the same workload generator and serve one request at a
time. The legacy arm uses the port's single-active-history cache with
conversation parking unavailable in that arm. It loses the private
active history when another session overwrites it. The shared store retains reusable blocks on a
2,048-token grid within a 7.8~GiB cap. On the 96 requests covering
2,189,573 prompt tokens, the store reduces p95 TTFT by a factor of 5.0
(Table~\ref{tab:short}). The experiment is one recorded run per policy.
Re-running the last request of each session with cache lookup and
insertion bypassed reproduces all four tested greedy token sequences.
\begin{table}[ht]
\centering
\small
\begin{tabular}{@{}lrrrr@{}}
\toprule
Prompt tokens / turn & Legacy TTFT (s) & Grid TTFT (s)
& Grid reuse & Import (ms) \\
\midrule
103,051 / 2 & 28.1--28.2 & 2.33 & 98,304 & 101 \\
106,082 / 3 & 28.6 & 2.79 & 98,304 & 101 \\
183,051 / 2 & 53.1 & 4.76 & 172,032 & 175--177 \\
186,082 / 3 & 53.6--53.7 & 2.72 & 180,224 & 182--194 \\
\bottomrule
\end{tabular}
\caption{Returning requests for two alternating sessions at each
context scale, on an 8,192-token grid. Ranges cover sessions A and B.
Import time is a component of the request, separate from suffix prefill.}
\label{tab:long}
\end{table}
In the long-context experiment, two sessions alternate for three turns.
They share about 8k tokens and add about 3k per turn. Each session's
first request is cold in grid mode because the shared prefix is shorter
than one grid block. For returning requests, the legacy policy reuses
7,998 tokens, whereas the new policy restores up to 180,224 tokens.
Table~\ref{tab:long} shows an 11.2--19.7$\times$ TTFT ratio at the
180k scale. End-of-third-turn greedy outputs match the cache-bypassed
full grid prefill for both sessions at both depths. Cancellation during
prefill and decode was exercised at 100k, with agreement on retry.
\subsection{Live gateway and queueing}
In a Codex CLI smoke test, an orchestrator and two workers share the
same engine while implementing a web application. Of 122 requests, 44
overlap another at the gateway and 48 switch the engine's live session.
The median import time on a switch is 29~ms (max 48~ms), and 98.1\% of
prompt tokens are reused. The p90 queue wait is 5.0~s and the maximum
is 51~s. All 122 responses complete and all 161 function calls pass
the recorded name and argument checks. The task takes 791~s, compared
with 766~s for a same-boot single-agent run. Each arm has one trial and
uses a different agent trajectory (127,288 versus 96,647 output tokens).
This is evidence of working session alternation and a measurement of
head-of-line blocking. The effect on time to task completion remains
uncertain.
\section{Related work}
\paragraph{Progressive weights and sparse lookup.}
Any-Precision LLM, Matryoshka Quantization, AnyBCQ and MatGPTQ support
multiple precisions from one set of weights
\cite{anyprecision,matquant,anybcq,matgptq}. MatMoE varies the precision
of routed experts \cite{matmoe}. In particular, non-uniform Any-Precision
also refines clusters and uses a codebook at each bit width
\cite{anyprecision,matgptq}. KAR's grouping and scalar split rule come
from Koference. Leleka serves PLE at a fixed precision in the evaluated
profile, with the same Strata-derived expert path in both arms
\cite{strata,fiddler}.
Engram uses token-derived n-gram lookups that support host placement
and prefetch \cite{engram}. Strata reads selected rows from the native
IQ4\_NL table of the same Qwen model \cite{strata}. The closest
quantization comparison is Han et al.'s Conditional Program (CP),
which uses Gaussian trellis codes and independently decodable rows.
Their Qwen3.8-Flash-Next evaluation reports 13.4~GB at a two-bit code
rate and 10.2~GB at a 1.5-bit code rate, including scale overhead.
Their serving tests use DeepSeek on four or eight H200 GPUs
\cite{twobitngram}. SlackTier evaluates lookup scheduling and tier
placement by prefetch deadlines \cite{slacktier}. Leleka's deployment
contribution is a KAR loader that materializes and verifies the
reachable pages of a larger archive, preserves offsets for the
existing row reader, and serves those rows from host RAM on one GPU.
Comparing CP and KAR on the same runtime, weight source and request
trace remains open.
\paragraph{Prefix reuse and recurrent checkpoints.}
PagedAttention enables block-granular sharing, vLLM's automatic prefix
cache uses parent hashes and reference counts, and SGLang and
CachedAttention reuse prefixes across requests \cite{pagedattention,
vllmhash,sglang,cachedattention}. SGLang's hybrid cache stores K/V and
recurrent checkpoints with separate replacement lists, and its
scheduler supports aligning chunks to a recurrent checkpoint grid
\cite{sglanghybrid,sglanggrid}. Sparse Prefix Caching studies exact
resume from selected recurrent states and optimizes their placement
from a distribution of prefix overlaps \cite{sparseprefix}. The grid
in Leleka serves a particular role in the port: it ties cache
checkpoints to the floating-point chunk schedule while the saved state
also includes the attention-index tails, embedding history and MTP ring.
Marconi combines recency and compute saved per footprint
\cite{marconi}. HiState also accounts for reclaimed storage and added
recomputation, using adaptive checkpoint spacing and separate SSD
storage for historical states \cite{histate}. Leleka implements an
online score for its shared host store in which token savings are
measured relative to the nearest surviving ancestor and memory savings
depend on block references after each tentative eviction. Upstream
Strata parks conversation images in host RAM, lets another conversation
borrow a checkpoint, and offers optional batched generation
\cite{strata}. Leleka's design shares individual prefix blocks among
checkpoints and restores the missing portion into one live slot.
The measured latency comparison uses the port's single-active-history
control. Relative performance against Strata's parking or batching and
other hybrid caches remains an empirical question.
\section{Discussion and conclusion}
The two contributions address different parts of the serving state.
The verified sparse loader keeps the compressed PLE path intact while
removing the resident archive pages that the model never reads.
The session store retains shared attention blocks and coupled model
checkpoints so returning requests can resume in the same slot.
The two mechanisms share the host memory budget. Measuring their joint
effect would require varying both factors on the same workload.
The data cover one model and one primary GPU, mostly greedy inference,
two coding tasks for the PLE comparison, and one live orchestration
trial. Exact grid-resume checks compare short greedy continuations
against a full read on the same grid. The configured 256k capacity,
approximately 245k compression replay and 180k interleaved workload
measure different operating points. The strongest demonstrated benefits
are reduced host residency and time to first token for returning
sessions, while the live trial identifies queueing as a separate limit
on interactive performance.
\appendix
\section{Experiment provenance}
\begin{table}[!ht]
\centering
\small
\setlength{\tabcolsep}{4pt}
\begin{tabular}{@{}ll@{}}
\toprule
Item & Git SHA or SHA-256 \\
\midrule
Leleka snapshot & \texttt{5db2a5da3d8230764201efa7a8994601df974e47} \\
Strata reference & \texttt{41cf05a06a25dd29103b7b27a2279a3f60c21876} \\
Koference codec & \texttt{806d2398ae1daaceb2917242911e5680cbfb3608} \\
GGUF model pair & \texttt{80d5e3333801cedbca81a5c19c24ed6bb48fd56977acd190318f66b23a1766a3} \\
KAR archive & \texttt{536d612ca60eab460cb978f51748fc6fa4e9d611d4601e777884e8b51385afa5} \\
\bottomrule
\end{tabular}
\caption{Source and artifact identifiers. The experiment descriptions
give the builds used for each comparison.}
\label{tab:revisions}
\end{table}
\small
\begin{description}
\item[Source history.] The source revisions and weight digests are
listed in Table~\ref{tab:revisions}. The local Strata import and patch
set are documented in \path{docs/upstream.md}.
\item[Weights.] The model-pair SHA-256 is the identity recorded by the
KAR/GGUF PLE comparison. The records and aggregate results are listed in
\path{docs/build-validation.md}, \path{docs/kar-sparse-memfd.md}
and the release checklist (\texttt{Q12}, \texttt{A6}).
\item[Sparse/full comparison.] The three-arm harness
\path{scripts/e2e/decode/single-copy-ab.sh} compares the pre-change
full copy, sparse copy and file-backed source in balanced order.
The full/sparse results here use a fixed five-turn corpus, a
300-token output cap, an 8,192-token grid, a 6,144~MiB prefix cap,
disabled placement seeding and the same resident GGUF expert bank.
\item[KAR/GGUF A/B.] Same rebuilt release package in both arms, based
on \texttt{17e372944279} with opt-in native PLE changes and
results in \path{docs/experiments/kar-off-ab-5090.md}
(evidence commits \texttt{740d84113}, \texttt{5cc2257ea}).
Ubuntu 26.04, Linux 7.0.0-38, CUDA toolkit 13.2.2,
cuBLAS 12.9.1.4, NVIDIA driver 595.99.02 and Codex CLI 0.163.0.
The server release record lists a 600~W GPU power limit.
The replay uses INT8 K/V, request-end checkpoints and a 6,144~MiB
prefix cap. Serialized pass order is KAR, GGUF, GGUF, KAR, KAR, GGUF.
GGUF PLE is prewarmed in the page cache and KAR PLE uses a sparse
sealed memory file. The paired numerical check uses a static expert
tier. Aggregate tables and analysis are under
\path{docs/e2e-data/kar-off-ab/}.
\item[Session-cache controlled tests.] Generator introduced in
\texttt{d53db650f}, policy introduced in \texttt{8ad4dd5d7}.
Jobs 923 and 927 are the legacy and grid-cache four-session runs.
\path{docs/prefix-cache.md} sections 2 and 3 report the four-session
and alternating long-context results. The harness uses greedy decoding,
16--24 tokens for the reported equality checks, MTP, static expert
placement with seeding disabled, INT8 K/V and a 20,480-token
GPU-resident K/V window. The driver series is 595.99 and the
model shard 0 digest begins \texttt{4c1eb2ce}. The workloads are
synthetic and run the real model.
\item[Live smoke.] Package commit \texttt{83bdd85bb482} with Codex CLI
0.163.0. Report and harness are recorded in \texttt{b54e334a8} and
\texttt{7d580590d}, respectively. The warm-up precedes both task
cells. Raw request captures and weights are outside the paper
source package.
\end{description}
\normalsize
\begin{thebibliography}{99}
\bibitem{strata}
Strata project.
\href{https://github.com/Niko1221/Strata/blob/41cf05a06a25dd29103b7b27a2279a3f60c21876/docs/DETAILS.md}{\emph{Strata -- the details}}.
Engine documentation at \texttt{41cf05a0}, October 2026.
\bibitem{leleka}
Leleka project. \emph{Leleka source and measurement records}. Repository
snapshot \texttt{5db2a5da3}, 2026. Evidence paths in Appendix~A.
\bibitem{koference}
Koference project. \emph{KAR v2 format specification and reference
decoder}. Revision \texttt{806d2398}, local research source. Reference
decoder provenance is recorded in Leleka's \path{gpu/kar/README.md}.
\bibitem{anyprecision}
Yeonhong Park et al.
\emph{Any-Precision LLM: Low-Cost Deployment of Multiple,
Different-Sized LLMs}. ICML, 2024.
\url{https://arxiv.org/abs/2402.10517}.
\bibitem{matquant}
Pranav Nair et al. \emph{Matryoshka Quantization}. 2025.
\url{https://arxiv.org/abs/2502.06786}.
\bibitem{anybcq}
Gunho Park et al. \emph{AnyBCQ: Hardware Efficient Flexible
Binary-Coded Quantization for Multi-Precision LLMs}. 2026.
\url{https://arxiv.org/abs/2510.10467}.
\bibitem{matgptq}
Maximilian Kleinegger, Elvir Crn\v{c}evi\'c, and Dan Alistarh.
\emph{MatGPTQ: Efficient and Accurate Inference over Nested
Quantized Models}. 2026. \url{https://arxiv.org/abs/2602.03537}.
\bibitem{matmoe}
Renjie Wei et al. \emph{MatMoE: Matryoshka Mixture-of-Experts with
Dynamic Mixed-Precision Quantization for Efficient Inference}. 2026.
\url{https://arxiv.org/abs/2611.01704}.
\bibitem{fiddler}
Keisuke Kamahori et al.
\emph{Fiddler: CPU-GPU Orchestration for Fast Inference of
Mixture-of-Experts Models}. ICLR, 2025.
\url{https://arxiv.org/abs/2402.07033}.
\bibitem{engram}
Xin Cheng et al. \emph{Conditional Memory via Scalable Lookup:
A New Axis of Sparsity for Large Language Models}. 2026.
\url{https://arxiv.org/abs/2601.07372}.
\bibitem{twobitngram}
Donghoon Han, Minseop Jung, Dong Woo Kwak, SeungJae Lee, and
Junhoo Lee. \emph{N-Gram Memories at Two Bits: Quantizing Lookup Tables
in Large Language Models}. 2026.
\url{https://arxiv.org/abs/2610.21810v3}.
\bibitem{slacktier}
Wen Huang and Jack Liu. \emph{Placing LLM Lookup Tables by Per-Layer
Prefetch Deadlines}. 2026. \url{https://arxiv.org/abs/2611.13413}.
\bibitem{pagedattention}
Woosuk Kwon et al. \emph{Efficient Memory Management for Large Language
Model Serving with PagedAttention}. SOSP, 2023.
\url{https://arxiv.org/abs/2309.06180}.
\bibitem{vllmhash}
vLLM project. \emph{Automatic Prefix Caching}. Design documentation,
v0.15.0. \url{https://docs.vllm.ai/en/v0.15.0/design/prefix_caching/}.
\bibitem{sglang}
Lianmin Zheng et al. \emph{SGLang: Efficient Execution of Structured
Language Model Programs}. NeurIPS, 2024.
\url{https://arxiv.org/abs/2312.07104}.
\bibitem{sglanghybrid}
SGLang project.
\href{https://pytorch.org/blog/hybrid-models-meet-sglang-more-than-full-attention/}{%
\emph{Hybrid Models Meet SGLang: More than Full Attention}}.
PyTorch Foundation technical article.
\bibitem{sglanggrid}
SGLang project.
\href{https://github.com/sgl-project/sglang/blob/99e4233f633a9835987308e6f0a7fb262fc34d62/python/sglang/srt/managers/schedule_policy.py}{%
\emph{Prefill scheduler and recurrent checkpoint alignment}}.
Source code at \texttt{99e4233f}, November 2026.
\bibitem{cachedattention}
Bin Gao et al. \emph{Cost-Efficient Large Language Model Serving for
Multi-turn Conversations with CachedAttention}. USENIX ATC, 2024.
\url{https://www.usenix.org/conference/atc24/presentation/gao-bin-cost}.
\bibitem{marconi}
Rui Pan et al. \emph{Marconi: Prefix Caching for the Era of Hybrid
LLMs}. MLSys, 2025. \url{https://arxiv.org/abs/2411.19379}.
\bibitem{sparseprefix}
Mikhail Shirokikh and Sergey Nikolenko.
\emph{Sparse Prefix Caching for Hybrid and Recurrent LLM Serving}.
2026. \url{https://arxiv.org/abs/2605.05219}.
\bibitem{histate}
Zaifeng Pan et al. \emph{HiState: Hierarchical Prefix Cache Management
for Hybrid LLM Serving in Agentic Workloads}. 2026.
\url{https://arxiv.org/abs/2610.41508}.
\end{thebibliography}
\end{document}