Skip to content

feat(core): runtime-selectable vector engine (usearch + vecq in one build) - #1169

Merged
ajianaz merged 2 commits into
developfrom
feat/dual-vector-engine
Aug 31, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/dual-vector-engine

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

What

  • Unify the two compile-time vector engines into one runtime enum behind the unchanged VectorIndex API. The mutual-exclusion compile_error! is gone; features are now additive — a desktop build can ship both engines, slim mobile builds keep exactly one (unused variants are link-time eliminated).
  • Selection precedence: UTEKE_VECTOR_BACKEND env → [vector] backend in uteke.toml → compiled-in default (usearch when present). Bad/unknown/not-compiled-in values fall back to the default with a warning — open() never fails on a bad preference.
  • Per-engine index files preserved (uteke_index.usearch / uteke_index.vecq). Switching engines on an existing store leaves the old file intact; the new engine starts empty and the existing auto-rebuild-from-SQLite path repopulates it. Switching back picks the old file up with no rebuild. SQLite stays the single source of truth.
  • vecq profile unchanged: 4-bit + residual (with_residual, build(core): bump vecq-core to 0.3.0 — adopt 4-bit + residual profile #1164) on every path.
  • New API: VectorBackend (parse/resolve/default_backend), VectorIndex::with_backend / load_or_create_for / load_from_file_for, VectorIndex::backend().
  • CLI wiring: [vector] backend config key + UTEKE_VECTOR_BACKEND env override; docs table entry in configuration.md.

Why

  • Closes feat(core): runtime-selectable vector engine — build usearch+vecq together, select via ENV/config #1168. Makes the upcoming 0.17.0 a real feature release: runtime-switchable vector engine is unique in the local-memory space (competitor research, Aug 31), and lets a single Docker image serve both engines via one ENV var — ops can benchmark usearch vs vecq on real workloads by flipping UTEKE_VECTOR_BACKEND and restarting.
  • Keeps mobile freedom intact: --no-default-features --features onnx,vecq still builds vecq-only with no C++ toolchain.

Testing

  • Dual-engine build (cargo test -p uteke-core --features usearch,vecq --lib): 537 passed, 0 failed — includes new dual-engine per-extension roundtrip test
  • vecq-only slim build (--no-default-features --features onnx,vecq): 535 passed, 0 failed
  • Default build (onnx+usearch): 534 passed, 0 failed — no regression
  • CLI config tests: 45 passed (incl. new [vector] backend parsing)
  • e2e engine-switch test: one store, usearch → vecq → usearch via UTEKE_VECTOR_BACKEND — per-engine files written/coexist, auto-rebuild from SQLite finds the probe, switch-back reuses the old file
  • Invalid env fallback test: UTEKE_VECTOR_BACKEND=bogus-engine → open succeeds on default engine
  • clippy: 0 warnings on all three feature sets; fmt clean

Note per maintainer instruction: PR left open for preview — do not merge until reviewed. Release 0.17.0 stays on hold pending the usearch-vs-vecq default decision (#1165).

…ether, select via ENV/config (#1168)

Replace the compile-time mutual exclusion of vector engines with
runtime selection while keeping slim single-engine builds working.

- vector.rs: unified runtime enum Engine { Usearch(Box<Index>),
  Vecq(VecqIndex) } behind the unchanged VectorIndex API; all cfg-
  branched sites became match arms on the enum. The vecq profile
  stays 4-bit + residual (with_residual, #1164) on every path.
- compile_error guard: 'both engines' no longer errors — only
  'no engine at all' does. Features are additive: desktop builds can
  compile both engines; mobile keeps single-engine builds (unused
  variants are eliminated at link time).
- Selection precedence: UTEKE_VECTOR_BACKEND env > [vector] backend
  in uteke.toml > compiled-in default (usearch when present).
  Unknown values / engines not compiled in fall back to the default
  with a warning — open() never fails on a bad preference.
- Per-engine index files kept (uteke_index.usearch / .vecq).
  Switching engines leaves the old file intact; the new engine
  starts empty and finish_open_full auto-rebuilds it from SQLite
  (source of truth). Both files coexist; switching back picks the
  old file up without a rebuild.
- New API surface: VectorBackend (parse/resolve/default_backend),
  VectorIndex::with_backend / load_or_create_for /
  load_from_file_for, VectorIndex::backend().
- CLI: [vector] backend config + UTEKE_VECTOR_BACKEND env override.
- Docs: configuration.md env table entry.

Verified (all green; clippy 0 warnings and fmt clean on all three
feature sets):
- dual-engine (onnx+usearch+vecq): 537 passed
- vecq-only slim (onnx+vecq): 535 passed
- default (onnx+usearch): 534 passed; cli config tests: 45 passed
- e2e: engine switch usearch->vecq->usearch on one store —
  auto-rebuild from SQLite, per-engine files coexist, switch back
  reuses the old file; invalid env falls back to default
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

Guard the runtime-selection feature: dual-engine build must compile
and pass the engine-switch + vector module tests on every PR.
@ajianaz
ajianaz merged commit 75b72ff into develop Aug 31, 2026
15 checks passed
ajianaz added a commit that referenced this pull request Aug 31, 2026
…ecq (#1171)

* feat(build): dual-engine default — official binaries ship usearch + vecq (#1168)

Flip the default feature set of uteke-core and all forwarding crates
(cli/server/mcp) to compile BOTH vector engines, making runtime
selection (UTEKE_VECTOR_BACKEND / [vector] backend, #1169) available
out of the box in official binaries and the Docker image.

- default = [onnx, usearch, vecq] across the workspace.
- Slim builds unchanged: --no-default-features --features vecq
  (mobile, pure Rust) or --features usearch (classic single-engine).
- docker-compose: expose UTEKE_VECTOR_BACKEND (default usearch).
- docs/docker.md: engine-choice section + volume layout (.usearch +
  .vecq coexist; switching rebuilds from SQLite, data untouched).

Release binary size: 11.86 MB (was ~10.9 MB usearch-only; +~1 MB for
the vecq engine).

Verified:
- cargo test -p uteke-core --lib (dual-engine default): 537 passed
- cli config tests: 45 passed
- Release-binary smoke test: default writes .usearch; switch to vecq
  rebuilds (hybrid recall finds the probe, score 1.13); switch back
  reuses the old .usearch; invalid env falls back cleanly (exit 0)

* fix(core): drop unused VectorBackend import in engine-switch test

CI clippy (-D warnings, workspace all-targets) flagged the import as
unused — the test never names the type directly.

---------

Co-authored-by: ajianaz <[email protected]>
@ajianaz
ajianaz deleted the feat/dual-vector-engine branch October 13, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(core): runtime-selectable vector engine — build usearch+vecq together, select via ENV/config

1 participant