YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
perf(redact): run PII models on ANE/NPU instead of CPU (~3.4x faster, low power)
Louis Beaumont3b9a1a105280
diff --git a/crates/screenpipe-redact/src/adapters/onnx.rs b/crates/screenpipe-redact/src/adapters/onnx.rsindex 0af514fb1..2a52bb8a4 100644--- a/crates/screenpipe-redact/src/adapters/onnx.rs+++ b/crates/screenpipe-redact/src/adapters/onnx.rs@@ -782,6 +782,11 @@ mod runtime {#[cfg(feature = "onnx-coreml")]let builder = builder.with_execution_providers([ort::execution_providers::CoreMLExecutionProvider::default()+ // MLProgram + ComputeUnits::All offloads to the Apple Neural+ // Engine; measured ~3.4x faster than the legacy NeuralNetwork+ // default (which is slower than CPU) and lower CPU/GPU power.+ .with_model_format(ort::execution_providers::coreml::CoreMLModelFormat::MLProgram)+ .with_compute_units(ort::execution_providers::coreml::CoreMLComputeUnits::All).with_subgraphs(true).build(),ort::execution_providers::CPUExecutionProvider::default().build(),diff --git a/crates/screenpipe-redact/src/adapters/rfdetr.rs b/crates/screenpipe-redact/src/adapters/rfdetr.rsindex 34af439bc..939645ebd 100644--- a/crates/screenpipe-redact/src/adapters/rfdetr.rs+++ b/crates/screenpipe-redact/src/adapters/rfdetr.rs@@ -241,12 +241,33 @@ mod imp {/// on initialization if the API fails (e.g. missing drivers, corrupted binary,/// ABI mismatch). This converts such panics into proper Err values.fn create_session_safe(model_path: &std::path::Path) -> Result<Session, RedactError> {- match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {- Session::builder()- .and_then(|b| b.with_optimization_level(GraphOptimizationLevel::Level3))- .and_then(|b| b.with_intra_threads(num_cpus_physical()))- .and_then(|b| b.commit_from_file(model_path))- })) {+ match std::panic::catch_unwind(std::panic::AssertUnwindSafe(+ || -> Result<Session, ort::Error> {+ let builder = Session::builder()?+ .with_optimization_level(GraphOptimizationLevel::Level3)?+ .with_intra_threads(num_cpus_physical())?;+ // Offload to the Apple Neural Engine (Mac) / NPU (Windows) instead of+ // running CPU-only. CoreML MLProgram + ComputeUnits::All measured ~3.4x+ // faster than the legacy default and keeps the work off the CPU/GPU.+ #[cfg(feature = "onnx-coreml")]+ let builder = builder.with_execution_providers([+ ort::execution_providers::CoreMLExecutionProvider::default()+ .with_model_format(ort::execution_providers::coreml::CoreMLModelFormat::MLProgram)+ .with_compute_units(ort::execution_providers::coreml::CoreMLComputeUnits::All)+ .with_subgraphs(true)+ .build(),+ ort::execution_providers::CPUExecutionProvider::default().build(),+ ])?;+ #[cfg(feature = "onnx-directml")]+ let builder = builder.with_execution_providers([+ ort::execution_providers::DirectMLExecutionProvider::default()+ .with_device_id(0)+ .build(),+ ort::execution_providers::CPUExecutionProvider::default().build(),+ ])?;+ builder.commit_from_file(model_path)+ },+ )) {Ok(Ok(session)) => Ok(session),Ok(Err(e)) => Err(RedactError::Runtime(format!("ort session creation: {e}"))),Err(payload) => {