makepad/tools/qwen38/serve_start.ps1
Admin 384d0e031c tools: the Builder replaces makepad_loader, the web server moves to makepad/webserver, fleet scripts, docs and the workspace members
tools/makepad_builder replaces tools/makepad_loader: one build target
shared across app builds, workspace package selection, checkout
progress on the public Git API, detached built apps with a completion
state, waits for Windows security scans, manual retry after compiler
locks, dedicated-folder installer checks, catalog and runtime fixes.
tools/web_server and its scripts leave for github.com/makepad/webserver.
Arch USB clone/restore scripts, the qwen38 box scripts and the G-belt
serial test join tools/. docs/agents records the agent workflow and the
remote-control handoff protocol; AGENTS.md forbids vendored sources and
bulk imports. Cargo.toml lists apps/wm-dyn, libs/code_language,
libs/search, libs/tar, libs/loader_bundle and tools/makepad_builder,
and drops the two removed crates.

Squashed from work:
- Share Builder target across Makepad app builds
- Fix Builder workspace package selection
- Align Builder checkout progress with public Git API
- Detach built apps and show completion state
- Wait for Windows security scans
- Offer manual retry after Windows compiler locks
- docs: the agent workflow of record and the remote-control handoff protocol
- builder: dedicated-folder installer checks, catalog and runtime fixes; Windows job objects hold c_void handles
- tools: Arch USB clone/restore scripts, the qwen38 box scripts, and the G-belt serial test
- tools: the web server moves to makepad/webserver
- AGENTS.md: no vendored sources or bulk imports in the tree

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-18 12:17:59 +02:00

58 lines
3 KiB
PowerShell

# Launch llama-server detached at the firewall-allowed path with VRAM sampler + cold-load timing.
# args: [quant-file-basename] [mmproj-basename|none] [port] [extra args joined]
param(
[string]$Model = 'Qwen3.8-27B-Q4_K_M.gguf',
[string]$Mmproj = 'mmproj-Qwen3.8-27B-BF16.gguf',
[int]$Port = 8090,
[string]$Draft = 'none'
)
$ErrorActionPreference = 'Stop'
$exe = 'C:\Users\playe\llama.cpp\build\bin\release\llama-server.exe'
$out = 'C:\ai\models\qwen38'
$keyfile = 'C:\ai\qwen38\api_key.txt'
if (-not (Test-Path $keyfile)) {
$k = -join ((1..48) | ForEach-Object { '{0:x}' -f (Get-Random -Maximum 16) })
Set-Content -Path $keyfile -Value $k -NoNewline -Encoding ascii
}
$key = (Get-Content $keyfile -Raw).Trim()
# stop any previous llama-server we launched
Get-Process llama-server -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 2
# VRAM sampler: 1s cadence, 3h cap, own log
$samp = @'
$log = "C:\ai\qwen38\vram.log"
for ($i = 0; $i -lt 10800; $i++) {
$u = (nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits).Trim()
Add-Content -Path $log -Value ((Get-Date -Format "HH:mm:ss.f") + " " + $u)
Start-Sleep -Seconds 1
}
'@
Set-Content -Path C:\ai\qwen38\vram_sampler.ps1 -Value $samp -Encoding UTF8
Remove-Item C:\ai\qwen38\vram.log -ErrorAction SilentlyContinue
$r0 = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = 'cmd /c "powershell -NoProfile -ExecutionPolicy Bypass -File C:\ai\qwen38\vram_sampler.ps1"' }
Write-Output ("VRAM_SAMPLER pid=" + $r0.ProcessId)
$baseline = (nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits).Trim()
Write-Output ("VRAM_BASELINE_MB " + $baseline)
# server launch
$args8 = "-m $out\$Model --host 0.0.0.0 --port $Port --api-key $key -ngl 99 -c 32768 -ctk q8_0 -ctv q8_0 -fa on --jinja --reasoning-format auto -np 1 --alias qwen3.8-27b"
if ($Mmproj -ne 'none') { $args8 += " --mmproj $out\$Mmproj" }
if ($Draft -ne 'none') { $args8 += " --model-draft $out\$Draft" }
Remove-Item C:\ai\qwen38\server.log -ErrorAction SilentlyContinue
$cmd = 'cmd /c ""' + $exe + '" ' + $args8 + ' >> C:\ai\qwen38\server.log 2>&1"'
$t0 = Get-Date
$r = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = $cmd }
Write-Output ("SERVER_LAUNCH pid=" + $r.ProcessId + " rc=" + $r.ReturnValue + " port=" + $Port + " model=" + $Model + " mmproj=" + $Mmproj + " draft=" + $Draft)
# cold-load: poll /health until 200
$ready = $false
for ($i = 0; $i -lt 600; $i++) {
Start-Sleep -Milliseconds 500
try {
$resp = Invoke-WebRequest -Uri ("http://127.0.0.1:" + $Port + "/health") -UseBasicParsing -TimeoutSec 2
if ($resp.StatusCode -eq 200) { $ready = $true; break }
} catch { }
}
$dt = ((Get-Date) - $t0).TotalSeconds
if ($ready) { Write-Output ("COLD_LOAD_SECONDS " + [math]::Round($dt,1)) } else { Write-Output "SERVER_NOT_READY_AFTER_300S"; Get-Content C:\ai\qwen38\server.log -Tail 25 }
$used = (nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits).Trim()
Write-Output ("VRAM_AFTER_LOAD_MB " + $used)
Get-Content C:\ai\qwen38\server.log -Tail 8