fix(local_ai): Windows Ollama discovery + DirectML GPU for GLiNER RelEx#416
Conversation
…or GLiNER RelEx Ollama was not found on Windows because find_system_ollama_binary lacked common Windows install paths (%LOCALAPPDATA%\Programs\Ollama). The server spawn also silently swallowed errors, and the NSIS installer fallback didn't check system paths after install. GLiNER RelEx ONNX sessions were CPU-only — no execution providers were configured. Now offers DirectML (Windows), CoreML (macOS), and CUDA as GPU backends with automatic fallback. Updated the release to v0.5-onnx.2 with a DirectML-enabled onnxruntime.dll. Bundle completeness now requires the platform DLL and verifies checksums to trigger re-download on update. Changes: - Add Windows common paths to find_system_ollama_binary (install.rs) - Log and return spawn errors in start_and_wait_for_server (ollama_admin.rs) - Fall back to find_system_ollama_binary after Windows installer (ollama_admin.rs) - Add platform_execution_providers() with DirectML/CoreML/CUDA (relex.rs) - Require ORT DLL in bundle_complete check (relex.rs) - Verify platform DLL checksums in managed_bundle_complete (relex.rs) - Update release URL and SHA256 hashes for v0.5-onnx.2 (relex.rs) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe PR enhances system binary discovery for Ollama on Windows by checking additional installation paths, improves Ollama server spawn error handling with better logging, and updates ONNX runtime configuration with platform-specific GPU providers and stricter bundle validation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/openhuman/memory/relex.rs (1)
575-584: Consider usingspawn_blockingor streaming SHA256 for large files.The
managed_bundle_completefunction is called from async contexts (resolve_bundle_dir,ensure_managed_bundle) but performs synchronous file reads viafile_matches_sha256_sync. ORT DLLs can be 100+ MB, which could block the async runtime.Since this is an initialization path that runs infrequently and files are local, the impact is limited. However, for robustness:
- Wrap the call in
tokio::task::spawn_blocking, or- Use a streaming hash approach to avoid loading the entire file into memory.
♻️ Option 1: Use spawn_blocking in resolve_bundle_dir
// 3. Check managed bundle in user home directory. let managed_dir = default_managed_bundle_dir(); -if managed_bundle_complete(&managed_dir) { +let managed_dir_clone = managed_dir.clone(); +let is_complete = tokio::task::spawn_blocking(move || managed_bundle_complete(&managed_dir_clone)) + .await + .unwrap_or(false); +if is_complete { return Some(managed_dir); }♻️ Option 2: Streaming SHA256 to reduce memory footprint
fn file_matches_sha256_sync(path: &Path, expected: &str) -> bool { if expected.is_empty() { return path.exists(); } let Ok(file) = std::fs::File::open(path) else { return false; }; let mut reader = std::io::BufReader::new(file); let mut hasher = Sha256::new(); let mut buffer = [0u8; 8192]; loop { let Ok(n) = std::io::Read::read(&mut reader, &mut buffer) else { return false; }; if n == 0 { break; } hasher.update(&buffer[..n]); } let actual = hex::encode(hasher.finalize()); actual.eq_ignore_ascii_case(expected) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openhuman/memory/relex.rs` around lines 575 - 584, managed_bundle_complete is sync but called from async paths and uses file_matches_sha256_sync which can block on large files; update the call path so hashing runs off the async runtime: either make managed_bundle_complete async and wrap the checksum checks in tokio::task::spawn_blocking (invoking file_matches_sha256_sync inside spawn_blocking) from resolve_bundle_dir/ensure_managed_bundle, or replace file_matches_sha256_sync with a non-blocking streaming implementation (reading via a BufReader and incremental Sha256) and call that from managed_bundle_complete; reference the functions managed_bundle_complete, file_matches_sha256_sync, resolve_bundle_dir, and ensure_managed_bundle when applying the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openhuman/memory/relex.rs`:
- Around line 441-464: Update the ort dependency in Cargo.toml to enable the
execution-provider features required by platform_execution_providers: add the
"cuda", "directml", and "coreml" features so that ep::CUDA, ep::DirectML and
ep::CoreML can register (keep existing version, default-features=false and other
features like "std","ndarray","load-dynamic"), then run cargo check and cargo
fmt to ensure the build and formatting pass.
---
Nitpick comments:
In `@src/openhuman/memory/relex.rs`:
- Around line 575-584: managed_bundle_complete is sync but called from async
paths and uses file_matches_sha256_sync which can block on large files; update
the call path so hashing runs off the async runtime: either make
managed_bundle_complete async and wrap the checksum checks in
tokio::task::spawn_blocking (invoking file_matches_sha256_sync inside
spawn_blocking) from resolve_bundle_dir/ensure_managed_bundle, or replace
file_matches_sha256_sync with a non-blocking streaming implementation (reading
via a BufReader and incremental Sha256) and call that from
managed_bundle_complete; reference the functions managed_bundle_complete,
file_matches_sha256_sync, resolve_bundle_dir, and ensure_managed_bundle when
applying the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 71b63262-19ce-41cb-af04-c4a2bd456d4b
📒 Files selected for processing (3)
src/openhuman/local_ai/install.rssrc/openhuman/local_ai/service/ollama_admin.rssrc/openhuman/memory/relex.rs
…or GLiNER RelEx (tinyhumansai#416) Ollama was not found on Windows because find_system_ollama_binary lacked common Windows install paths (%LOCALAPPDATA%\Programs\Ollama). The server spawn also silently swallowed errors, and the NSIS installer fallback didn't check system paths after install. GLiNER RelEx ONNX sessions were CPU-only — no execution providers were configured. Now offers DirectML (Windows), CoreML (macOS), and CUDA as GPU backends with automatic fallback. Updated the release to v0.5-onnx.2 with a DirectML-enabled onnxruntime.dll. Bundle completeness now requires the platform DLL and verifies checksums to trigger re-download on update. Changes: - Add Windows common paths to find_system_ollama_binary (install.rs) - Log and return spawn errors in start_and_wait_for_server (ollama_admin.rs) - Fall back to find_system_ollama_binary after Windows installer (ollama_admin.rs) - Add platform_execution_providers() with DirectML/CoreML/CUDA (relex.rs) - Require ORT DLL in bundle_complete check (relex.rs) - Verify platform DLL checksums in managed_bundle_complete (relex.rs) - Update release URL and SHA256 hashes for v0.5-onnx.2 (relex.rs) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
find_system_ollama_binarynow checks%LOCALAPPDATA%\Programs\Ollamaand%PROGRAMFILES%\Ollama— matching macOS/Linux which already had common-path fallbacks. Also logs spawn errors instead of silently swallowing them, and falls back to system paths after the NSIS installer.v0.5-onnx.2with a DirectML-enabledonnxruntime.dll.bundle_completenow requires the platform ORT DLL to exist.managed_bundle_completeverifies SHA256 checksums so stale CPU-only DLLs trigger re-download.Files changed
src/openhuman/local_ai/install.rssrc/openhuman/local_ai/service/ollama_admin.rssrc/openhuman/memory/relex.rsTest plan
cargo checkpasses (17 pre-existing warnings, 0 new)local_ai_statusreturns"state": "ready"on Windowslocal_ai_chatreturns valid response via Ollamaonnxruntime.dllconfirmed:DmlExecutionProviderpresent in binary🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes