On a GPU (Metal, Vulkan), privacy-filter.cpp read the whole 1.6 GB
GGUF into a CPU ggml context, copied every tensor into the device's
buffer, and kept the CPU copy "as source" for as long as pf-serve ran.
#3590's Mac held 4.7 GB of physical footprint idle.
patches/weights-once.patch opens the GGUF metadata-only when the
backend isn't the CPU, and reads each tensor from the file straight
into the device's buffer through one 16 MB chunk. The CPU backend
still reads it whole and uses that buffer in place, as before.
Run: build.sh for every target on CI (privacy-filter run 40188759504,
green on all five), then a probe (start pf-serve, classify 7 texts in
en/zh/code/cards plus a 57K and a 20K text, 20 hot requests, 3 long
ones, read memory after 5 s idle) on the released pf-v1 and on this
commit's CI build, with the pinned model (sha256 80efc180…):
Mac M4 Pro, Metal, GGML_METAL_NO_RESIDENCY=1 as magpie starts it:
idle phys_footprint 4777 MB -> 1683 MB, RSS 4798 -> 1706 MB
hot request median 9.0/13.8 ms -> 10.8/9.9 ms (two runs each,
load average ~180, so noisy); long 1.5-1.9 s both
Mac, CPU: 1852 MB both, as before
Windows, AMD 8060S, Vulkan:
private bytes 6629 MB -> 1968 MB, working set 3258 -> 174 MB
hot median 4.2-4.7 ms both, long 0.79-0.85 s both, load 1.2 -> 0.8 s
Windows, CPU: 1810 MB working set both
The spans are byte-identical before and after on each backend (Metal,
Mac CPU, Vulkan, Windows CPU; each backend's own as before).
Not tried: Linux's pf-serve-vulkan on a real GPU (the same code path
as Windows' Vulkan); linux-arm64 and darwin-amd64 run on the CPU only,
which this doesn't change, and were only built.
ggml-vulkan finds SPIRV-Headers' package but doesn't link its target, so
its include path never reached the compiler and both Vulkan builds
(linux-amd64, windows-amd64) failed on 'spv has not been declared'.
CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES puts it in.
Run: a syntax-only compile of ggml-vulkan.cpp's include block with the
fetched headers finds spirv/unified1/spirv.hpp; the CI run is the real
test.
ggml-vulkan asks for SPIRV-Headers' CMake config, so build.sh installs the
pinned SPIRV-Headers into .work and points cmake at it. Ubuntu 22.04 has no
glslc package; build.sh takes it from LunarG's 1.4.309.0 Linux SDK, checked
against the sha256 LunarG publishes. First CI run failed on both (run
39097128531).
pf-serve loads privacy-filter.cpp's GGUF model on the GPU (Metal, Vulkan)
when there is one, else the CPU, warms the kernels up, writes one JSON
hello line and then answers length-prefixed batches of texts with byte
spans. internal/pii (next) downloads and runs it on demand.
build.sh pins privacy-filter.cpp 735a6c28 (MIT) and patches two upstream
build bugs (ner.h lacks <cstdint>; ggml's power-throttling block needs a
newer mingw). The privacy-filter workflow builds darwin-arm64 (Metal),
darwin-amd64, linux-amd64/arm64 and windows-amd64 (cross, mingw); the
Vulkan targets get pf-serve-vulkan plus a CPU-only pf-serve for machines
with no Vulkan loader. A pf-v* tag publishes them as a prerelease.
Run: build.sh darwin-arm64 on an M4 Pro; pfclient.py against the q8 model:
hello in 5.4s (file cached), warm requests 9-18ms on Metal for Chinese
person/address/phone, email, secret and a 3 KB text. Other targets: not
built locally yet; this push is their first CI build.