feat: Windows runtime packaging: Docker cross-build, Start-Leleka launcher, zip packager, docs (STRA-220)
- deploy/Dockerfile.windows-build cross-compiles the six executables (mingw, no Visual Studio needed) - control-plane/build.rs: the ggml link stubs are used for every Windows target, not only MSVC - scripts/windows/Start-Leleka.ps1 (igpu | cpu | npu modes, speculation and cache slots on by default) and Package-Windows.ps1 - docs/windows-runtime.md; stale statements in docs/cpu-runtime.md corrected Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
6c26ccdbcd
commit
92cbffdfe8
@@ -10,3 +10,7 @@ engine/strata/*
|
||||
!engine/strata/LICENSE
|
||||
benchmarks/
|
||||
docs/
|
||||
target/
|
||||
dist/
|
||||
**/target/
|
||||
benchmarks/results/
|
||||
|
||||
@@ -38,3 +38,4 @@ logs/
|
||||
*.kar2
|
||||
*.safetensors
|
||||
*.bin
|
||||
dist/
|
||||
|
||||
@@ -15,8 +15,9 @@ fn main() {
|
||||
.flag_if_supported("-ffunction-sections")
|
||||
.flag_if_supported("-fdata-sections")
|
||||
.warnings(false);
|
||||
// The MSVC linker keeps the quantizer object and needs ggml.c's four helpers; see the file.
|
||||
if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") {
|
||||
// The Windows linkers (MSVC and the mingw one used by the Docker cross-build) keep the quantizer object and
|
||||
// need ggml.c's four helpers; see the file.
|
||||
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
|
||||
build.file("src/ggml_msvc_stubs.c");
|
||||
}
|
||||
build.compile("strata_ggml_quants");
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# Cross-compiles the Windows (x86_64-pc-windows-gnu) runtime binaries in a Linux container, so no Visual Studio is
|
||||
# needed on the build machine. Build context: the repository root.
|
||||
# docker build -f deploy/Dockerfile.windows-build -o type=local,dest=dist/windows .
|
||||
# The binaries are written to dist/windows (ignored by Git). The mingw runtime is linked statically; OpenVINO is
|
||||
# still loaded at run time from a separately obtained install (see docs/windows-runtime.md).
|
||||
FROM rust:1.99-bookworm AS build
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 cmake \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& rustup target add x86_64-pc-windows-gnu
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
# the repository pins its toolchain (rust-toolchain.toml); add the target to that one
|
||||
RUN rustup target add x86_64-pc-windows-gnu
|
||||
ENV CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc \
|
||||
CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc \
|
||||
CXX_x86_64_pc_windows_gnu=x86_64-w64-mingw32-g++ \
|
||||
AR_x86_64_pc_windows_gnu=x86_64-w64-mingw32-ar \
|
||||
RUSTFLAGS="-C target-feature=+crt-static"
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/src/target \
|
||||
cargo build --release --target x86_64-pc-windows-gnu \
|
||||
-p strata-control -p leleka-cpu-worker -p leleka-igpu-worker -p leleka-npu-worker \
|
||||
-p leleka-npu-service -p leleka-gpu-npu-worker \
|
||||
&& mkdir /out \
|
||||
&& for b in strata-next leleka-cpu-worker leleka-igpu-worker leleka-npu-worker leleka-npu-service leleka-gpu-npu-worker; do \
|
||||
cp target/x86_64-pc-windows-gnu/release/$b.exe /out/; done
|
||||
|
||||
FROM scratch AS export
|
||||
COPY --from=build /out/ /
|
||||
+2
-2
@@ -73,8 +73,8 @@ Tool-call arguments arrive in one piece when the call ends (the stream decoder b
|
||||
teacher-forced logit comparison that would explain it is still to be done. Greedy tokens agreed on the
|
||||
prompts tried, but near-ties can flip.
|
||||
* The KV cache holds half-precision keys and values (about 49 KB per token, as llama.cpp's default): the worker's default context is 32,768 tokens (1.6 GB). A 131,072-token context would take 6.4 GB; RAM planning for it with the 12 GB model (STRA-204/205/210) and cold-expert streaming (KAR) are not done.
|
||||
* One request at a time (by decision); sampling is temperature and top-p over the 1,024 best logits.
|
||||
* iGPU/NPU helpers for prefill (STRA-207) are a spike: the NPU driver is present on the reference laptop, OpenVINO is not installed yet.
|
||||
* One decode at a time per worker (several conversations can share it through `--cache-slots`); sampling is temperature and top-p over the 1,024 best logits.
|
||||
* iGPU and NPU prefill helpers exist as opt-in workers (`docs/igpu-prefill.md`, `docs/npu-service.md`); the packaged Windows runtime is described in `docs/windows-runtime.md`.
|
||||
|
||||
## Decode speed limit on the reference laptop (2026-10-15)
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# Leleka runtime for Windows x64 (gpt-oss-20b, AVX2 / iGPU / NPU)
|
||||
|
||||
Status 2026-10-21: usable and tested on the reference laptop (Core Ultra 7 265U, 32 GB, one DDR5-5600 module); the
|
||||
iGPU and NPU paths and speculation are experimental switches, the CPU path is the baseline. Pure Rust; production
|
||||
serving needs no Python and no CUDA. Linux x64 has not been built or run.
|
||||
|
||||
## What it is
|
||||
|
||||
`strata-next serve` (control plane) exposes `POST /v1/responses` (and `/health`, `/ready`) and supervises one worker
|
||||
process that decodes gpt-oss-20b-MXFP4 on the CPU (AVX-VNNI / AVX2 / portable kernels, chosen at run time).
|
||||
|
||||
| worker | long prompts (prefill) | decode | notes |
|
||||
| --- | --- | --- | --- |
|
||||
| `leleka-cpu-worker` | CPU | CPU | baseline |
|
||||
| `leleka-igpu-worker` | integrated GPU (wgpu / Vulkan), falls back to the CPU by itself | CPU | default of the launcher; `docs/igpu-prefill.md` |
|
||||
| `leleka-npu-worker` | Intel NPU through `leleka-npu-service` (OpenVINO, a separate process) | CPU | experimental; `docs/npu-service.md` |
|
||||
| `leleka-gpu-npu-worker` | GPU and NPU together | CPU | measured: no gain over the GPU alone; `docs/worker-pool.md` |
|
||||
|
||||
Switches common to the workers: `--speculate` (exact prompt-lookup speculation), `--cache-slots N` (KV caches of N
|
||||
conversations), `--ctx`, `--threads`. Decode quality is checked against llama.cpp on teacher-forced text
|
||||
(`benchmarks/quality/gpt-oss-20b-teacher-forced`); the iGPU and NPU prefills sit about one rounding-noise step above the
|
||||
CPU path there (`docs/igpu-prefill.md`, `docs/npu-service.md`).
|
||||
|
||||
## Build (Docker, no Visual Studio)
|
||||
|
||||
```powershell
|
||||
powershell -File scripts\windows\Package-Windows.ps1
|
||||
```
|
||||
|
||||
Runs `deploy/Dockerfile.windows-build`: a Linux container cross-compiles the six executables for
|
||||
`x86_64-pc-windows-gnu` (mingw, runtime linked statically) and writes `dist\windows`; the script then packs
|
||||
`dist\leleka-windows-x64.zip` (about 23 MB: `bin\*.exe`, `Start-Leleka.ps1`, `README.txt`, `SHA256SUMS.txt`). The first
|
||||
build downloads the Rust and mingw packages (a few minutes). Docker Desktop's VM takes several GB of RAM while it runs:
|
||||
stop it (`docker desktop stop`) before measuring anything. A native build with the MSVC toolchain
|
||||
(`cargo build --release -p strata-control -p leleka-cpu-worker ...`) also works where Visual Studio Build Tools exist.
|
||||
|
||||
## Run
|
||||
|
||||
```powershell
|
||||
powershell -File Start-Leleka.ps1 -Model C:\models\gpt-oss-20b-MXFP4.gguf # iGPU prefill, CPU decode
|
||||
powershell -File Start-Leleka.ps1 -Model ... -Mode cpu
|
||||
powershell -File Start-Leleka.ps1 -Model ... -Mode npu -OpenVinoRoot C:\ov\openvino_toolkit_windows_2026.3.0...
|
||||
```
|
||||
|
||||
It writes a configuration, starts the control plane, waits for `/ready` (about 1.5 minutes: the 12 GB model is read once
|
||||
so requests do not page it in) and keeps running; Ctrl+C stops the control plane and its workers. Defaults and why:
|
||||
speculation on (output identical to plain decoding, up to 1.5x on copy-heavy output, within noise otherwise), 4 cache
|
||||
slots (several agents do not evict each other's prefix), threads = logical processors minus two (12 or 14 threads give
|
||||
the same decode speed: 8.74 and 8.73 tok/s medians; the low-power cores add nothing to a memory-bound loop), context
|
||||
16,384. Add `-NoSpeculate`, `-CacheSlots`, `-Context`, `-Port`, `-Bind` as needed. The control plane binds to
|
||||
127.0.0.1 by default; there is no authentication layer in this launcher.
|
||||
|
||||
Requirements: an AVX2 CPU; free memory of about 12 GB for the mapped model plus 0.05 MB x context x slots for the KV
|
||||
caches and 1-2 GB of scratch (the launcher warns when it looks short); for the iGPU a Vulkan driver with integer dot
|
||||
product support (Intel Arc / Xe graphics); for the NPU the Intel NPU driver and an unpacked OpenVINO 2026.3 runtime
|
||||
(not shipped; loaded from `-OpenVinoRoot` at run time).
|
||||
|
||||
## Verified (cross-built binaries, 2026-10-21)
|
||||
|
||||
Started with `Start-Leleka.ps1 -Mode igpu` from the Docker-built executables: ready after 78-87 s, the GPU adapter
|
||||
found, and through `/v1/responses`: a plain answer ("Paris"), a function call (`get_weather({"city":"Kyiv"})`), and
|
||||
prefix reuse (975-token prompt, second identical request: 974 cached). All completed with status `completed`.
|
||||
Per-feature tests (cargo, native MSVC build): kernels against integer references, speculation exactness, serve loop,
|
||||
control plane, real-model tests.
|
||||
|
||||
Speed on this machine: 8-12 tok/s decode on a quiet machine (LM Studio's llama.cpp CPU: 7.6-8.7 earlier on the same
|
||||
laptop), 16-17 tok/s on rewrites with speculation, prefill 14-19 tok/s on the CPU, about 60 on the iGPU and 50-55 on the
|
||||
NPU at 4,096-token prompts. The smoke run itself was slow (1.5-4 tok/s) because another WSL VM on the machine held
|
||||
about 11 GB of RAM and the model did not fit in free memory: with less than about 20 GB free the runtime pages and
|
||||
every number above is out of reach. Do not run it next to large virtual machines.
|
||||
|
||||
## Limits
|
||||
|
||||
* One decode at a time per worker; several conversations share it through cache slots, not concurrency.
|
||||
* Decode is bound by memory bandwidth: lossless decode on a single-channel laptop stops near 14 tok/s (see
|
||||
`docs/cpu-runtime.md`); 20+ tok/s needs dual-channel memory.
|
||||
* Custom (non-function) tools are not supported for this model family; tool-call arguments arrive in one piece.
|
||||
* The iGPU prefill refuses (and uses the CPU) when free memory is below its estimate; the NPU path does the same.
|
||||
* Linux x64 not built; the cross-build uses mingw, so the iGPU worker's wgpu path was exercised on that build only
|
||||
for startup and a short prompt (the long-prompt GPU path was skipped for lack of memory in the smoke run and
|
||||
was tested on the native build earlier).
|
||||
@@ -0,0 +1,42 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Builds the Windows runtime in Docker (no Visual Studio needed) and packs dist\leleka-windows-x64.zip.
|
||||
.DESCRIPTION
|
||||
1. docker build -f deploy\Dockerfile.windows-build exports the mingw cross-compiled executables to dist\windows.
|
||||
2. The zip holds bin\*.exe, Start-Leleka.ps1, README.txt and SHA256SUMS.txt. Model weights and OpenVINO are not
|
||||
included (the model is the user's own file; OpenVINO is only needed for -Mode npu).
|
||||
Docker Desktop must be running. Nothing is pushed or uploaded.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param([switch] $SkipBuild)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$root = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
|
||||
$dist = Join-Path $root 'dist'
|
||||
if (-not $SkipBuild) {
|
||||
Push-Location $root
|
||||
try {
|
||||
docker build -f deploy/Dockerfile.windows-build --target export -o type=local,dest=dist/windows .
|
||||
if ($LASTEXITCODE -ne 0) { throw 'docker build failed' }
|
||||
} finally { Pop-Location }
|
||||
}
|
||||
$stage = Join-Path $dist 'leleka-windows-x64'
|
||||
if (Test-Path $stage) { Remove-Item -Recurse -Force $stage }
|
||||
New-Item -ItemType Directory -Force (Join-Path $stage 'bin') | Out-Null
|
||||
Copy-Item (Join-Path $dist 'windows\*.exe') (Join-Path $stage 'bin')
|
||||
Copy-Item (Join-Path $PSScriptRoot 'Start-Leleka.ps1') $stage
|
||||
@"
|
||||
Leleka gpt-oss runtime for Windows x64 (experimental build, see docs/windows-runtime.md in the repository)
|
||||
|
||||
powershell -File Start-Leleka.ps1 -Model <path>\gpt-oss-20b-MXFP4.gguf
|
||||
|
||||
Serves http://127.0.0.1:8081/v1/responses. Needs about 12 GB of free memory for the model plus the KV caches
|
||||
(-Context, -CacheSlots) and an AVX2 CPU. -Mode igpu (default) prefills long prompts on the integrated GPU, -Mode cpu
|
||||
uses the CPU only, -Mode npu needs an unpacked OpenVINO runtime (-OpenVinoRoot) and an Intel NPU.
|
||||
"@ | Set-Content -Encoding ascii (Join-Path $stage 'README.txt')
|
||||
Get-ChildItem $stage -Recurse -File | ForEach-Object {
|
||||
'{0} {1}' -f (Get-FileHash $_.FullName -Algorithm SHA256).Hash.ToLower(), $_.FullName.Substring($stage.Length + 1).Replace('\', '/')
|
||||
} | Set-Content -Encoding ascii (Join-Path $stage 'SHA256SUMS.txt')
|
||||
$zip = Join-Path $dist 'leleka-windows-x64.zip'
|
||||
if (Test-Path $zip) { Remove-Item -Force $zip }
|
||||
Compress-Archive -Path (Join-Path $stage '*') -DestinationPath $zip
|
||||
"{0} {1:N1} MB" -f $zip, ((Get-Item $zip).Length / 1MB)
|
||||
@@ -0,0 +1,97 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Starts the Leleka gpt-oss runtime on Windows: the control plane (/v1/responses) with a CPU, iGPU or NPU worker.
|
||||
|
||||
.DESCRIPTION
|
||||
Writes a configuration for strata-next, starts it, waits until it is ready and keeps it running in the
|
||||
foreground (Ctrl+C stops the control plane and its workers). Nothing is installed or downloaded.
|
||||
|
||||
Modes (-Mode):
|
||||
igpu (default) leleka-igpu-worker: long prompts are prefilled on the integrated GPU, decoding on the CPU; with no
|
||||
usable GPU it serves from the CPU on its own.
|
||||
cpu leleka-cpu-worker: everything on the CPU (AVX2 / AVX-VNNI).
|
||||
npu leleka-npu-worker: long prompts are prefilled by the Intel NPU through leleka-npu-service
|
||||
(experimental; needs -OpenVinoRoot, an unpacked OpenVINO runtime, and an Intel NPU driver).
|
||||
|
||||
Defaults that matter, with the reason (docs/windows-runtime.md has the measurements):
|
||||
-Speculate on exact prompt-lookup speculative decoding; the output equals plain decoding, copy-heavy output
|
||||
(rewrites, patches) decodes up to 1.5x faster, other output is within noise.
|
||||
-CacheSlots 4 one worker keeps the KV caches of four conversations, so several agents sharing the runtime
|
||||
do not recompute each other's prefix.
|
||||
-Threads logical processors minus two (the two low-power cores add nothing to a memory-bound decode).
|
||||
.PARAMETER Model
|
||||
Path of gpt-oss-20b-MXFP4.gguf (SHA-256 65d06d31...cde53ab is the file this runtime was measured with).
|
||||
.PARAMETER BinDir
|
||||
Folder with strata-next.exe and the workers. Default: bin next to this script, else target\release of the repository.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)] [string] $Model,
|
||||
[ValidateSet('igpu', 'cpu', 'npu')] [string] $Mode = 'igpu',
|
||||
[string] $OpenVinoRoot = $env:LELEKA_OPENVINO_ROOT,
|
||||
[string] $BinDir,
|
||||
[int] $Port = 8081,
|
||||
[string] $Bind = '127.0.0.1',
|
||||
[int] $Context = 16384,
|
||||
[int] $Threads = 0,
|
||||
[int] $CacheSlots = 4,
|
||||
[switch] $NoSpeculate,
|
||||
[int] $StartupTimeoutSeconds = 300
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (-not (Test-Path -LiteralPath $Model -PathType Leaf)) { throw "model file not found: $Model" }
|
||||
if (-not $BinDir) {
|
||||
$candidates = @((Join-Path $PSScriptRoot 'bin'), (Join-Path $PSScriptRoot '..\..\target\release'), (Join-Path $PSScriptRoot '..\..\dist\windows'))
|
||||
$BinDir = $candidates | Where-Object { Test-Path (Join-Path $_ 'strata-next.exe') } | Select-Object -First 1
|
||||
}
|
||||
if (-not $BinDir -or -not (Test-Path (Join-Path $BinDir 'strata-next.exe'))) { throw 'strata-next.exe not found; pass -BinDir' }
|
||||
$BinDir = (Resolve-Path $BinDir).Path
|
||||
|
||||
$worker = @{ igpu = 'leleka-igpu-worker'; cpu = 'leleka-cpu-worker'; npu = 'leleka-npu-worker' }[$Mode]
|
||||
if (-not (Test-Path (Join-Path $BinDir "$worker.exe"))) { throw "$worker.exe not found in $BinDir" }
|
||||
if ($Mode -eq 'npu') {
|
||||
if (-not $OpenVinoRoot -or -not (Test-Path $OpenVinoRoot)) { throw 'npu mode needs -OpenVinoRoot (or LELEKA_OPENVINO_ROOT): an unpacked OpenVINO runtime' }
|
||||
if (-not (Test-Path (Join-Path $BinDir 'leleka-npu-service.exe'))) { throw "leleka-npu-service.exe not found in $BinDir" }
|
||||
}
|
||||
if ($Threads -le 0) { $Threads = [Math]::Max(1, [Environment]::ProcessorCount - 2) }
|
||||
|
||||
# the model is memory-mapped (12 GB) next to the KV caches and scratch: warn rather than start into paging
|
||||
$os = Get-CimInstance Win32_OperatingSystem
|
||||
$freeGb = [Math]::Round($os.FreePhysicalMemory / 1MB, 1)
|
||||
$needGb = [Math]::Round(12.1 + 0.05 * $Context / 1000 * $CacheSlots + 1.5, 1)
|
||||
if ($freeGb + 12 -lt $needGb) {
|
||||
Write-Warning "about $needGb GB needed (model 12.1 GB when mapped, $CacheSlots KV caches of $Context tokens, scratch) and only $freeGb GB are free: close other programs or lower -Context / -CacheSlots"
|
||||
}
|
||||
|
||||
$args = @('--model', $Model, '--ctx', "$Context", '--threads', "$Threads", '--cache-slots', "$CacheSlots")
|
||||
if (-not $NoSpeculate) { $args += '--speculate' }
|
||||
if ($Mode -eq 'npu') { $args += @('--openvino-root', $OpenVinoRoot) }
|
||||
|
||||
$work = Join-Path ([IO.Path]::GetTempPath()) 'leleka-runtime'
|
||||
New-Item -ItemType Directory -Force $work | Out-Null
|
||||
$configPath = Join-Path $work 'config.json'
|
||||
@{
|
||||
bind = "${Bind}:$Port"; model = 'gpt-oss-20b'
|
||||
engine = @{
|
||||
executable = (Join-Path $BinDir "$worker.exe"); args = $args; gptoss_gguf = (Resolve-Path $Model).Path
|
||||
startup_timeout_s = $StartupTimeoutSeconds; generation_timeout_s = 1800
|
||||
}
|
||||
} | ConvertTo-Json -Depth 5 | ForEach-Object { [IO.File]::WriteAllText($configPath, $_, (New-Object Text.UTF8Encoding($false))) }
|
||||
|
||||
Write-Host "Leleka: $Mode worker, $Threads threads, context $Context, $CacheSlots cache slots, speculation $(if ($NoSpeculate) {'off'} else {'on'})"
|
||||
$server = Start-Process (Join-Path $BinDir 'strata-next.exe') -ArgumentList @('serve', '--config', $configPath) -PassThru -NoNewWindow
|
||||
try {
|
||||
$deadline = (Get-Date).AddSeconds($StartupTimeoutSeconds + 30)
|
||||
$ready = $false
|
||||
while ((Get-Date) -lt $deadline -and -not $server.HasExited) {
|
||||
try { if ((Invoke-RestMethod "http://${Bind}:$Port/ready" -TimeoutSec 2) ) { $ready = $true; break } } catch { }
|
||||
Start-Sleep 2
|
||||
}
|
||||
if (-not $ready) { throw 'the runtime did not become ready (see the messages above)' }
|
||||
Write-Host "Ready: http://${Bind}:$Port/v1/responses (health: /health, readiness: /ready). Ctrl+C stops it."
|
||||
$server.WaitForExit()
|
||||
}
|
||||
finally {
|
||||
if (-not $server.HasExited) { Stop-Process -Id $server.Id -Force }
|
||||
}
|
||||
Reference in New Issue
Block a user