From 697335d8ee5e4441e8289ff0d9827993fb800e5a Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 1 Nov 2026 08:05:34 +0800 Subject: [PATCH] native: each x86 target gets pf-serve-base, built for SSE4.2 alone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .github/workflows/privacy-filter.yml | 2 +- native/privacy-filter/build.sh | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/privacy-filter.yml b/.github/workflows/privacy-filter.yml index 09c6db975..efa90dbaf 100644 --- a/.github/workflows/privacy-filter.yml +++ b/.github/workflows/privacy-filter.yml @@ -48,7 +48,7 @@ jobs: if: matrix.target != 'windows-amd64' && matrix.target != 'darwin-amd64' run: | mkdir t && cd t && unzip -q ../pf-serve-${{ matrix.target }}.zip - for p in pf-serve pf-serve-vulkan; do + for p in pf-serve pf-serve-vulkan pf-serve-base; do [ -f "$p" ] || continue ./"$p" | tee out.txt; grep -q usage out.txt done diff --git a/native/privacy-filter/build.sh b/native/privacy-filter/build.sh index 35aa7eaee..2aed10b08 100755 --- a/native/privacy-filter/build.sh +++ b/native/privacy-filter/build.sh @@ -7,7 +7,11 @@ # windows-amd64) gets two programs: pf-serve-vulkan, linked to the Vulkan # loader the GPU's driver installs, and pf-serve, the CPU's alone, for a # computer with no loader, where pf-serve-vulkan can't start at all. -# darwin-arm64's pf-serve uses Metal. +# darwin-arm64's pf-serve uses Metal. Each x86 target also gets +# pf-serve-base, built for SSE4.2 alone: pf-serve's AVX2, FMA, F16C and +# BMI2 end it with SIGILL on a CPU without them (a Celeron, a Pentium, a +# Mac before Haswell) and under Rosetta before macOS 15, and magpie runs +# pf-serve-base there (internal/pii's fullX86). set -euo pipefail PF_REPO=https://github.com/localai-org/privacy-filter.cpp @@ -96,6 +100,7 @@ build() { } x86=(-DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_F16C=ON -DGGML_BMI2=ON) +base=(-DGGML_SSE42=ON -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF -DGGML_BMI2=OFF) case $target in darwin-arm64) build pf-serve -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \ @@ -104,12 +109,15 @@ case $target in darwin-amd64) build pf-serve -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_OSX_ARCHITECTURES=x86_64 \ -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 -DGGML_METAL=OFF -DGGML_BLAS=OFF "${x86[@]}" + build pf-serve-base -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_OSX_ARCHITECTURES=x86_64 \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 -DGGML_METAL=OFF -DGGML_BLAS=OFF "${base[@]}" ;; linux-amd64) fetch_vulkan static=(-DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++") build pf-serve "${static[@]}" "${x86[@]}" build pf-serve-vulkan "${static[@]}" "${x86[@]}" "${vkargs[@]}" + build pf-serve-base "${static[@]}" "${base[@]}" ;; linux-arm64) build pf-serve -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" @@ -120,6 +128,7 @@ case $target in win=(-DCMAKE_TOOLCHAIN_FILE="$here/mingw.cmake" -DCMAKE_C_FLAGS=-D_WIN32_WINNT=0x0A00 -DCMAKE_CXX_FLAGS=-D_WIN32_WINNT=0x0A00) build pf-serve "${win[@]}" "${x86[@]}" build pf-serve-vulkan "${win[@]}" "${x86[@]}" "${vkargs[@]}" -DVulkan_LIBRARY="$vk/lib/libvulkan-1.a" + build pf-serve-base "${win[@]}" "${base[@]}" ;; *) echo "unknown target $target" >&2