# Measure inference on Apple Silicon The benchmark calls Keystone's CLIP encoders, YOLOX detector, and caption client directly. It uses three generated JPEGs and three fixed search queries unless you supply local images with repeated `--image` options. It does not contact Protect or need footage, a database, or a running Keystone service. Install Keystone from this checkout into a Python virtual environment. Create a separate benchmark configuration so model downloads and compiled caches stay outside your live Keystone state. ```yaml state_dir: ./benchmark-state acceleration: provider: cpu vision: provider: ollama base_url: http://127.0.0.1:11434 model: qwen3.5:4b-q4_K_M ``` Save it as `benchmark.yaml` and run each workload in its own process. The first CLIP and YOLOX runs download the pinned weights. Start your configured vision server and load its model before running the caption benchmark. ```sh python scripts/benchmark-inference.py clip-image --config benchmark.yaml --iterations 60 python scripts/benchmark-inference.py clip-image --config benchmark.yaml --batch-size 4 --iterations 30 python scripts/benchmark-inference.py clip-text --config benchmark.yaml --iterations 150 python scripts/benchmark-inference.py detection --config benchmark.yaml --iterations 80 python scripts/benchmark-inference.py caption --config benchmark.yaml --iterations 20 ``` The JSON output includes first-call latency, warm median and p95 latency, requests per second, and peak RSS. First-call latency includes any model download or compilation, so prefetch the models and record whether you reused a compiled cache before comparing startup times. With image batches, multiply requests per second by batch size to get images per second. To compare accelerators, change the relevant configuration, keep the inputs and batch size fixed, and check the reported provider for fallback. CPU percentage uses one fully occupied core as 100%. On Apple Silicon, the benchmark also reports estimated CPU joules per call and average CPU watts from macOS process accounting. The CPU, energy, and peak RSS fields cover the Python process. Request latency includes any work in an accelerator helper or a vision server. Repeated frames can benefit from caching in the vision server. [Apple XNU CPU resource accounting](https://github.com/apple-oss-distributions/xnu/blob/main/doc/observability/recount.md) For whole-machine power, use a wall-power meter on the target Mac mini. Run each workload for at least a minute with the machine otherwise idle and record an idle reading under the same conditions. Where available, `sudo powermetrics --samplers cpu_power -i 1000` reports estimated SoC power including CPU, GPU, and Neural Engine for the sampling interval. Use camera and backfill workloads together when measuring the effect on live detection latency. ## Reference CPU run These measurements use an M5 Max with macOS 27.2.1, ONNX Runtime 1.32.0, and the generated inputs. CLIP used four CPU threads and YOLOX-M used two. | Workload | Warm p50 | Warm p95 | CPU time per request | Estimated CPU energy per request | | --- | ---: | ---: | ---: | ---: | | CLIP fp32, one image | 102.37 ms | 117.47 ms | 411.94 ms | 1.353 J | | CLIP fp32, four images | 390.11 ms | 402.63 ms | 1533.52 ms | 4.972 J | | CLIP fp32, text query | 4.57 ms | 7.26 ms | 18.70 ms | 0.065 J | | YOLOX-M, one frame | 91.67 ms | 95.66 ms | 183.28 ms | 0.772 J | On the same Mac, Keystone sent three frames to a preloaded `mlx-community/Qwen3.5-4B-4bit` model on MLX-VLM 0.8.2. The first request took 7.38 s. Over 12 repeated-input requests with the server's default vision cache, median latency was 970 ms and p95 was 1182 ms. ## Evaluating Core AI for captions Apple's prototype `llm-server` accepts multiple inline images through its OpenAI-compatible API. On a Mac with macOS 27 or later, Xcode 27 or later, and the Xcode Metal Toolchain, you can use it to evaluate the Qwen3-VL-2B-Instruct export with Keystone's caption benchmark. [Apple's vision-model exports](https://github.com/apple/coreai-models/blob/6d22d570f0da321b461771d597638acec2fa6624/models/vlm/README.md) ยท [Apple's server interface](https://github.com/apple/coreai-models/blob/6d22d570f0da321b461771d597638acec2fa6624/swift/Sources/Tools/llm-server/LLMServerMain.swift) ```sh git clone https://github.com/apple/coreai-models.git cd coreai-models git checkout --detach 6d22d570f0da321b461771d597638acec2fa6624 uv run --python 3.13 --no-dev coreai.vlm.export qwen3-vl swift run -c release llm-server --model exports/qwen3_vl_2b --server-model-name qwen3-vl-2b --port 8091 ``` Point the benchmark configuration at the loopback server. Apple supports images with text prompts and requires unconstrained generation for these requests. Keystone's prompt still asks for JSON captions. [Apple's image request handling](https://github.com/apple/coreai-models/blob/6d22d570f0da321b461771d597638acec2fa6624/swift/Sources/Tools/llm-server/ChatHandler.swift) ```yaml vision: provider: openai-compatible base_url: http://127.0.0.1:8091/v1 model: qwen3-vl-2b extra_body: response_format: null ``` Caption latency and quality for this Core AI configuration remain unmeasured. Use the same Qwen3-VL checkpoint and frames on each backend to compare the runtimes.