Files
magpie/native/privacy-filter
yetone 642d430ecb native: pf-serve on a GPU reads the model once, not twice (#3590)
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.
2026-10-25 19:52:47 +08:00
..