Commit Graph
5 Commits
Author SHA1 Message Date
yetone 697335d8ee native: each x86 target gets pf-serve-base, built for SSE4.2 alone
echo_yip on X: Settings → Privacy's model would not start, "pf-serve
(Metal): signal: illegal instruction" and then the same on the CPU.
pf-serve for x86 (darwin-amd64, linux-amd64, windows-amd64) is built
with GGML_AVX, AVX2, FMA, F16C and BMI2 on and GGML_NATIVE off, so on a
CPU without AVX2 (a Celeron or Pentium, a Mac before Haswell) and under
Rosetta before macOS 15, which has no AVX at all, ggml's first vector
instruction ends it with SIGILL. Two tries, Metal then CPU, are what
magpie's Mac start does, so this was a Mac: most likely the Intel DMG
on Apple silicon.

build.sh now also builds pf-serve-base for each x86 target, with SSE4.2
on and AVX, AVX2, FMA, F16C and BMI2 off, and puts it in the same zip.
The workflow's start check runs it too where the runner can. magpie
picks it on a CPU without them in the next commit; a pf-v3 tag
publishes these zips.

Run: privacy-filter workflow on pf/base, run 41255213505, green on
all five targets; darwin-amd64, linux-amd64 and windows-amd64 each
have pf-serve-base in their zip. objdump -d of the CI binaries:

  pf-serve       ymm 20613 / 12222 / 12230, vfmadd 859 / 714 / 686
  pf-serve-base  ymm 0, VEX-encoded xmm 0, vfmadd 0 (all three)

Linux box (magpie-desktop), the pinned model (sha256 80efc180...),
PF_DEVICE=cpu, qemu-x86_64-static 8.2 -cpu Nehalem (SSE4.2, no AVX):
  pf-v2's released pf-serve:   signal 4 (Illegal instruction), 132
  this build's pf-serve:       signal 4, 132
  this build's pf-serve-base:  {"device":"cpu",...}, exit 0 (135 s
                               under emulation)
Natively, pf-serve and pf-serve-base find the same spans in an
English, a Chinese and a secrets text (names, email, phones, address,
password).

Not tried: a real CPU without AVX2, and a Mac before macOS 15 under
Rosetta; qemu stands in for the first.
2026-11-01 08:22:44 +08:00
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
yetone cac6e358a7 native: pf-serve-vulkan is built with the SPIR-V headers build.sh fetched
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.
2026-10-18 12:41:38 +08:00
yetone 1f98f5ba65 native: pf-serve-vulkan finds SPIR-V's headers, and glslc on Ubuntu 22.04
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).
2026-10-18 12:32:53 +08:00
yetone ffa292c7d3 native: pf-serve, a sidecar that runs OpenAI's Privacy Filter for masking (#1977)
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.
2026-10-18 12:26:55 +08:00