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
@@ -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