adityanandanx / adityanandanx/heimdall
Map: NPU engine — run RapidOCR on the Lunar Lake NPU (proto worktree)
- Vorherrschende Sprache
- Python
- Sterne
- 0
- Forks
- 0
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
## Destination
Decide whether heimdall's OCR **engine** should run on the Intel Lunar Lake NPU instead of the CPU. Walk: build a **standalone prototype** in the proto worktree (`proto/rapid-ocr-npu`) that runs the exact bundled RapidOCR det/cls/rec ONNX models on the NPU (via the OpenVINO installed at `/opt/intel/openvino`) and on the current onnxruntime/CPU path, over real captured frames; then **decide the default**: beat-or-match CPU latency with reasonable init/robustness → **NPU replaces the default OCR engine**; else keep CPU. The decision, with recorded numbers behind it, is the end of the map — implementation/integration is a follow-up effort.
## Notes
- Domain: heimdall v2 capture pipeline. Current engine: `rapidocr>=3.9.2` (onnxruntime, CPU), lazy singleton `rapid_ocr(img)` at `src/heimdall/capture/ocr.py:20`, invoked in the extraction thread (`daemon.py:695`) → `frames.ocr_text/ocr_engine='rapid'` → FTS5. Swap seam: `CaptureTools.rapid_ocr` (`daemon.py:53`). OCR is the a11y-blind fallback; a11y wins otherwise.
- **Hardware**: Core Ultra 200V (Lunar Lake) NPU — PCI `8086:7D1D`, driver `intel_vpu`, `/dev/accel/accel0`, kernel 6.12.69 cachyos-lts. Arc iGPU **not in scope** here (it hosts the llama Vulkan server); this effort is NPU-only.
- OpenVINO toolkit installed at `/opt/intel/openvino` (runtime + samples + python). uv cache carries `onnxruntime 1.28.0-cp313` and `openvino 2026.2.0-cp311` wheels — both engines resourceable from local cache.
- Worktree: branch `proto/rapid-ocr-npu`, path `/home/aditya/stuff/heimdall-npu`. Nothing lands on main from the prototype itself; the _decision_ becomes the map's deliverable.
- Do not disturb the running `serve`/`capture` loop on main; bench against a throwaway read-only copy of frames from `~/.heimdall/frames`.
- Benchmark-fairness (user mandate, from v2 map): pin system state, record it alongside every number, no retroactive rule changes. Breadth statements to measure: init/cold-start, per-frame p50/p95, CPU-usage, stability over a session.
- Refer to every child by issue name, never bare id.
- Skills to consult per session: `/wayfinder`, `/grilling`, `/research`, `/domain-modeling`.
## Decisions so far
- [Research: NPU path for bundled RapidOCR ONNX models (OpenVINO on Lunar Lake)](https://github.com/adityanandanx/heimdall/issues/66) — **direct OpenVINO static-shape NPU engine works end-to-end on all three bundled models** (det ~46ms / cls ~2.5ms / rec ~7ms steady at typical window shapes; cold compile 0.7–1.8s; `core.available_devices = [CPU, GPU, NPU]`). `onnxruntime-openvino` EP is a **dead end for the rec model** (dynamic-shape bounds bug — `Input for name 'x' is not found` even on CPU; vpux crash with dynamic shapes), so the EP swap is off the table; rapidocr's packaged OpenVINO engine hardcodes `device_name="CPU"` (`inference_engine/openvino/main.py:65`). Full verified numbers + machine snapshot: `docs/research/rapidocr-npu-viability.md` (branch `research/rapid-ocr-npu-path`).
## Not yet specified
- Whether NPU needs a compile-on-shape-change strategy: real windows are arbitrary sizes; if the det model's dynamic input shape forces per-window recompilation (intolerable), the "static shape normalization" (resize/crop to a fixed canvas + tx) path — to be answered by the prototype bench.
- `ocr_engine` opt value scheme (`rapid|rapid-npu`) and the auto-fallback-to-CPU behavior on NPU watchdog failures — decide with the prototype's failure-mode record.
- Whether quantization (FP16/INT8 on NPU) to cut latency; in scope for the decision, but the op-set story isn't sharp until the prototype measures the unquantized baseline.
- Where the OpenVINO compiled-blob / IR cache lives (`CACHE_DIR` semantics), and whether re-compile per shape is affordable for capture-time — prototype ticket owns this.
## Out of scope
- Arc/Vulkan or any GPU OCR path — the GPU here is the LLM's (out of scope for OCR).
- Cloud OCR / vision APIs.
- Model changes (training, distilling, surya, OmniParser, tesseract) — destination: run **today's** RapidOCR ONNX models on the NPU, accuracy is not in play.
- heimdall main-branch integration work — the map ends at the decision; landing is a follow-up effort once it's made.
## Open children
- [x] [Research: NPU path for bundled RapidOCR ONNX models (OpenVINO on Lunar Lake)](https://github.com/adityanandanx/heimdall/issues/66) — closed
- [ ] [Prototype: standalone NPU-vs-CPU OCR bench in the proto worktree](https://github.com/adityanandanx/heimdall/issues/67)
- [ ] [Grilling: NPU as the default OCR engine?](https://github.com/adityanandanx/heimdall/issues/68)
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.