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.
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
# Builds pf-serve, the program that runs Settings → Privacy's local
|
||||
# masking model (native/privacy-filter, internal/pii), for each system.
|
||||
# A change to it is built on every push; a pf-v* tag publishes the zips as
|
||||
# a prerelease of this repo, never Latest, whose sha256s internal/pii pins.
|
||||
name: privacy-filter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, "pf/**"]
|
||||
paths: ["native/privacy-filter/**", ".github/workflows/privacy-filter.yml"]
|
||||
tags: ["pf-v*"]
|
||||
pull_request:
|
||||
paths: ["native/privacy-filter/**", ".github/workflows/privacy-filter.yml"]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { target: darwin-arm64, os: macos-15 }
|
||||
- { target: darwin-amd64, os: macos-15 }
|
||||
# the oldest glibc a runner has, so the program runs on older systems too
|
||||
- { target: linux-amd64, os: ubuntu-22.04 }
|
||||
- { target: linux-arm64, os: ubuntu-22.04-arm }
|
||||
- { target: windows-amd64, os: ubuntu-24.04 }
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: tools (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install ninja
|
||||
- name: tools (Linux)
|
||||
if: startsWith(matrix.target, 'linux')
|
||||
run: sudo apt-get update && sudo apt-get install -y ninja-build libvulkan-dev glslc zip
|
||||
- name: tools (Windows, cross)
|
||||
if: matrix.target == 'windows-amd64'
|
||||
run: sudo apt-get update && sudo apt-get install -y ninja-build mingw-w64 glslc zip
|
||||
- name: build
|
||||
run: native/privacy-filter/build.sh ${{ matrix.target }} pf-serve-${{ matrix.target }}.zip
|
||||
- name: starts
|
||||
# each program the runner can start runs to its usage line
|
||||
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
|
||||
[ -f "$p" ] || continue
|
||||
./"$p" | tee out.txt; grep -q usage out.txt
|
||||
done
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: pf-serve-${{ matrix.target }}
|
||||
path: pf-serve-${{ matrix.target }}.zip
|
||||
|
||||
release:
|
||||
if: startsWith(github.ref, 'refs/tags/pf-v')
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
merge-multiple: true
|
||||
- name: publish
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
sha256sum pf-serve-*.zip | tee SHA256SUMS
|
||||
gh release create "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" --prerelease --latest=false \
|
||||
--title "pf-serve $GITHUB_REF_NAME" \
|
||||
--notes "pf-serve, which runs the local masking model of Settings → Privacy (native/privacy-filter). Not a magpie release: magpie downloads these itself, checked against the sha256s in internal/pii." \
|
||||
pf-serve-*.zip SHA256SUMS
|
||||
Reference in New Issue
Block a user