diff --git a/docs/windows.md b/docs/windows.md index 9a78e68d..78bb243d 100644 --- a/docs/windows.md +++ b/docs/windows.md @@ -17,13 +17,13 @@ No performance claim is made anywhere in this document; nothing here has a quali | Milestone | State | Evidence | | --- | --- | --- | -| A. `leleka.exe` as the WSL2 front end | **Works** for `help`, `version`, `profiles`, `doctor`, `status`, `down`, `preflight`, `up --dry-run` on this laptop (real `wsl.exe`, real distribution). `up` (real start), `reconfigure`, `verify` use the same code path but were **not run against the model**: the owner tests them | `leleka.exe preflight` / `up --dry-run` ran the Linux `leleka` in `Ubuntu` and printed its plan | -| B. native engine, compiles and unit-tests | **Whole integrated tree** (`claude/port-gpu-bringup` e64a3da merged) builds natively for `x86_64-pc-windows-msvc` and its non-GPU tests pass: `leleka-deploy` 116 unit + 2 Windows end-to-end + 5 recipe tests, control-plane (`strata-control`), `leleka-runtime`, `strata-desktop-core`, `leleka-memory`, `leleka-model-format` and the rest of the workspace. One failure, also on Linux: `experimental-ref` `literal_port` (4 tests; the kernel sources moved with the upstream sync) | `cargo test --workspace` on Windows; Linux `cargo check --release --workspace --tests` and `cargo test -p leleka-deploy --features test-fakes` in WSL (all pass except `e2e::dry_run_prints_the_plan_and_changes_nothing`, which assumes a host with enough RAM for the sealed form and picks the mapped form on this 39 GB WSL VM: environment, not code) | -| B. native supervisor, test doubles | **Works** on Windows processes without GPU or model: start, readiness, `status`, `reconfigure` over HTTP and by engine restart, Ctrl-Break drain, stop-file shutdown (section "What was exercised") | `crates/deploy/tests/e2e_windows.rs`, 2 tests passing | -| B. native engine, real model | **Not run.** A model-free GPU smoke through `nvcuda.dll` passed earlier (context creation and the installed-driver fixed-kernel test, one run, 4.5 s). The load of 80 GB of shards + the 55 GB archive, the mapped expert source and a decode on Windows are **untested**: that is what you test | - | -| `leleka service` (Task Scheduler / user unit) | Task XML generated and unit-tested; **never registered on this machine** | `service.rs` tests | -| `stage-model.ps1`, `fetch-cublas.ps1` | Parse-checked; `fetch-cublas.ps1` refusal verified locally with a wrong-length and a wrong-hash archive (no network); **the downloads and the 140 GB copy were not run** | - | -| C. this document | written | - | +| 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: `experimental-ref` `literal_port` (4 tests; kernel sources moved with the upstream sync), `arch_ptx` (`chain_window.ptx` has no sm_86 record) | `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): @@ -102,14 +102,16 @@ ASSETS\tokenizer-assets\ (made by ``` **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//`). This laptop's existing `~/laptop` volume has the archive inside `model/`. Make a leleka-shaped -volume next to it with `mv` (instant on one file system; the files leave `~/laptop/model`, so your older bench scripts stop finding -them until you `mv` them back). The engine admits only a regular, single-link archive file, so a hard link or symlink is not a substitute: +`--assets` under `/mnt//`). 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): ```powershell -wsl -d Ubuntu -- bash -lc "mkdir -p ~/leleka-assets/model ~/leleka-assets/data && cd ~/laptop && mv model/*.gguf ~/leleka-assets/model/ && mv model/qwen-iq3-s-l2-v4.kar model/qwen-iq3-s-l2-v4.kar.provenance.json ~/leleka-assets/ && mv data/mtp-rt ~/leleka-assets/data/ && cp data/expert-profile.bin ~/leleka-assets/data/" +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: @@ -123,7 +125,7 @@ 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 (works today) +## Route A: WSL2 bridge ```powershell cd C:\Users\pavel\work\leleka-windows @@ -154,7 +156,7 @@ Leleka (WSL2 route) is reachable from Windows: `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 (compiled and exercised with test doubles; not run with the model) +## 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): @@ -192,7 +194,7 @@ else `~/laptop`; both layouts are understood), copies with `robocopy` (a percent 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 parse-checked and its layout logic reviewed; **the copy itself was not run here** (140 GB; the owner runs it). +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 @@ -220,6 +222,51 @@ admission messages. 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` ```powershell @@ -232,7 +279,7 @@ leleka service uninstall # stop, then delete the task leleka service install --dry-run # print the task XML and change nothing ``` -`--hidden` makes `leleka.exe` give up its console and start the engine, gateway and API with `CREATE_NO_WINDOW`, so no window stays on the desktop. Prepare the state +`--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). @@ -241,7 +288,7 @@ distribution, and a second task `Leleka-WSL` that runs `leleka.exe service hold 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). First use: run `leleka service install --dry-run`, look at the XML, then `leleka service install`; if `schtasks` rejects +`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` @@ -299,6 +346,8 @@ All flags: `--context-tokens 1..262144`, `--prefill-capacity 256..8192`, `--kv-r | `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 | diff --git a/scripts/windows/stage-model.ps1 b/scripts/windows/stage-model.ps1 index cd8274d3..97c8c297 100644 --- a/scripts/windows/stage-model.ps1 +++ b/scripts/windows/stage-model.ps1 @@ -77,6 +77,8 @@ if ($have + $already -lt $need) { function Copy-Tree([string]$from, [string]$to, [string[]]$files = @(), [switch]$Recurse) { $arguments = @($from, $to) + $files + @("/J", "/R:3", "/W:5", "/NJH", "/NJS", "/NDL") if ($Recurse) { $arguments += "/E" } + # Redirected to a file, robocopy would write one line per percent point: drop the progress there. + if ([Console]::IsOutputRedirected) { $arguments += "/NP" } Say "copying $from -> $to" & robocopy.exe @arguments if ($LASTEXITCODE -ge 8) { throw "robocopy failed ($LASTEXITCODE) for $from" }