Skip to content

fix(serve): accept --device mps for Apple Silicon - #134

Open
o2yama wants to merge 1 commit into
StarTrail-org:mainfrom
o2yama:fix/serve-device-mps
Open

fix(serve): accept --device mps for Apple Silicon#134
o2yama wants to merge 1 commit into
StarTrail-org:mainfrom
o2yama:fix/serve-device-mps

Conversation

@o2yama

@o2yama o2yama commented Aug 1, 2026

Copy link
Copy Markdown

Problem

The index build CLI accepts --device mps since #73 / #109, but the serve CLI was left behind: serve/src/pixelrag_serve/api.py still has choices=["cpu", "cuda"], so on Apple Silicon pixelrag serve --device mps fails at argument parsing:

pixelrag serve: error: argument --device: invalid choice: 'mps' (choose from 'cpu', 'cuda')

The downstream logic already handles non-cpu devices correctly (dtype = torch.float32 if device == "cpu" else torch.bfloat16), so the argparse whitelist is the only blocker.

Fix

Add "mps" to the --device choices and update the help text. No other changes needed.

Testing

  • uvx ruff check . passes
  • pytest tests/ — 87 passed; 5 pre-existing failures in test_department_filter.py reproduce identically on unmodified main (unrelated to this change)
  • Verified on real hardware: M3 MacBook Air (8 GB RAM, macOS 14.4). With this patch, pixelrag serve --device mps loads Qwen3-VL-Embedding-2B in bfloat16 (~4.3 GB), and search over a prebuilt FAISS index responds in 0.2–1.2 s per query after warmup. Retrieval scores match CPU/float32 results from the same index within ±0.001.

The index build CLI already accepts mps (StarTrail-org#73, StarTrail-org#109), but the serve CLI
was left with choices=["cpu", "cuda"], so pixelrag serve --device mps
fails at argument parsing. The downstream dtype logic already handles
non-cpu devices (bfloat16), so widening the choices list is sufficient.

Verified on an M3 MacBook Air (8 GB): the model loads in bfloat16 on MPS
and search latency is 0.2-1.2 s per query after warmup.
@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

@o2yama is attempting to deploy a commit to the andylizf's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant