Files
leleka/docs/windows.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 4df5f3dcf0 docs, check-local: experimental ports re-synced to Strata 41cf05a0; literal_port is a hard gate again
* docs/experiments/2026-10-14-experimental-modes-port.md: "Re-sync" section (what drifted per program, what was done, verification,
  the stale-PTX gate, the server-side reseal list and steps, open items found on the way: remote experts host code, K8V4 streaming,
  multi-token append entries).
* scripts/check-local.sh: --fast no longer skips `_bodies_are_literal` and no longer carries literal_port as debt.
* docs/ci-audit.md (findings 4, 5 and the "what changed" note) and docs/windows.md: literal_port closed, minimal edits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 02:27:51 +01:00

72 KiB

Leleka on Windows 11 (RTX 3080 Laptop 16 GB)

Branch claude/windows. Two routes, both started by the same leleka.exe:

  • Route A, the WSL2 bridge. The engine runs inside WSL2 exactly as docs/laptop-profile.md and docs/deploy.md describe; leleka.exe is the Windows front end: it starts the Linux leleka through wsl.exe, translates paths, checks %UserProfile%\.wslconfig, and reads status / sends reconfigure / stops the service from Windows over the loopback HTTP that WSL2 forwards.
  • Route B, the native engine. No WSL: leleka-inference.exe (engine), leleka-daemon.exe (gateway) and strata-next.exe (API) run as Windows processes under leleka.exe run. The Windows primitives replace the Linux ones: nvcuda.dll for libcuda.so.1, read-only file mappings for mmap, VirtualLock for mlock, GlobalMemoryStatusEx / GetProcessMemoryInfo for /proc, Ctrl-C and a stop file for signals.

No performance claim is made anywhere in this document; nothing here has a quality gate beyond what the Linux path has.

What works and what does not (honest state)

Milestone State Evidence
A. WSL2 bridge, real Works with the model (2026-10-25): up to ready, one request, status, reconfigure --prefix-cache-tail prompt, a second request, down section "Measured on this laptop"
B. native engine, real Works with the model (2026-10-25): staged volume, pins verified, up --native --foreground to ready (engine load 80-128 s), requests answered, status, reconfigure, down. Needed two fixes (MTP ranged reads, child shutdown), both committed section "Measured on this laptop"
Whole tree builds and tests natively leleka-deploy 116 unit + 2 Windows end-to-end + 5 recipe tests, control-plane, leleka-runtime, strata-desktop-core, leleka-memory, leleka-model-format and the rest of the workspace pass. Failures, also on Linux: arch_ptx (chain_window.ptx has no sm_86 record). experimental-ref literal_port (4 tests, kernel sources moved with the upstream sync) passes again since the 2026-11-03 re-sync cargo test --workspace on Windows; Linux cargo check --release --workspace --tests and cargo test -p leleka-deploy --features test-fakes in WSL
native supervisor, test doubles start, readiness, status, reconfigure (HTTP and engine restart), Ctrl-Break drain, stop-file shutdown crates/deploy/tests/e2e_windows.rs
leleka service (Task Scheduler / user unit) Task XML generated, unit-tested and reviewed from service install --dry-run on this machine; never registered (not authorized) service.rs tests
stage-model.ps1, fetch-cublas.ps1 Both run for real: the cuBLAS download (524 MiB, 18 s) matched the SHA-256 pin; the staging copied 138 GB in 614 s; the refusal path of fetch-cublas.ps1 was also verified with wrong archives measured section
C. this document updated with the measurements -

