ann_router.detect module
Hardware probing — fill in the hardware criterion automatically.
The router’s decision changes with the accelerator: a GPU unlocks FAISS batch
search, Apple Silicon makes turbovec’s Rust/NEON path especially attractive, and
a plain CPU box narrows the field. Rather than make the caller hand-classify
their machine, this module probes it the same way the best-engine-ai-helper
sibling’s detect.py does — cheap subprocess/library calls with graceful
fallbacks, never raising, always returning one of the three HardwareName
values.
Consumes: os_helper (worker count), optional psutil/torch if present.
Produces: detect_hardware(), hardware_report().
Author: Warith Harchaoui <warith.harchaoui@deraison.ai>
- ann_router.detect.detect_hardware()[source]
Classify the local accelerator into the router’s three-way taxonomy.
- Returns:
"gpu"when a CUDA GPU is found (it dominates the batch regime), else"apple_silicon"on M-series Macs, else"cpu".- Return type:
{“gpu”, “apple_silicon”, “cpu”}
Examples
>>> detect_hardware() in {"gpu", "apple_silicon", "cpu"} True
- ann_router.detect.hardware_report()[source]
Return a small JSON-ready dict describing the host for the CLI/API.
- Returns:
os,machine,cpu_count,workersand the classifiedhardwarelabel.- Return type:
Examples
>>> report = hardware_report() >>> report["hardware"] in {"gpu", "apple_silicon", "cpu"} True