lazyeo on Discord (Apple M2, 16 GB, macOS 27.0.1, since v0.1.1577): with
Settings → Privacy's local model on, every request, even the first after
a restart, waited out the gateway's 2-minute 504 ("still loading"), and
Settings showed "pf-serve ended: ggml_metal_device_init: tensor API
disabled for pre-M5 and pre-A19 devices … recommendedMaxWorkingSetSize".
Their goroutine dump has startOne(path, cpu=true): a GPU pf-serve had
failed and every request was loading the CPU one.
What was wrong:
- macOS had one pf-serve candidate, the Metal one; a load that hung on
the GPU waited out loadTimeout (3m) with no CPU to fall back to.
- The error was pf-serve's stderr, which on every pre-M5 Mac starts with
ggml's Metal init lines (the CPU mode too), so a kill by magpie's own
classify watchdog read as a Metal crash. On an M4 Pro the CPU mode
reads ~1.4 KB/s, below classifyTimeout's 4 KB/s, so a slower Mac's CPU
pf-serve is killed by magpie on larger requests.
- Each failed request left the next one to load again, so a model that
keeps failing held every request for its full 2 minutes.
Changes (internal/pii):
- candidates(): the GPU one (Vulkan, or macOS's Metal pf-serve), then
pf-serve with PF_DEVICE=cpu. A GPU load gets gpuLoadTimeout (40s, inside
the gateway's 2m); a GPU that fails or hangs moves the run to the CPU
and sets gpuLost, as one dying in classify already did.
- died(): "didn't answer in Xs (N KB on the CPU), so magpie ended it"
when the watchdog killed it, else "ended (exit status/signal)", then
the last 3 stderr lines that aren't ggml/Metal/Vulkan startup chatter
(a line saying error/fail/assert/abort is always kept).
- After a failure, FindContext holds requests back at once with that
error (before and after taking the turn), until a retry 30s later,
doubling to 10m while it keeps failing; a success or Stop resets it.
The request is still held, not sent masked by the rules alone; the
message says how to turn the model off.
- pii.go's comment and docs/subsystems/gateway-routing.md say so.
- Tests: a cleanup race in fakeInstall, and the seam above (cache.go
gets disk.saves).
Run (worktree at origin/main a6c808b68 + this, sandbox HOME):
- go test -count=1 ./internal/pii/ ok; -race -count=1 ok (54.7s).
- Broken by hand, each red, then restored:
- old candidates (macOS Metal alone, plain one not forced to CPU):
TestHungGPULoadMovesToCPU both subtests "didn't load in 3s on the
GPU" and TestVulkanThatWontStartFallsBack starts = [vulkan MTL0,
pf-serve MTL0].
- not remembering the fallen-back GPU: TestHungGPULoadMovesToCPU red
(starts = [CPU] only after Stop, GPUError empty).
- old died(): TestEndedForSlownessSaysSo and
TestDeathSaysExitAndLastWords red with the M2's Metal lines as the
error.
- heldBack() returning nil: TestFailedModelHoldsRequestsBackAtOnce red
("didn't answer in 300ms", a queued request loaded again).
- Real pf-serve and model (pf-v2-darwin-arm64) on an M4 Pro, macOS 26.2,
outside magpie: GPU load 9.9s cold / 0.86s warm, 200 KB in 2.3s; CPU
load ~20s, 50 KB in 36.4s; the CPU mode's stderr also has the
"tensor API disabled for pre-M5" lines.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... ok; go build for darwin, linux (nogui),
windows ok.
- After the first full run, TestHungGPULoadMovesToCPU was red at load
~220 (the stand-in hadn't logged its GPU start inside a 3s budget). It
now gives the GPU load up once the stand-in has started on it
(`giveUp`, a seam over time.After), not after a duration: 8 of 8 green
at load 220, and still red with the old candidates.
- -race then caught fakeInstall's cleanup restoring dir while the disk
cache's 2s save timer, already fired, was writing (cleanup stopped
only a timer that hadn't fired). disk.saves now counts a timer's
write until it is done, and cleanup waits on it. -race -count=3
./internal/pii/ ok (143.9s).
- go test ./internal/gateway/ ./internal/redact/ ./plugins/redact/ ok
(gateway 601.5s); internal/masking has no tests.
- Full suite: not completed. go test ./... -timeout 45m at 18:06
(load 118, no other Go suite running) failed to build 16 packages and
failed TestWarm, proc's TestEndProbesThenExitLeavesNothing and
settings' TestSaveConcurrent, all "no space left on device": the
disk was at 189 MB free (900 of 926 GB used, not by this run). By the
time space came back, other sessions' suites were running (a gateway
run, a -p 3 multi-package run, the GUI suite), so a second full run
would have broken one suite per machine. Every package that ran and
isn't named above was ok.
- Rebased on 7d075df9d (pushed head's parent): go build and
go test ./internal/pii/ ./internal/redact/ ok there.
Not tried: an M2 or macOS 27 (no such machine), so why lazyeo's GPU
pf-serve failed first is still unknown; the new error and gpuLost will
show it. No known llama.cpp/ggml issue for macOS 27 or the pre-M5 tensor
line turned up. A CPU too slow for a large request is still killed by
classifyTimeout; it now says so and holds the requests after it back at
once.