Known limits (all of them apply to route B unless stated):

  • Model volume is not built or downloaded on Windows. strata-next model fetch / archive preparation / service-install are Unix-only. Prepare the shards, the KAR archive, the MTP pack and the expert profile on the WSL disk (or copy a finished volume), then copy them to a Windows disk (section "Model files").
  • Only the file-backed form: the profile must be rtx3080-16g (kar_source=file, expert_source=mapped). The sealed-memfd form (55 GB in RAM) and the 50 GB resident expert copy do not exist on Windows; rtx5090-32g is refused by the preflight.
  • cuBLAS 12 DLLs: leleka up never downloads them; scripts\windows\fetch-cublas.ps1 does, when you run it, with a SHA-256 pin.
  • No systemd on Windows: --mode system/user are refused; the service runs in the terminal that started it (--foreground, the default); closing that terminal stops it. leleka service install (Task Scheduler, at logon, hidden, restart on failure) removes that limit. It is not a Windows Service: it runs while the user is logged on.
  • Memory governor on Windows: MemAvailable is the available physical memory, swap is commit limit minus RAM, thread count, VmLck/VmPin, cgroup and PSI are unknown (the governor fails closed on unknown figures that it needs). RLIMIT_MEMLOCK is reported as unlimited, so VirtualLock and the working-set quota decide; the laptop profile has lock: off.
  • The key file (api-key) and runtime.env have no mode bits on Windows: they inherit the ACL of their folder. The defaults are under %LOCALAPPDATA%\leleka (other users cannot read it). Do not point --state-dir at a shared folder.
  • CPU expf/powf come from the Windows C runtime instead of glibc: last-bit differences in the CPU SiLU / RoPE theta are possible and were not measured. Compare greedy output against the Linux run before trusting numbers (the charter's rule for non-lossy changes).
  • arch_ptx::every_sealed_sm120_file_has_a_companion_or_a_documented_reason fails on Linux and Windows alike (chain_window.ptx has no sm_86 companion record); on the 3080 that PTX loads as sm_120 code. Pre-existing, not touched here.
  • GPU safety (project-laptop-gpu-freeze-bsod): the laptop took 0x19C BSODs under long GPU load in the OEM 30 W profile. Run nvidia-smi -q -d PERFORMANCE,POWER before a long test and prefer the Turbo mode (docs/laptop-profile.md, "Machine state is the dominant variable").

Prerequisites

  • Windows 11, NVIDIA driver >= 595 (this laptop: 617.42). Nothing else from NVIDIA is needed for route A; no CUDA toolkit and no nvcc for either route (every PTX image is sealed in the repository).
  • Rust 1.99 for x86_64-pc-windows-msvc (the repository pins it in rust-toolchain.toml) and the Visual Studio Build Tools (MSVC linker and cl.exe; strata-next compiles a small C bridge).
  • Route A: WSL2 with an Ubuntu distribution that has Rust 1.99 and a C toolchain (gcc), the NVIDIA Windows driver (WSL2 gets the GPU from it), %UserProfile%\.wslconfig with memory=40GB and swap=8GB (what this laptop has; leleka doctor judges it).
  • Route B: the two CUDA 12 cuBLAS DLLs (below).

Build

Windows binaries (leleka.exe and the five native programs)

cd C:\Users\pavel\work\leleka-windows
powershell -ExecutionPolicy Bypass -File scripts\windows\build-release.ps1          # -> dist\bin\*.exe, with the sm86 companions
# only the front end, for route A:
cargo build --release --locked -p leleka-deploy --bin leleka                         # -> target\release\leleka.exe

dist\bin gets leleka.exe, strata-next.exe, leleka-inference.exe, leleka-daemon.exe, leleka-cli.exe and a stub leleka-seal-exec.exe (prints "requires Linux"; nothing runs it). The first full release build takes a while (leleka-inference.exe is ~140 MB).

Linux binaries for route A (inside WSL)

The Linux leleka needs its five sibling programs next to it; build them in WSL from a copy of the tree on the WSL disk (building under /mnt/c works but is slow):

wsl -d Ubuntu -- bash -lc "mkdir -p ~/leleka-src && cd /mnt/c/Users/pavel/work/leleka-windows && git ls-files -co --exclude-standard -z | tar --null -T - -cf - | tar -xf - -C ~/leleka-src"
wsl -d Ubuntu -- bash -lc "cd ~/leleka-src && source ~/.cargo/env && cargo build --release --locked -p strata-desktop-core --features sm86 --bin leleka-inference --bin leleka-daemon --bin leleka-cli --bin leleka-seal-exec && cargo build --release --locked -p strata-control --bin strata-next && cargo build --release --locked -p leleka-deploy --bin leleka"

The result is ~/leleka-src/target/release/ (six programs). leleka.exe finds leleka there (it also looks in ~/.local/share/leleka/bin, ~/leleka/target/release, ~/leleka-bin, ~/.cargo/bin and PATH), or you pass --wsl-bin. (On this laptop an older Linux build is in /home/para/deploy-rel-target/release/; it works for preflight/up --dry-run but predates the laptop strata.json fix below, so rebuild.)

Model files

leleka expects one assets directory:

ASSETS\model\Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf     54,817,524,224 bytes
ASSETS\model\Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf     28,800,138,432 bytes
ASSETS\qwen-iq3-s-l2-v4.kar                                            55,295,529,472 bytes   (at the root, not in model\)
ASSETS\qwen-iq3-s-l2-v4.kar.provenance.json
ASSETS\data\mtp-rt\{dense.bin,dense.txt,draft_vocab.bin,experts.bin}
ASSETS\data\expert-profile.bin                                         (sha256 8f59b4aa...8975baf; the VRAM expert tier; `leleka up` installs the copy embedded in `leleka.exe`, or `--expert-profile-file PATH`)
ASSETS\tokenizer-assets\                                               (made by `up`)

Route A: the volume must be on the WSL ext4 disk (not /mnt/c: 9p is far too slow for mapped reads; leleka.exe refuses --assets under /mnt/<drive>/). This laptop's existing ~/laptop volume has the archive inside model/, and the tools want real regular files at the leleka layout: strata-next model fetch refuses symlinks ("refusing symlink") and the engine admits only a regular, single-link archive, so neither a symlink nor a hard link is a substitute. What was done (nothing in ~/laptop was touched; needs 140 GB free on the WSL disk, 578 GB were):

wsl -d Ubuntu -- bash -lc "A=~/leleka-assets; S=~/laptop; mkdir -p $A/model $A/data && cp --reflink=never $S/model/*.gguf $A/model/ && cp --reflink=never $S/model/qwen-iq3-s-l2-v4.kar $S/model/qwen-iq3-s-l2-v4.kar.provenance.json $A/ && cp --reflink=never -r $S/data/mtp-rt $A/data/ && cp --reflink=never $S/data/expert-profile.bin $A/data/ && chmod 400 $A/qwen-iq3-s-l2-v4.kar && chmod 444 $A/model/*.gguf"

(The two shards took about 7 minutes to copy. If you prefer not to keep two copies, mv the files instead; then ~/laptop no longer works for the older bench scripts.)

Route B: the volume must be on a Windows disk with ~150 GB free (the NVMe on C: or D:). scripts\windows\stage-model.ps1 -Dest D:\leleka-assets copies it from the WSL volume above (about 140 GB over the 9p share; expect tens of minutes), lays it out, and verifies the pins (section "Route B"). By hand, the equivalent copy is:

$src = '\\wsl.localhost\Ubuntu\home\para\leleka-assets'; $dst = 'D:\leleka-assets'
robocopy "$src\model" "$dst\model" *.gguf /J
robocopy $src $dst qwen-iq3-s-l2-v4.kar qwen-iq3-s-l2-v4.kar.provenance.json /J
robocopy "$src\data" "$dst\data" /E /J

(dist\bin etc. are not part of the volume. Nothing of the model goes into Git.)

Route A: WSL2 bridge

cd C:\Users\pavel\work\leleka-windows
$L = "target\release\leleka.exe"          # or dist\bin\leleka.exe
& $L doctor                                # GPU, RAM, .wslconfig advice, distributions, the Linux leleka, DLLs for route B
& $L preflight --assets '\\wsl.localhost\Ubuntu\home\para\leleka-assets' --wsl-bin /home/para/leleka-src/target/release/leleka
& $L up        --assets '\\wsl.localhost\Ubuntu\home\para\leleka-assets' --wsl-bin /home/para/leleka-src/target/release/leleka --trust-archive
  • --assets may be a Linux path (/home/para/leleka-assets), a \\wsl.localhost\Ubuntu\... path or ~/...; Windows paths are translated to /mnt/c/... and refused for --assets. The same translation applies to --state-dir, --prefix, --bin-src, --cublas-dir, --mtp-pack, --expert-profile-file, --profile FILE. --wsl-distro NAME / $env:LELEKA_WSL_DISTRO choose the distribution (default: the default WSL2 one that is not Docker's).
  • up first prints the .wslconfig advice (memory below ~32 GB or no swap), then runs the Linux leleka up with its output forwarded. Without systemd in the distribution it runs in the foreground in this window (Ctrl-C drains and stops); with systemd (this laptop has it) it installs and starts a user unit and returns when /ready answers. Keep a WSL session alive (any open wsl window) so the VM is not shut down while idle. leleka service install automates that (section "Keeping it running without a terminal").
  • --trust-archive accepts the existing archive without the hours-long strict re-derivation (the engine still checks its SHA-256 and every CRC at each load) and makes it read-only, which the file form requires. The first up also verifies the shards (about 3 min with hash reuse; a cold cache is 5-7 min) and unpacks cuBLAS 12.9.1.4 from NVIDIA's pinned redistributable inside WSL (download ~890 MiB; or pass --cublas-dir).
  • When it is ready, leleka.exe prints (and the foreground form prints while up is still running):
Leleka (WSL2 route) is reachable from Windows:
  endpoint   http://127.0.0.1:8081
  api key    \\wsl.localhost\Ubuntu\home\para\.local\state\leleka\api-key   (WSL: /home/para/.local/state/leleka/api-key)
  try        $k=(Get-Content -Raw '...api-key').Trim(); Invoke-RestMethod -Method Post -Uri http://127.0.0.1:8081/v1/responses ...

leleka.exe remembers the distribution, the Linux binary, the state directory and the API address of the last up in %LOCALAPPDATA%\leleka\wsl-bridge.json (no secret in it), so status, reconfigure and down need no flags afterwards.

Route B: native engine

The first command to run on any state of the machine is leleka doctor; it prints what is missing and the one command that fixes the first missing thing (programs, then cuBLAS, then the model volume, in that order):

cd C:\Users\pavel\work\leleka-windows
.\target\release\leleka.exe doctor --assets D:\leleka-assets
#   MISSING  native programs ...   fix: powershell -ExecutionPolicy Bypass -File ...\scripts\windows\build-release.ps1
#   MISSING  CUDA 12 cuBLAS DLLs   fix: powershell -ExecutionPolicy Bypass -File ...\scripts\windows\fetch-cublas.ps1
#   MISSING  model volume          fix: powershell -ExecutionPolicy Bypass -File ...\scripts\windows\stage-model.ps1 -Dest D:\leleka-assets
#   next (native route): <the first of those>      (or `leleka up --native --foreground --assets ...` when nothing is missing)

The steps, in order (each is one command; each can be rerun):

# 1. the five programs -> dist\bin
powershell -ExecutionPolicy Bypass -File scripts\windows\build-release.ps1

# 2. cuBLAS 12 -> %LOCALAPPDATA%\leleka\cublas\bin (found automatically afterwards; no --cublas-dir needed).
#    Downloads libcublas 12.9.1.4 windows-x86_64 (549,755,186 bytes) from NVIDIA with curl.exe and REFUSES (and deletes the file) unless
#    length and SHA-256 equal the pin d534d98b0b453a98914dbf3adf47d7e84b55037abf02f87466439e1dcef581ed (from NVIDIA's own
#    redistrib_12.9.1.json). -ZipPath FILE checks and unpacks an archive you downloaded yourself. The NVIDIA licence in the archive applies.
powershell -ExecutionPolicy Bypass -File scripts\windows\fetch-cublas.ps1

# 3. the model volume: copy from WSL (\\wsl.localhost\Ubuntu\...), lay it out, verify the pins (about 140 GB; tens of minutes + 5-10 min of hashing)
powershell -ExecutionPolicy Bypass -File scripts\windows\stage-model.ps1 -Dest D:\leleka-assets

# 4. start (engine + gateway + API in this window; Ctrl-C drains and stops)
.\dist\bin\leleka.exe up --native --foreground --bin-src dist\bin --assets D:\leleka-assets --trust-archive

stage-model.ps1 reads the volume through the \\wsl.localhost share without changing anything in the distribution (default source ~/leleka-assets, else ~/laptop; both layouts are understood), copies with robocopy (a percentage per file; files that already match are skipped, so an interrupted copy resumes), puts the archive at the volume root, checks that it is a regular single-link file and makes it read-only, then runs leleka.exe up --native --mode none (installs the programs, tokens, tokenizer, configuration; starts nothing) and leleka.exe verify --native (hashes both shards and the archive in full against the pinned digests). Options: -Distro, -Source, -BinSrc, -LelekaExe, -CublasDir, -SkipVerify. It needs steps 1 and 2 first. It was run for real (138 GB, 614 s, layout checks passed); when the output is redirected it passes /NP to robocopy.

What up --native does: preflight with Windows facts (nvidia-smi.exe, GlobalMemoryStatusEx, GetDiskFreeSpaceEx, DLL search for nvcuda.dll / cublas64_12.dll), checks that the two shards and the archive are on the volume with their pinned sizes (it never downloads or builds), installs the five .exe files into %LOCALAPPDATA%\leleka\bin, generates the tokens and the API key (strata-next api-key init), extracts the tokenizer from shard 1, writes leleka.json / daemon.json / strata.json / runtime.env in %LOCALAPPDATA%\leleka\state, and runs the supervisor (leleka.exe run): gateway, engine, typed load-mtp, API, /ready. Logs are in ...\state\logs\{leleka,engine,gateway,api}.log. The cuBLAS directory reaches the engine through LELEKA_DLL_DIRS (the loader flags used by the engine do not search PATH).

If the engine does not come up, read engine.log first; the first thing to check is the load line for nvcuda.dll, then the mapped-expert and archive admission messages.

What was exercised on this laptop without a GPU or a model

crates/deploy/tests/e2e_windows.rs (cargo test -p leleka-deploy --features test-fakes --test e2e_windows, two tests, about 75 s) runs the real leleka.exe run with test doubles named like the four other programs (leleka-fake-runtime.exe, the same double the Linux end-to-end tests use, extended with /v1/status and /v1/reconfigure). Passing on Windows 11:

  • the supervisor starts the gateway, the engine (file-backed archive form, --expert-source mapped), the typed load, the API, and reaches phase ready; /ready and /health answer;
  • leleka status (and --json) reads the status file and the API and prints the engine-load block;
  • leleka reconfigure --context-tokens 4096 --cpu-workers 3 goes over HTTP; leleka reconfigure --gpu-budget-gib 12 goes through the supervisor's request files, restarts only the engine process (new pid, restart counter stays 0, gateway and API pids unchanged);
  • Ctrl-Break sent to the supervisor's console process group drains the API, then the gateway and the engine: exit code 0, phase stopped, engine process gone, API port closed;
  • leleka down from another process (the stop file) does the same; a second down says nothing runs; status then exits 1.

Not covered by it: a real Ctrl-C typed in a console (the handler is the same code path as Ctrl-Break; it cannot be aimed at a new process group from a test), the real engine's own shutdown on Ctrl-C, --hidden, and everything that needs the GPU or the model.

Measured on this laptop (2026-10-25, RTX 3080 Laptop 16 GB in Turbo mode, driver 617.42, 48 GB RAM, WSL2 memory=40GB swap=8GB)

Single runs, no repetitions, no baseline, no quality comparison: these are outcomes of "does it work", not performance claims. Every GPU-active stretch was under 12 minutes, one at a time, with nvidia-smi checked before and a 5 s poll of temperature during (stop at 85 C; for the WSL run also scripts/laptop/monitor.sh on the supervisor). Highest GPU temperature seen: 57 C; no throttling, no P5 under load, power 12-50 W; no instability. Request: POST /v1/responses, the same 59-token prompt ("Name three colors of the rainbow.", chat-templated), thinking on (the model spends its first tokens on reasoning), max_output_tokens 48/64.

Route A (WSL2 bridge, Linux engine) Route B (native Windows engine)
volume ~/leleka-assets on ext4: shards and archive copied (cp, 83 GB + 55 GB; symlinks are refused by strata-next model fetch: "refusing symlink"), MTP pack copied, expert profile copied. ~/laptop untouched C:\leleka\assets, 138 GB copied by stage-model.ps1 in 614 s (about 0.22 GB/s over the 9p share), layout checks passed
pinned digests leleka up --mode none --trust-archive (installs, verifies both shards with strata-next model verify): 600 s cold leleka.exe verify --native: both shards and the archive hashed in parallel in 46 s (the files had just been written, so partly cached)
start to ready leleka.exe up (user unit, stamps current): 266 s wall (engine load not printed separately) leleka.exe up --native --foreground: engine load 127.7 s (first start), 79.9 s (second start, warm file cache); model loaded in 82 s
request 1 59 in / 31 out (22 reasoning): 47.8 s (first request after start) 59 in / 48 out (all reasoning, hit the cap): 18.4 s; run 3: 17.1 s
reconfigure --prefix-cache-tail prompt worked; settings echo shows tail prompt worked, 17.1 s to reopen the serve stack
request 2 59 in / 31 out: 10.2 s 59 in / 57 out (53 reasoning), different prompt: 14.3 s
telemetry (leleka status) idle: VRAM 14.3 of 16.0 GiB, RAM 32.6 of 39.2 GiB available (WSL VM), engine 11.7 GiB resident; after a request: engine 28.3 GiB resident; prefill 2 tok/s, decode 3 tok/s (first request) idle: VRAM 14.3 of 16.0 GiB; after the first request VRAM 14.8, RAM 9.6 of 47.7 GiB available (it was 25.8 at idle), engine 27.6 GiB resident (mapped file pages included), whole system 97 % busy during decode; the prefill/decode lines stayed - (see "Known measurement gaps")
down 2 s (systemctl --user stop) 94 s with the first build (the children were never signalled and each waited out its 30 s grace); 6 s after the fix below
peak (monitor.sh, WSL run) VRAM 14,995 MiB, min MemAvailable 31.9 GB, max 57 C, mean power 23 W -

What broke on the way and what was done (each is a commit on claude/windows with a test where one is possible):

  1. Native load stopped at SelectedBinding / UnsupportedKind after the archive bind and before any CUDA call: the MTP pack's ranged reads (read_exact_range in qwen4exp_mtp.rs) had only a Unix read_exact_at; the Windows arm returned UnsupportedKind. Fixed with seek_read (53a7666). Everything after it loaded: the mapped 83 GB shards (file mappings), the 55 GB archive read through seek_read, nvcuda.dll, the sm_86 PTX companions, the expert tier (13,162 VRAM slots + profile fill), the MTP draft, the serve stack.
  2. leleka down --native took 94 s: the supervisor stopped its children with SIGINT, which does not exist on Windows (interrupt() was a no-op), so each of the API, the gateway and the engine was killed after its 30 s grace. Now the children run in their own process groups and are stopped in order with Ctrl-Break; leleka-inference, leleka-daemon and strata-next handle Ctrl-Break like Ctrl-C (tokio::signal::windows::ctrl_break). down takes 6 s with the real engine; the Windows end-to-end test now asserts it finishes in under 25 s.
  3. leleka up --mode none printed the "reachable from Windows" summary although nothing was started: fixed.
  4. stage-model.ps1: with the output redirected, robocopy wrote a line per percent point (thousands of lines): it adds /NP then.

Findings about this machine that the owner should know:

  • WSL2 and native compete for the same 48 GB. After the Route A run the vmmemWSL process held 22.5 GB of host RAM although the VM reported 38 GB free inside; Windows reported 4.9-9.7 GiB available and the native preflight failed (memory: ... below the 10.0 GiB needed). wsl --shutdown (nothing else was running in the distribution) gave 38 GiB available at once. Do not run both routes at the same time; run wsl --shutdown between them. Right after a large copy the figure can read near 0 for a few seconds (pages being written back); rerun the command.
  • The native engine's RAM: 27 GiB resident at the end of a request, most of it mapped shard pages; Windows available RAM drops to ~10 GiB while it decodes.

Known measurement gaps (not fixed):

  • The telemetry's prefill/decode lines stayed - on the native route (on the WSL route they showed 2 and 3 tok/s). The engine reports them to the gateway, so either the Windows engine's counters are not reaching it or they are filled later; not investigated.
  • status shows memory bus 100% at idle and swap in use 17.8 GiB on Windows: the swap figure is the commit limit minus RAM (an approximation, stated in winproc.rs), the bus figure is NVML's as read through nvml.dll; do not read either as a measurement.
  • The streaming response delivers all text events at the end (first text event time = total time) on both routes; the first-token time therefore cannot be read from the stream.

Keeping it running without a terminal: leleka service

leleka service install     # native: a Task Scheduler task "Leleka": at logon (30 s delay) run `leleka.exe run --config ...\leleka.json --hidden`,
                           #         interactive token of the installing user, least privilege, no time limit, restart up to 3 times a minute apart on failure
leleka service start       # schtasks /Run (starts it now)
leleka service status      # the task (status, last run, last result) and whether the supervisor runs
leleka service stop        # graceful: the stop file, the API drains first (up to 120 s)
leleka service uninstall   # stop, then delete the task
leleka service install --dry-run   # print the task XML and change nothing

--hidden makes leleka.exe hide its console window (the console itself stays, because the supervisor stops its children through it), so no window stays on the desktop; a window can flash for a moment at logon. Prepare the state first (leleka up --native --mode none ... or one foreground up); service install refuses when leleka.json or the installed leleka.exe is missing. Logs are the same files in state\logs. The task runs only while the user is logged on (the GPU needs the interactive desktop session; it is not a Windows Service).

For the WSL route the same commands (--wsl, chosen automatically after a WSL up) do two things: systemctl --user enable|start|stop|disable leleka.service inside the distribution, and a second task Leleka-WSL that runs leleka.exe service hold --wsl-distro NAME --hidden at logon: it starts the unit and keeps a hidden wsl.exe ... sleep infinity open, because WSL2 shuts its VM down when no wsl.exe process is left and the unit would die with it. service install needs the unit file, i.e. one leleka up in a distribution with systemd.

State of this feature: the task XML is generated by tested code (crates/deploy/src/service.rs: well-formed, escaping, quoting, UTF-16 file); no task was registered on this machine and schtasks.exe was not run by me (the owner's constraint); service install --dry-run printed the XML below the line --dry-run: nothing is registered and it was reviewed (user PARA-GAME\pavel, logon trigger with a 30 s delay, leleka.exe run --config ...\leleka.json --hidden, 3 restarts a minute apart). First use: run leleka service install --dry-run, look at the XML, then leleka service install; if schtasks rejects the file the message is printed verbatim. --hidden and hold are untested for the same reason.

Reading leleka status

leleka status (add --json for a machine-readable form; exit code 1 when not ready) prints:

ready: true
supervisor: phase ready (pid 1234), engine restarts 0, updated 2026-10-25T13:00:00Z
engine load (decode):
  gpu      91% busy (memory bus 40%), VRAM 14.1 of 16.0 GiB, 98 W, 1800 MHz
  cpu      6.4 of 16 cores busy in the engine (whole system 52%)
  ram      9.3 of 39.0 GiB available, engine 22.0 GiB resident (0.5 GiB pinned), swap in use 1.2 GiB
  prefill  310 tok/s last, ...
  decode   9 tok/s last, ... average, ... lifetime, ... now
  cache    87% of requests hit, 91% of prompt tokens reused (last request ... of ...)
  context  1200 of 8192 tokens (14.6%)
settings in force:
  context_tokens 8192 ...

The numbers above are the layout, not measurements. phase is the supervisor's state (starting, loading, ready, engine_restarting, draining, stopped, failed). gpu is the engine's GPU as NVML reports it, cpu the engine's busy cores, ram the host figures and the engine's resident / page-locked memory (on Windows these come from Win32 and are approximations; see the limits), prefill/decode tokens per second of the last request, the running average and since start, cache the cross-session prefix cache, context the live tokens against the ceiling. Route A reads the same document from Windows over HTTP; if the distribution is stopped it says so instead of booting it.

leleka reconfigure

Changes the inference settings of the running engine without reloading the model (it reopens its serve stack in tens of seconds; requests wait; a refused value keeps the previous settings; the VRAM budget and the preset need a restart):

leleka reconfigure --context-tokens 8192 --prefill-capacity 2048 --kv-resident 32768
leleka reconfigure --prefix-cache-mib 4096 --prefix-cache-tail reply --cpu-workers 7 --spec-min-p 0.5

All flags: --context-tokens 1..262144, --prefill-capacity 256..8192, --kv-resident N (0 = all, else >= 20480), --prefix-cache-mib auto|off|N, --prefix-cache-tail off|prompt|reply, --prefix-cache-block N, --prefix-retention-min N, --cpu-workers 1..64, --spec-min-p 0..1. On the 16 GB laptop the context is capped by the VRAM left for the KV window; a value that does not fit is refused by the engine, not applied.

Stopping

  • Route A: Ctrl-C in the up window (foreground), or leleka down from any window (stops the user unit if there is one, else sends SIGINT to the supervisor and waits up to 120 s). wsl --shutdown also kills it, but not gracefully.
  • Route B: Ctrl-C in the window, or leleka down --native from another one (a stop file in state\run that the supervisor polls every 0.5 s).

Troubleshooting

Symptom Cause / fix
the Linux leleka was not found in Ubuntu build it in WSL (above) and pass --wsl-bin, or put it in ~/.local/share/leleka/bin
--assets ... is a Windows drive seen from WSL move the volume to the WSL disk (section "Model files")
preflight cuBLAS 12 ... not found (native) scripts\windows\fetch-cublas.ps1 (or --cublas-dir with cublas64_12.dll and cublasLt64_12.dll)
the profile rtx5090-32g holds the archive in a sealed memfd native Windows serves the file form only: --profile rtx3080-16g
step kar is blocked ... must already be on the model volume (native) scripts\windows\stage-model.ps1 -Dest ... (puts the archive and its .provenance.json at the root of the volume); leleka doctor --assets DIR names each missing file
status says ready: false and the distribution is stopped start the service again with leleka up; keep a wsl window open
native up fails the preflight with memory: 0.0 GiB available / below 10 GiB WSL2 still holds the RAM (vmmemWSL): wsl --shutdown, or wait a few seconds after a big copy, then rerun
strata-next model fetch: refusing symlink (WSL volume) the shards must be real files in model/; copy them (cp), do not link them
strata-next doctor fails on Windows ("requires Linux") expected: that check is Linux-only
the API refuses with max_output_tokens fixed on this branch: strata.json now uses min(32768, context-1) (8191 on the laptop); rerun up to rewrite the config

Where the code is

crates/deploy/src/wsl.rs (parsers, path translation, .wslconfig), winfront.rs (the Windows commands and doctor), doctor.rs (what is missing and the fix), service.rs / winservice.rs (leleka service), winsys.rs (Win32 calls), facts.rs (Windows probe), crates/libc-shim (dlopen -> LoadLibrary, mlock -> VirtualLock, read-only file views), crates/leleka-memory/src/winproc.rs (Win32 rendered as /proc text), scripts/windows/build-release.ps1. WSL check used during development: tar the tree with git ls-files -co --exclude-standard, then cargo check --offline --release --workspace --tests and cargo test -p leleka-deploy in WSL.

Native run 2026-10-25 evening (lessons, open fixes)

Run by the assistant on this laptop with WSL stopped (wsl --shutdown), 34.4 GiB of 47.7 GiB free, Chrome and Docker Desktop idle.

  • up --native preflight said "cuBLAS 12 not found" although leleka doctor finds both DLLs in %LOCALAPPDATA%\leleka\cublasin. Workaround that works: --cublas-dir "$env:LOCALAPPDATA\leleka\cublasin". The probe of up and the one of doctor disagree (open: unify them).
  • The engine refused the first start (REFUSING TO START: ... the fixed host footprint (29.44 GiB) leaves 4.83 GiB of 34.26 GiB available, below the 5.00 GiB). The mapped-expert form auto-sizes its page-locked complement to almost all free RAM, which is too greedy on a Windows desktop that also needs its own working set. LELEKA_ORIGINAL_SERVE_RESIDENT_BUDGET_GIB=20 let it start (80 s to ready), but the engine then held 31-32 GiB, Windows had 0.6-0.8 GiB available and 14 GiB of swap in use. (Open: the Windows planner must set memory.resident_budget_gib itself from the free RAM minus about 15 GiB for the desktop; closing the browser helps.)
  • A request worked (59 tokens in, 48 out, 19 s, incomplete at the 48-token cap) and leleka status showed the engine telemetry (GPU 79 % busy, VRAM 14.8 GiB, 13 of 16 cores, RAM 0.6 GiB available, prefill/decode rates once the request has finished). Short requests on the 3080 are neither efficient nor representative (owner): the numbers of this laptop must come from agent-sized contexts, not from one-liners.
  • leleka reconfigure --prefix-cache-tail prompt on this memory-starved host left the engine unusable: the reopen failed with InputAllocation, the rollback to the previous settings failed the same way, the gateway answered worker_not_ready afterwards (on the 5090 server the same call takes 7 s and works). Open fixes: refuse a reconfigure up front when the free RAM cannot hold the reopened stack (say so), and when both the reopen and the rollback fail make the engine process exit so that the supervisor restarts it instead of leaving a half-dead engine.
  • leleka down took 2 s.

Second native run, same evening, after the fixes (commits d2386f1 and the Windows floors)

WSL was shut down again before the run (the assistant's own WSL test runs had restarted its VM and taken 10 GiB of RAM: always wsl --shutdown before a native test). Preflight passed without --cublas-dir and printed the planner's Windows note (10 GiB of page-locked experts, 12 GiB left to the desktop, floors 3072/1536 MiB). Start to ready 87 s (stack open 34 s). An agent-sized request (6,043 tokens in, 160 out): 98.6 s, prefill 83 tok/s, decode 6 tok/s, GPU 62 C at most. During it the host had 0.2 GiB available (engine 32 GiB resident): the machine runs at its memory limit, which is also why the governor's 503 appeared afterwards. reconfigure on that starved host was refused up front in 0.1 s (HTTP 409: only 283 MiB available, 7168 MiB needed, nothing changed); down 8 s and the RAM came back (37.6 GiB free). What the start check needs on this laptop: fixed footprint 29.4 GiB (the mapped working set is estimated at MemTotal/2 = 23.9 GiB, pinned K/V 3.1 GiB, pools) plus the floor and reserve (4 GiB with the lowered Windows floors). With less than about 34 GiB available the engine refuses to start and says so; close the browser and Docker Desktop first.

Workstation preset on Windows (planned, not yet measured)

The laptop is also the owner's work machine (coding agent, IDE, browser), so it runs --preset workstation; the 5090 server runs dedicated. In the file-backed form the planner now differs by preset (crates/deploy/src/resources.rs):

dedicated workstation
RAM left to the desktop 12 GiB 18 GiB (estimate: agent + IDE + browser)
page-locked experts (resident_budget_gib) available - 12 - 11 (max 24) available - 18 - 11 (max 24); 5 GiB at 34 GiB free
memory-governor floors lowered to 3072 / 1536 MiB kept at the workstation values (12 / 6 GiB on 48 GB)
hot part of the mapped bank planned by the start check min(MemTotal/2, bank) = 24 GiB 8 GiB (LELEKA_MAPPED_WORKING_SET_GIB)

Without the smaller hot-set estimate the start check could not pass on 48 GB (29.4 GiB fixed + 12 GiB floor > 34 GiB free). The value is accounting only: the OS decides what stays resident. The 18 GiB and 8 GiB are estimates; the first workstation run must measure decode speed, disk reads and the desktop's real footprint, and replace them. Unit test: the_windows_workstation_preset_leaves_the_desktop_more_and_keeps_its_floors.

First native workstation run (2026-10-26, 48 GB laptop, agent and browser running, WSL off, 32 GiB available at start)

One 7,113-token request (instructions of about 7k tokens plus a one-line task, 30 output tokens), then two more with the same instructions and another one-line task. Single runs, not repeats; short requests, so read the times as an existence proof of the memory behaviour, not as throughput.

Build Start Request A (cold) B, C (same prefix) What happened
workstation planner only (2d704e3) ready in 83 s 92.4 s 503 memory_pressure the working set grew to 30 GiB (mapped expert pages count as in use on Windows); available fell to 5.4 GiB, under the 6 GiB hard floor
+ working-set trim in the sampler ready in 82 s 69.4 s 58.7 s, 59.5 s, cached_tokens 0 no rejections (available 11.1 -> 16.3 GiB per trim), but the shed directive had set the prefix budget to 0 at every request end
+ soft floor 8 GiB (12 GiB left no budget) ready in 80 s 67.0 s 57.1 s, 58.8 s, cached_tokens 0 same: the budget is shed while a prefill runs
+ trim also on the shed directive ready in 80 s 67.5 s 20.8 s, 19.9 s, cached_tokens 6,144 budget 4,940 MiB, 2 hits, 12,288 reused tokens, 0 rejected

Cold prefill is about 105 tokens/s here; the 6,144 cached tokens cut the second and third request to under a third of the cold time. Changes behind it: EmptyWorkingSet on Windows while the pressure level is above normal (Governor::relieve_working_set, at most every 2 s, called by the sampler and by the shed directive), and a Windows workstation soft floor of 8 GiB (hard 4 GiB). The trim fired 66 times in this run; its effect on decode speed (the trimmed pages come back with soft faults) is not measured yet. Still open: a decode-speed A/B with and without the trim, and the same test with a real agent-sized context (tens of thousands of tokens).

Longer contexts on the laptop (2026-10-26): open defect STRA-235

The real workload is 256k tokens (owner); the laptop profile has a ceiling of 8,192 and nothing above 7k had run on the 3080 until today.

  • leleka reconfigure --context-tokens 32768 echoes kv_resident 32768 but the gateway keeps the 8,192 ceiling (context_length_exceeded, "the model's context is 8192 tokens"); only leleka up --context-tokens 32768 (a restart) raises it.
  • With the ceiling raised, a 28,567-token request prefills (~180 s, about 160 tok/s on the laptop; the 5090 does 1,781 tok/s) and the first forward after the prefill fails: forward layer 25 ... ffn-validate ok, then forward operation failed: CudaExecution; HTTP 502 generation_failed, the stack loses an owner and the worker is not ready until a restart. The per-layer attn-read / mixer / ffn-validate / moe lines are checks after each stage, so the failure is inside the MoE stage of layer 25 of the first decode window.
  • The same 28,000-token request on the 5090 with a 13 GiB budget works (job 9w0, prefill 1,781 tok/s, output ok), so the VRAM budget alone is not the cause. QSA-late is already off on sm_86 and the chain kernels are not in the laptop profile.
  • CUDA_LAUNCH_BLOCKING=1 is not usable: at 12k tokens the engine hung at the first decode window (GPU 100 % at 42 W for 16 minutes, stopped by hand).
  • Not yet known: which kernel fails (CUDA errors are asynchronous). Next: a launch-name trace for the MoE stage without blocking launches, then fix, then the 256k build-up in pieces of about 30k tokens that extend one prefix and hit the prefix cache (a 256k prefill is ~27 min at this speed, beyond the 12-minute GPU rule).

STRA-235 follow-up (2026-10-26): what failed, what is ruled out, the tracer

Native Windows engine, RTX 3080 Laptop (cc 8.6, 16 GiB, driver 617.42), workstation preset, --context-tokens 32768, build of this branch (sm86), model digest sha256:80d5e333...66a3, prefix cache on (a cold salted request never hit it), ~160 tok/s prefill. GPU 50-65 C, 40-60 W in every run (the engine is bound by the expert stream, not by compute), pstate P3/P0 while busy.

What the failure is. It is a GPU exception, not a length limit and not a host-side error:

  • The Windows System log (Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='nvlddmkm'}, id 13) holds one event per capture: Graphics SM Warp Exception on (GPC 0, TPC 0, SM 0): Out Of Range Address, ESR 0x504730=0xc05000e (0xc07000e once), warp PC 0x504728/0x50472c = 0x1174_0c81eb60. The same PC in all three captures (the two 28.5k failures of the first report at 08:18:58 and 08:24:30, and a 13,954-token request at 10:18:33). "Out of range address" is the SM's shared/local-window violation, not an unmapped global address: one kernel indexes beyond its dynamic shared (or local) allocation. The runtime sees it as cuStreamSynchronize code 700 and maps every driver error to the class CudaExecution.
  • The tracer (below) put the fault in the MoE of one layer: the 1,379 operations queued since the last successful synchronization are that layer's expert copies on the copy stream, then leleka_original_mmq_gather, leleka_mmq_zero, quantize_mmq_q8_1, mul_mat_q<IQ3_S|IQ4_NL, 96|112> (grid 320/640 tiles, or 48 = the SM count with mul_mat_q_stream_k_fixup), leleka_original_mmq_gu_finite, leleka_original_mmq_swiglu, leleka_mmq_finite. No cuLaunchKernel returned an error (no launch-configuration or shared-memory-opt-in failure); every asynchronous error surfaced at the next synchronization.
  • The same family shows up as NonFiniteMmqOutput("Gate" | "Up") (the MoE finite flags, layers 13, 15, 24, 39) and NonFiniteMmqOutput("MTP FC hidden") after a complete chunk: wrong MoE results without a fault. The runtime also mapped NonFiniteMmqOutput to CudaExecution in several helpers, which is why the first report only had the class.
  • It is intermittent and not tied to 28k: cold prefills of 13,954 tokens failed in the first chunks 4-7 (positions 8k-14k) and even at chunk 3, the first request of a fresh engine failed (not a second-request / state effect), while 28,466-29,653-token requests passed many times. Count over this session without any serializing tracer mode: 17 requests, 4 failures (13,954-28,610 tokens); plus the 2 original failures. The failing chunk, layer and error flavour differ from run to run; only the Xid PC repeats.

Ruled out (measured): the VRAM budget (5090 works, and 28k also passes here); sequence length / QSA position (13,954 fails, 29,653 passes repeatedly); the expert seed and adaptive swaps (LELEKA_ORIGINAL_SERVE_SEED=off, ADAPT_EVERY=0 still failed on the first request); the prefix cache (no hit in any failing run); a launch rejected by the driver (no launch error in the tracer); the host staging ring of the pageable expert bank as a data corrupter (LELEKA_STAGE_VERIFY=1 compares every staged buffer with its file bytes before the buffer is released: zero mismatches, in a run that then failed with a non-finite Gate); CUDA_LAUNCH_BLOCKING stays unusable. Not testable here: LELEKA_ORIGINAL_SERVE_PREFILL_BORROW=no (the engine cannot open: the separate arena does not fit next to the 2,208-slot expert cache, and ..._EXPERT_SLOTS is ignored by the laptop sizing), LELEKA_ORIGINAL_SERVE_RESIDENT_BUDGET_GIB (overridden by the planner), STRATA_STAGER_THREADS=1 (one 14k request took 562 s).

Serializing the host did not give a clean answer. With a cuStreamSynchronize after every kernel launch of the prompt forward (LELEKA_CUDA_TRACE_SYNC) 7 of 8 requests passed (the failure was a non-finite Gate, no fault); with a host callback queued behind every operation (LELEKA_CUDA_TRACE_CALLBACKS, finds the last operation that completed) 8 of 8 passed; with LELEKA_STAGE_VERIFY 5 of 6. 2 failures in 22 against 4 in 17 is not a significant difference, so this does not yet prove a timing race, and it does not rule one out. It does mean the callback mode could not be used to name the faulting kernel (it needs a failure to happen).

Tools added (all off unless LELEKA_BRINGUP_TRACE is set; nothing under engine/strata):

  • crates/libc-shim/src/cuda_trace.rs: on Windows the dlsym of the shim hands out wrappers for cuLaunchKernel, cuModuleGetFunction, the async/sync memcpy and memset entries, events, stream/context synchronization and graph launch. Every non-zero return prints CUDA-TRACE failure: <operation> returned <code> <cuGetErrorName> (<cuGetErrorString>) and the operations queued since the last successful synchronization of that stream, with kernel names, grid, block, dynamic shared bytes and stream. No wrapper blocks. LELEKA_CUDA_TRACE_SYNC=1 / LELEKA_CUDA_TRACE_CALLBACKS=1 add the per-launch synchronization or the completion callbacks, only while the prompt forward runs (PromptSyncTrace in cuda-driver; the decode windows would deadlock like CUDA_LAUNCH_BLOCKING).
  • The nine driver error: ... helpers also print under LELEKA_BRINGUP_TRACE (they needed LELEKA_TRACE_DRIVER_ERRORS), so the operation and code are in engine.log instead of the class only.
  • LELEKA_STAGE_VERIFY=1 (with the trace): staged expert buffers are compared with their file bytes when their DMA is released.

Not verified / next experiment. No kernel is named yet and there is no fix. The fault is data- or state-dependent and reproduces in roughly one cold 14k-30k prefill in four, so a failing run is needed with a tool that sees the faulting kernel. Cheapest options, in order: (1) run the model-free group-MMQ smokes (moe-mmq, preflight 20/40) and a randomized-count stress of mul_mat_q / stream_k_fixup on the 5090 under compute-sanitizer with sms forced to 48 (the 3080's SM count; the 5090, with 170 SMs, chooses other grids and stream-K splits for the same shapes), which finds a shared-memory overrun in the sm_120 PTX that the sm_86 retarget exposes; (2) install an NVIDIA CUDA toolkit on the laptop for compute-sanitizer / core dumps (CUDA_ENABLE_COREDUMP_ON_EXCEPTION), a system change the owner has to approve; (3) bisect by pinning the MoE kernels: force grid = tiles (no stream-K) for the group MMQ (mmq_original_group.rs, efficiency >= 90 rule) and rerun 8 cold 14k requests; the fault PC repeats, so one flag flip tells whether the stream-K fixup kernels are the culprit. The 256k target is not reached: nothing above 29,653 tokens was run, and the cache build-up and decode-depth numbers of the acceptance criteria are open.

STRA-235, second round (2026-10-26 afternoon): the stream-K A/B, the model-free stress, and a mitigation

Model-free stress of the grouped MMQ (crates/cuda-driver/src/mmq_original_group_stress_gpu.rs, test original_group_stream_k_stress, #[ignore]): random routing (10 distinct experts per token, power-law skew, 1-2048 tokens, 16-512 used experts, up to 1,490 rows for one expert), IQ3_S gate/up and IQ4_NL down with random finite-scale weights, run through the same mul_mat_q / mul_mat_q_stream_k_fixup / SwiGLU / quantize / finite kernels as the failing layers. Every layer runs twice, with the stream-K grid planned for STRESS_SMS SMs and with one block per tile, and the two results are compared (gate/up products must agree to 1e-4 of their range; the down product, whose input is the re-quantized SwiGLU, to 2e-3). A device fault panics with the trial's parameters.

device SMs planned for random layers x 2 grids fault worst difference gate/up / down
RTX 5090 (job stra235-streamk-stress, sm_120 native) 48 1,500 none 6.1e-7 / 1.35e-3
RTX 5090 (control) 170 1,500 none 5.8e-7 / 1.02e-3
RTX 3080 Laptop (native Windows, sm_86 companions, 28 min, 25-70 W) 48 2,400 none 7.1e-7 / 1.66e-3

So the grouped MMQ and its stream-K fixup, as a stand-alone owner with the 3080's 48-block decomposition, are correct and fault-free on both cards. There is no compute-sanitizer on the 5090 (not in the pinned toolkit 13.2.2, nothing under /); fetching it needs an approved download, so the harness checks by itself (CUDA error 700, and the A/B comparison). The ring, the stager, the arena lent from the expert cache and the real activations are not in it.

In-engine A/B inside one engine session (LELEKA_MMQ_NO_STREAMK_FILE, LELEKA_RING_SERIALIZE_FILE: the existence of a file switches the arm between requests, no restart; 13,954-token cold salted requests, the prefix cache never hit, tracer wrappers on, GPU 58-64 C, stretches of 31, 30 and 45 minutes):

arm what it does requests failures
A default: stream-K grid of 48 blocks when a wave of tiles is under 90 % full 23 4
B LELEKA_MMQ_NO_STREAMK: one block per tile (grid = tiles), no fixup kernel 23 0
C LELEKA_RING_SERIALIZE: the copy stream is drained after every expert DMA and the compute stream after every queued command of the prompt ring 8 0

The four A failures: cuLaunchKernel(mul_mat_q<IQ4_NL,128>) returning 700 in layer 17 of chunk 4 (a sticky fault of an earlier operation); NonFiniteMmqOutput("Up") in chunk 7; cuStreamSynchronize 700 in layer 29 of the very first chunk, 7 s after the request started and right after a successful request of the same session; NonFiniteMmqOutput("Gate") in chunk 3. Request times: A 93-113 s, B 95-112 s, C 131-136 s, i.e. no measurable prefill cost for B (the prefill is bound by the expert stream). One-sided Fisher exact test A against B: p = 0.054 (4/23 against 0/23); if B failed as often as A (17 %), 0 of 23 would have a probability of 1.4 %. This is suggestive, not conclusive, and C is too small to say anything. The failure rate was higher in the earlier, lighter-weight runs (about 1 in 4), so the host-timing sensitivity noted above is real.

What this says. The stream-K grid (48 blocks, a TMP fixup workspace of sms * 128 * 128 * 4 bytes) is implicated in the live pipeline, while the same kernels with the same decomposition are clean stand-alone: whatever corrupts memory needs the live neighbourhood (the arena lent from the expert cache, the copy ring and its stream, other work in flight). Why the fixup path indexes out of range there is not found.

Mitigation, on by default only for sm_86-class devices (mmq_original_group.rs, OriginalGroupBank::avoid_stream_k): a device that is not a native sm_120 launches the group MMQ with one block per tile. LELEKA_MMQ_STREAMK=1 restores the stream-K grid. The 5090 path is untouched (grid and fixup identical, the code path is not entered). Numerically the per-tile arithmetic is the same; only the float summation order of the K split disappears (gate/up differ by under 1e-6 of their range, see the stress). With the default build and no switch, two cold 28.4k-token requests passed on the laptop (209 s and 205 s, 62 C), after 28,466-29,653-token requests had also passed with the stream-K grid in the earlier runs: the 28k result alone does not prove anything. Not verified: the 256k build-up, decode at depth, that the mitigation removes the failures (0 of 23 is the evidence), and the root cause. Next steps if the failure returns with the mitigation on: arm C at 30+ requests (ring serialization), then drain the copy stream only (copy.synchronize() after each DMA) and the compute stream only, to separate a copy/compute hazard from a compute-only one; and a harness that drives execute_original_copy_ring with a synthetic pageable bank (the stager, gather and event ordering are the parts the stress does not cover).

  • compute-sanitizer 13.2.87 (NVIDIA redistributable, sha256 664570679f04d7ca1a124e1fcf1a84f0d9f511c857b01bae188a1d783025a15c) is installed on the 5090 at ~/cuda-toolkits/sanitizer-13.2.87/compute-sanitizer/compute-sanitizer (2026-10-26); the Linux toolkit 13.2.2 on the server does not ship it.

STRA-235, third round (2026-10-26 evening): the MTP stream-K site, the 256k-class session, the drain switches

The "MTP FC hidden" failure of the first real long session has a simple reading. The round-two mitigation switched only the grouped-MoE MMQ to one block per tile. The MTP draft-KV record that runs after every prefill chunk (mtp_original_prefill.rs, the NonFiniteMmqOutput("MTP FC hidden") check) plans its own stream-K grid (efficiency >= 90 ? tiles : sms), and so do the resident MMQ (mmq_resident.rs), the Original profiles of mmq.rs and the stream-all issuer. They were all still on the 48-block stream-K grid. The mitigation now covers every site: arch_ptx::stream_k_off() (one decision: an sm_86-class device unless LELEKA_MMQ_STREAMK=1, or LELEKA_MMQ_NO_STREAMK=1 / the files LELEKA_MMQ_NO_STREAMK_FILE and LELEKA_MMQ_STREAMK_FILE for A/B inside one engine), latched where the owners of those kernels are built with the device's context current. A native sm_120 device never enters it (grids and fixups unchanged, the 5090 path is bit-identical). New diagnostic switches, all off by default: LELEKA_FORCE_SMS=N (plan the stream-K grids for N SMs, e.g. 48 on the 5090), LELEKA_RING_SERIALIZE_COPY_FILE / _CMD_FILE (drain only after the DMAs / only after the queued commands of the prompt copy ring; LELEKA_RING_SERIALIZE_FILE does both), LELEKA_CHUNK_DRAIN / _FILE (drain the whole context before the cache lends its tail to each chunk).

Evidence on the laptop (native, workstation preset, driver 617.42, GPU 51-63 C, at most 89 W, no P5 stall, VRAM 12.9-13.5 GiB without drift):

  • The coordinator's session (scripts/e2e/long_session.py, 5 turns, context 262144) on this build, all stream-K sites off: all five turns completed. Input tokens / cached tokens / TTFT / decode rate: 46,749 / 0 / 432 s / 6.9 tok/s; 90,850 / 40,960 / 470 s / 7.4 (the turn that failed before: 49,890 new tokens, 25 prefill chunks); 135,738 / 90,112 / 439 s / 7.0; 182,901 / 135,168 / 447 s / 7.9; 224,066 / 182,272 / 418 s / 7.5. No CUDA error, no non-finite flag, no engine restart; the cache hits are the ones the prefix cache promised (45k, 90k, 135k, 182k tokens reused). Prefill runs at about 105-115 tok/s over the whole session (expert-streaming bound), decode 7-8 tok/s at 224k depth.
  • In-engine A/B inside one engine (13,954-token cold salted requests, 7 chunks each): stream-K on at every site: 38 requests, 5 failures (13 %; cuStreamSynchronize / cuLaunchKernel returning 700 or a non-finite Gate/Up flag, in chunks 0-7). Stream-K off in the grouped MoE only (the MTP site still on): 23 requests, 0 failures. All sites off (the default arm plus the arms that also drain the ring streams, which ran with stream-K off): 25 requests, 0 CUDA or non-finite failures, and one driver error: BudgetExceeded in the QSA attention of chunk 3 after 15 successful requests in the same engine (VRAM constant at 13.27 GiB; not explained, not a CUDA fault). Grouped-MoE stream-K off (48 requests, 0 failures) against on (38 requests, 5 failures): one-sided Fisher p = 0.014. The drain arms are uninformative about a hazard, because stream-K was off in them.
  • Control with stream-K forced on in the long-session shape (LELEKA_MMQ_STREAMK=1 in the engine's environment, 2 turns): turn 1 98,779 tokens cold (49 chunks) and turn 2 205,351 tokens with 98,304 cached (52 chunks) both completed, with no fault (decode 7.5 and 4.5 tok/s). So stream-K did NOT fail in about 100 chunks of that shape (at the 13 % per 7-chunk request seen above, about 1.9 failures would have been expected; P(0) is about 15 %), which neither confirms nor weakens the A/B; I did not verify from inside the engine that the variable reached it.

The 5090 does not show it. The real serve path (28,000 tokens, 13 GiB budget, LELEKA_FORCE_SMS=48, so the stream-K grids and the fixup workspace are planned for 48 SMs; the log line PROBE group bank new: sms=48 confirms it) completed 4 times, the control with the natural 170 SMs 3 times; the model-free stress passed 3,000 random layers (48 and 170 SMs) and, under compute-sanitizer memcheck and synccheck, 6 trials each with 0 errors (the larger sanitizer run is queued as stra235-sanitizer2). On the laptop the same stand-alone stress passed 2,400 layers. So the stream-K failure needs sm_86 execution and the live pipeline.

Code reading for a missing dependency (nothing found). The loan path: every lend_prefill_tail first runs sync_queued (wait_swaps on the swap stream, then the legacy default stream and the refill stream), so no seed/adaptive swap or lent-slot refill is in flight when a chunk takes the tail; the lent slots are refilled by refill_lent only after prefill_actions ended (LELEKA_REFILL_DEFER is off), through fill_slot_queued on the default stream with a drain at settle_refill; a slot lent to the prompt is NeedsRefill, never a hit, until that refill is fenced. Inside a layer the copy ring orders slot reuse with used.wait_on(copy) before each DMA and copied.wait_on(compute) before each gather, drains both streams in finish_statuses, and the host staging ring releases a buffer to the helpers only after the DMA's event completed (LELEKA_STAGE_VERIFY found no corrupted buffer in a failing run). The MTP record runs on the dense workspace's stream behind a context synchronize and ends with a synchronization. The pageable expert copies (cuMemcpyHtoDAsync from a file mapping) are staged by the driver before the call returns, so the source cannot change under them. I could not construct a deterministic repro (a delay in the copy path) because no hazard was identified; the drain switches above are in place to test the hypothesis directly (arms with stream-K forced on plus a drain), which needs 30+ requests per arm at the observed 13 % rate and was not run.

Not verified: the root cause of the stream-K fault (it needs sm_86 and the live neighbourhood; the stream-K grid itself, the fixup kernel and the TMP sizing are correct stand-alone), that the mitigation is complete beyond the 224k session and 15 + 38 requests, the 256k limit itself (the 5-turn session ends at 224k by design), quality against the 5090 (greedy outputs of the laptop were not compared).

Upstream speed items for the laptop (2026-10-26, prepared on the server, NOT yet run on the 3080): route tail skip and the worker plan

Branch claude/upstream-speed (docs/upstream-port-plan.md rows 3.1, 2.3, 0.6). Nothing below was run on this laptop; the numbers on the 5090 are in the port plan. Three switches, all off or neutral by default:

switch what it does default
LELEKA_ROUTE_TAIL_SKIP=N (1..9) EXPERIMENTAL, changes the output. A missed expert that every token of a verify window routes at rank N or lower is neither copied over PCIe nor computed on the CPU (its row is zero; the other route weights are not renormalised). Upstream claims +10..20 % decode on 12-16 GB cards. Off while at least LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED percent (90) of the experts are in VRAM; the engine log says EXPERIMENTAL route tail skip is ON ... or ... is OFF: x% of the experts are in VRAM once per process unset = off
LELEKA_CPU_POOL_PLAN=on the CPU expert worker count when LELEKA_ORIGINAL_SERVE_CPU_WORKERS is not set: physical cores but the host's (7 on the i9-11900H, 8 cores / 16 threads) instead of the constant 15; 8 of the 15 workers of the constant have no core of their own (the pool pins to the 7 physical cores left after the host's) and spin unpinned unset = 15
LELEKA_CB_WARMUP=off Linux only; Windows has no such code path (CPU sets are per thread) n/a here

Build (the sm86 companions as in the Build section; the branch only adds Rust and docs): powershell -ExecutionPolicy Bypass -File scripts\windows\build-release.ps1, or for the replay harness cargo test --release -p leleka-runtime --features sm86 --lib --no-run and use the printed leleka_runtime-*.exe as TEST_BIN.

Paired A/B on the laptop (one variable at a time, same model digest, same cache state, same prompts; ABBA order, at least 6 requests per arm, record tokens, tok/s per request, the expert tier: line and the engine's leleka-serve: ... route tail skip line):

# arm A (control) and arm B, each a separate engine start, alternating A B B A; the 8-core laptop's tier (slots from the memory plan) decides how many experts miss
$env:LELEKA_ROUTE_TAIL_SKIP = ""        # arm A: unset
$env:LELEKA_ROUTE_TAIL_SKIP = "7"       # arm B
# worker plan arm: leave LELEKA_ORIGINAL_SERVE_CPU_WORKERS unset and set LELEKA_CPU_POOL_PLAN=on for B; A runs the constant 15 (or set LELEKA_ORIGINAL_SERVE_CPU_WORKERS=7 to separate "7 workers" from "the plan")

With the replay harness (backend::original_serve_replay::original_serve_replay_smoke, needs a capture directory: captures are private data, copy one by hand) both arms live in ONE process: LELEKA_SPEC_ARMS=adaptive@0,adaptive@0+tail7 LELEKA_REPLAY_REPS=5 LELEKA_REPLAY_FORCE=1 (see the job upspeed-31-ab-9e3 for the full environment); the report line is REPLAY PASS ... arm=... weighted_decode_tok_s=. The quality gate (teacher-forced top-16 log-probabilities, scripts/quality/q_tail_gate.py LOG CAPTURE --ref 0 --control LOG2) needs the same capture: arms G=off@2048,T=off@2048!tail7 and a control run with G=off@4096 (LELEKA_REPLAY_ARMS, LELEKA_TRACE_LOGPROBS=16, LELEKA_BRINGUP_TRACE=1, LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=0, LELEKA_ORIGINAL_SERVE_SEED=off). The laptop's small tier is where the skip drops the most experts, so its own gate run matters more than the 5090's.

On the 5090 (auto tier, 9e3 replay) the skip measured +15.2 % decode but FAILED the teacher-forced gate (p99 1.005 against a limit of 0.499), so a laptop speed number alone proves nothing: run its gate too, and keep the switch out of every profile until one passes.

PCIe tier on the laptop (2026-10-27): the batch-copy fault, and whether PCIe beats the CPU

Branch claude/3080-pcie, native engine, workstation preset, RTX 3080 Laptop (cc 8.6, 16 GiB, driver 617.42), --context-tokens 262144, model digest sha256:80d5e333...66a3, WSL off. On the preset the expert tier reads vram 41-46% pcie 0 cpu 54-59% because a pageable file-mapped bank takes no PCIe share unless LELEKA_ORIGINAL_SERVE_PCIE_FRAC is set (pcie_num_for).

The failure. With a share set (0.45, 0.8, 1.0; 6 of 6 runs of the first A/B) every request died the same way: the prompt prefill finished (all 9 chunks of 17.9k tokens), the first decode window launched its graph, and the first cuMemcpyHtoDAsync_v2 after it returned CUDA_ERROR_ILLEGAL_ADDRESS (700), then class=CudaExecution and a worker that is not ready. It is not a length effect: a 2,066-token prompt with 48 output tokens fails the same way, so the loop is one engine start (60 s) plus 20 s. The Windows System log has one nvlddmkm event 153 per failure (STRA-235's were id 13, "SM Warp Exception"); it carries no text.

Root cause, bisected in the engine and reproduced model-free.

  • In the engine, LELEKA_PCIE_DMA_BATCH=off alone removes the failure (MANY=off and FLAGB=host are not needed); the reply hash of the 48-token request is the same with and without the other two switches. The window's DMA arm (publish_gpu_plan) gave all pieces of a group to one cuMemcpyBatchAsync_v2; dma_options turned that on everywhere except WSL2, and native Windows has no /proc/sys/kernel/osrelease, so it was on here.
  • crates/cuda-driver/src/original_pcie_copy_gpu_smoke.rs (no model, 200 rounds, real piece sizes, every byte checked) on this laptop:
source memory one call per piece cuMemcpyBatchAsync_v2
pageable (heap) exact exact (stream-ordered access; also with the "during call" and "any" orders)
page-locked: cuMemHostRegister flags 0, READ_ONLY (8) or DEVICEMAP (2) exact error 700 at the next synchronize (access order "during call": at the call itself)
half page-locked, half pageable exact error 700

The batch faults for a single 16-byte piece, and for every piece size, alignment, source access order and registration flag tried. So it is not a hazard of the engine (no stream, kernel, graph or flag is involved): it is the driver's batch entry with a page-locked host source on this machine. The older WSL2 note in dma_options ("the batch copy faulted in a microbenchmark on the RTX 3080 laptop") was the same bug. I cannot say why inside the driver.

  • Fix (7218a4f): dma_options_for(wsl, windows, env) leaves the batch off by default on native Windows too (the stream write of flag B stays on: it ran in every engine run here); LELEKA_PCIE_DMA_BATCH=on still forces it. The tracer now also names cuMemcpyBatchAsync_v2 (batch-async copies N ...). Tests: a unit test of the defaults; pcie_copy_gpu_production_{pageable,page_locked,mixed} pass; pcie_copy_gpu_raw_batch_{page_locked,mixed} FAIL on this laptop by design, they are the check to repeat on a new driver (cargo test --release -p leleka-cuda-driver --features cuda-driver,sm86 --lib -- --ignored --nocapture pcie_copy_gpu_<case>, one case per process because a fault poisons the context). Not tried on the 5090 or on Linux, where the batch has measured +6 % with the registered bank (job 981); that path is unchanged.

Is this STRA-235? No, as far as the evidence goes. STRA-235 is an SM warp exception inside a mul_mat_q kernel (event id 13, a repeating PC) during the prefill, with the PCIe share at 0, i.e. with no window copy and no batch call anywhere in the run; this one is a driver entry the prefill never calls, with a different event id. What this work adds to STRA-235 is negative: mapped_file_dma_under_working_set_trimming_is_exact (a 2 GiB read-only file mapping, the first GiB page-locked in place with cuMemHostRegister(READ_ONLY) as pin_resident does, random expert-sized copies out of the locked and the pageable halves, EmptyWorkingSet every 5 ms as the governor does, a thread churning the pages, every byte checked against the file's content function) found 0 wrong bytes in 205,235 copies (about 60 GB; half out of the locked pages, half out of pageable ones) over 5 minutes with 27,248 working-set trims. A page that was trimmed or reclaimed under a registration, which could have fed garbage weights to the MMQ, is therefore not what STRA-235 is, at least not in this form. The root cause of STRA-235 is still unknown.

Does PCIe beat the CPU here? Not with the pageable bank as it is. Raw link (pcie_copy_gpu_bandwidth): a page-locked source copies at 11.6 GB/s (640 KiB pieces) to 12.4 GB/s (32 MiB) with the link at x8 gen4 (nvidia-smi reads width 8 of 16, also under load in every arm below), in 4 us per call without holding the calling thread; a pageable heap source copies at 8.1-8.9 GB/s but the call is the copy (79 us per 640 KiB piece, 100 % of the time on the calling thread). The window is driven by one thread, and the pageable bank's pieces come out of file-mapped pages that the governor's working-set trim keeps dropping, so the engine pays far more than the heap figure: with LELEKA_SERVE_PROFILE=1 and share 0.45, one 200-token request spends 10.4-11.0 s in pool.publish_plan (of 27-31 s of decode), against 0.0 s without a share, while the CPU pool's compute falls only from 7.6-8.2 s to 4.9-5.1 s.

Decode tok/s of a 2,066-token prompt, 200 output tokens, temperature 0, the same request three times in one engine (request 1 is cold; requests 2 and 3 normally hit the prefix cache, the runs marked * lost it to memory pressure). One engine start per row, so read differences below about 10 % as noise:

share 1 2 3 PCIe / CPU share of the entries
unset (CPU only) 6.46 9.08 8.80 0 / 55 %
0.25 5.17 7.13 7.60 11 / 45 %
0.45 4.49 6.92 7.50 20 / 34 %
0.65 4.00 4.12* 4.29* 33 / 29 %
0.8 3.59 5.90 6.33 36 / 21 %
1.0 3.85 6.47 7.27 50 / 5 %
0.45 + LELEKA_PCIE_AUTO=on 4.57 7.51 7.51 16 / 39 %

No plain share beats the CPU. The pageable misses are the problem, so LELEKA_PCIE_LOCKED_ONLY=on (d54f101, off by default) lets only the experts that pin_resident locked (4,242 experts, 8 GiB, by profile rank) take the share; every other miss stays on the CPU pool. pool.publish_plan drops to 1.3-1.7 s per request. Same request, same method:

share + locked only 1 2 3 PCIe / CPU share
0.3 6.88 9.62 9.07 10 / 44 %
0.45 (two runs) 6.79, 7.26 9.11, 7.95* 10.02, 9.51 14-15 / 41-43 %
0.6 6.54 9.48 9.79 15 / 41 %
0.8 6.71 8.82 10.38 16 / 40 %
1.0 6.91 7.76* 8.01* 17 / 44 %
unset, same build (two runs) 6.75, 6.67 8.60, 7.50* 8.50, 8.88 0 / 54-59 %

Once the share is set it hardly matters which value, because the eligible set (a bit over 15 % of the entries) is the cap.

Paired A/B on the agent-shaped workload (scripts/e2e/long_session.py, 2 turns of one conversation, 17,907 then 46,787 input tokens with 16,384 (14,336 in two runs) reused from the prefix cache, 200 output tokens each; engine restarted per run after wsl --shutdown; 3 reps per arm in the rotated order A B C / B C A / C A B in three stretches of 31-34 minutes, a few minutes apart; GPU 55-64 C, no throttling, no P5 stall, no CUDA error in any of the 9 runs; build of 2a7e80a's code, arms differ only by the environment):

arm environment prefill tok/s, turn 1 / 2 decode tok/s, turn 1 decode tok/s, turn 2 entries VRAM / PCIe / CPU CPU utility during decode PCIe width
A none (the preset's default) 105.3 / 108.9 6.73 (6.46-7.01) 6.79 (6.58-7.19) 42.2 / 0 / 57.8 % 152 % x8
B PCIE_FRAC=0.45 106.3 / 109.7 5.02 (4.84-5.22) 4.79 (4.67-4.96) 43.7 / 20.4 / 36.0 % 150 % x8
C PCIE_FRAC=0.6, LELEKA_PCIE_LOCKED_ONLY=on 106.0 / 107.9 7.51 (7.20-7.81) 7.14 (7.05-7.19) 42.8 / 22.0 / 35.2 % 144 % x8

Means of 3 reps with the min-max in brackets. "CPU utility" is the Windows Processor Information\% Processor Utility counter (frequency-scaled, so above 100 %), from the 2 reps that had it. The GPU's NVML "utilisation" reads 87-100 % in every arm because the resident kernels poll, so it says nothing. Prefill does not depend on the share, as expected.

B is 25-29 % slower than A in every pair. C is faster than A in turn 1 in every pair (7.20-7.81 against 6.46-7.01, +12 % on the means) and +5 % in turn 2, where the ranges overlap (7.05-7.19 against 6.58-7.19): +8 % on the means over both turns, a small gain that I would not call proven from 3 reps. The replies of this workload are the thinking model's reasoning (both turns end incomplete at 200 tokens with an empty visible text, so every reply_sha256 is the hash of the empty string) and cannot show a greedy mismatch. The 2,066-token request can: its replies fall into the same six or so variants in every arm, the unset one included (they share the first 345-775 characters, then differ), because the adaptive tier and the GPU/CPU split change from run to run. No share arm produced a reply the unset arm did not also produce, and nothing matches a fixed baseline bit for bit; this is not a quality gate.

Recommendation. Keep the preset's default (no share): a pageable bank pays more for its copies than the CPU pool does. The workstation preset's default is not changed here. LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.6 LELEKA_PCIE_LOCKED_ONLY=on is the one setting that is not worse, about +8 % decode in these 9 runs; it needs more reps, a 256k-class run and the quality gate before it becomes a profile line. What would move the bound: the CPU pool's compute is only about a third of a window (the rest waits on the GPU graph's own routing ids), and the locked set is 8 GiB. More pinned experts (a larger resident_budget_gib, which the 48 GB machine cannot spare) or a copy that does not stall the driving thread (staging the pageable pieces on helper threads, as the prefill ring does) are the next steps; neither is done.

Not verified: why the driver faults (a driver defect is the only reading the tests leave; no vendor confirmation); the batch call on another driver or on Linux; C against A beyond 3 reps; a 256k session with a share; GPU against CPU expert math at the tensor level (the replies of one arm already differ between runs, so a greedy comparison cannot show it); compute-sanitizer on this laptop (not installed; nothing was installed).