fix(retrieval): resolve the reranker provider before acquiring its runtime - #90
fix(retrieval): resolve the reranker provider before acquiring its runtime#90citron07r wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe reranker resolves execution providers before ONNX Runtime setup in construction and probe paths. Session construction consumes the resolved provider. CoreML can reuse an initialized runtime, and tests cover provider resolution and runtime acquisition. ChangesReranker provider resolution
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to This localized change makes reranking acquire the runtime for its effective execution provider and reports successful verification; no actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…ntime `new_with_ep` acquired, initialized and dependency-checked the ONNX Runtime library for the requested provider, and only `build_session` resolved. Under CoreML those differ: `reranker_execution_provider` maps CoreMl to Cpu unconditionally, because no prebuilt reranker export runs on the CoreML GPU. Three consequences, in increasing order of seriousness: - every Apple Silicon run downloaded and validated `~/.vera/lib/coreml/libonnxruntime.dylib` for a session always built on CPU - `ensure_provider_dependencies` ran the CoreML shared-library check that production reranking never needs, since it early-returns for Cpu - `ensure_ort_runtime` is a process-wide OnceLock, so only the first path passed to it in a process is loaded. The embedding provider resolves first, so the reranker could validate the CoreML dylib and then build against whichever library the embedding path had already loaded. A green check was not evidence the session got that library. All three entry points now resolve first, matching the shape `LocalEmbeddingProvider::new_with_ep_and_mem_limit` already uses via `resolve_provider_and_config`. Measured effect under CoreML: the library acquired goes from `~/.vera/lib/coreml/libonnxruntime.dylib` to `~/.vera/lib/libonnxruntime.dylib`, which is the one it builds against. `build_session` no longer re-resolves, since all three callers now do. The new test is asset-free on purpose: it pins that resolution is idempotent, which is what makes dropping the second resolve safe, and that CoreML maps to CPU while other providers are untouched. The existing reranker test early-returns without ONNX Runtime and would assert nothing. Fixes VeraTools#89
The comment read as if it described the test it sits on. It is about test_local_reranker below, which early-returns without ONNX Runtime and is the reason this one is deliberately asset-free.
4359bcc to
96892b8
Compare
Problem
LocalReranker::new_with_epacquired, initialized and dependency-checked the ONNX Runtime library for the requested execution provider, and onlybuild_sessionresolved. Under CoreML those differ:reranker_execution_providermaps CoreMl to Cpu unconditionally, because no prebuilt reranker export runs on the CoreML GPU (the fix from #33/#41).Three consequences, in increasing order of seriousness:
~/.vera/lib/coreml/libonnxruntime.dylibfor a session that is always built on CPU.ensure_provider_dependenciesran the CoreML shared-library check that production reranking never needs, since it early-returns for Cpu.ensure_ort_runtimeis a process-wideOnceLock, so only the first path passed to it in a process is actually loaded. The embedding provider resolves its own library first, so the reranker could validate the CoreML dylib and then build against whichever library the embedding path had already loaded.Point 3 is why this is more than wasted bandwidth: the check and the load could disagree, so a green check was not evidence the session would get that library.
Change
All three entry points (
new_with_ep,probe_session,probe_inference) resolve first, which is the shapeLocalEmbeddingProvider::new_with_ep_and_mem_limitalready uses viaresolve_provider_and_config.build_sessionno longer re-resolves, since all three of its callers now do. Keeping it would put the same contract in two places that could drift, which is the defect this PR is fixing one layer up.Verification
The behavioural change, measured by resolving each provider to its library path:
So under CoreML the reranker now acquires the library it actually builds against, rather than a second copy it never loads.
End to end on this Apple Silicon machine with the CoreML backend, reranking still works and nothing regressed:
vera searchreturns the expected match, which exercises the rerank path.Test
Asset-free on purpose. The existing
test_local_rerankerearly-returns when ONNX Runtime is not on the default lookup path and passes without asserting anything, so a test routed through session creation would prove nothing on a machine without ORT.The new test pins the two properties the change depends on: that resolution is idempotent, which is what makes dropping the second resolve in
build_sessionsafe, and that CoreML maps to CPU while CUDA and CPU are untouched.786
vera-coretests, 97vera-cli,cargo fmt --checkclean, clippy unchanged at the 5 pre-existing warnings.Note
Found while fixing the doctor-side half in #72, where
vera doctor --probepreflighted the requested provider but probed the effective one. That PR is scoped todoctor.rs; this is the vera-core half, kept separate because it changes what gets downloaded and which library is initialized at runtime.Fixes #89
Summary by cubic
Resolves the reranker’s execution provider before acquiring ONNX Runtime and reuses an already-initialized runtime under CoreML. This removes unnecessary downloads/checks and prevents library mismatches caused by the process-wide runtime lock.
Written for commit 96892b8. Summary will update on new commits.
Summary by CodeRabbit