Repository navigation
feat(store): multi-metric vector core (cosine/dot/L2) + norm cache; green CI under edition-2024 - #8
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…; pin toolchain & make fmt/clippy green
- Add DistanceMetric enum (cosine/dot/L2) selectable via DASH_VECTOR_METRIC
/ per-service DASH_{RETRIEVAL,INGEST}_VECTOR_METRIC; metric-aware ANN
traversal, graph construction, and brute-force scoring.
- Cache stored vectors' L2 norms (claim_vector_norms) to avoid recomputing
the stored norm on every cosine comparison; kept coherent on insert/remove.
- Default (cosine) behavior is unchanged; new metrics are opt-in.
- Pin rust-toolchain to 1.88 (edition 2024 dep floor) and fix CONTRIBUTING.
- Make the workspace fmt-clean and clippy-clean (-D warnings) under the
edition-2024 rustfmt: uninlined_format_args, single_element_loop, and a
stray unparseable inner doc-comment in gpu.rs.
- Fix inaccurate 'via usearch' claims in docs/Cargo comment (the CPU path is
a hand-rolled HNSW); document the new metric env vars.
Co-Authored-By: Bhawesh Bhaskar <bhaskarbhawesh09@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| let result = | ||
| verify_hs256_token_for_tenant(&token, "tenant-a", &sample_config(), 1_000_000_000); | ||
| assert!(result.is_ok(), "expected Ok on the good token, got {result:?}"); | ||
| assert!( |
| .unwrap(); | ||
| let result = verify_hs256_token_for_tenant(&token, "tenant-b", &sample_config(), 1_000); | ||
| assert!(result.is_ok(), "expected Ok via tenants array, got {result:?}"); | ||
| assert!( |
This was referenced Jun 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is Tier 1a of the competitive vector-engine work (gap analysis: DASH's ANN was cosine-only, hand-rolled scalar, recomputing norms every comparison). It adds a metric abstraction + a norm cache, and along the way makes the workspace actually pass CI under the edition-2024 toolchain.
Two concerns in one PR because the fmt drift touches the same files as the logic:
1. Vector-core capability (the substantive change)
DistanceMetricenum inpkg/store/src/ann.rs—Cosine(default),DotProduct,Euclidean— with alias-tolerant parsing (cos,ip/inner_product,l2). Added as a field onAnnTuningConfig.claim_vector_norms: HashMap<claim_id, f32>): the stored vector's norm is computed once on insert and reused on every cosine comparison instead of being recomputed each call. Kept coherent — set onapply_claim_vector, cleared inremove_claim_indexes.vector_similarity+ the cache: ANN entry/greedy-descent/heap expansion (approximate_vector_candidate_ids), graph construction (select_ann_neighbors,prune_ann_neighbors), and brute-force scoring (score_query_candidate_vectors). The GPU shader is cosine-only, so non-cosine metrics fall back to the CPU path.DASH_VECTOR_METRIC(shared) andDASH_RETRIEVAL_VECTOR_METRIC/DASH_INGEST_VECTOR_METRIC(per-service wins). Documented indash-startup-env-matrix.md. Ingestion builds the graph with its metric, so it must match retrieval's.Default (cosine) behavior is byte-for-byte unchanged —
vector_similarity(Cosine, …)equals the oldcosine_similarity, and the cache returns identical norms. The new metrics are strictly opt-in. The legacy freecosine_similarity/score_query_candidate_vectors_cpuare removed (fully subsumed).New unit tests: alias parsing, per-metric "higher = more similar" ordering, norm-cache coherence, and a dot-product end-to-end ranking (prefers larger-magnitude candidate).
2. Make CI green under Rust 1.88 / edition-2024 (mechanical)
maincurrently does not passcargo fmt --checkorclippy --all-targets -- -D warningsunder the edition-2024 rustfmt + current clippy (verified by stashing and checkingHEAD). The bulk of the file count in this diff is unavoidable, mechanical cleanup needed for green CI:rust-toolchain.tomlpins1.88(the dependency tree's real floor viatime/icu_*, not the 1.85 edition-2024 minimum) +CONTRIBUTING.mdcorrected.cargo fmt(import sorting,assert!wrapping) andcargo clippy --fix(53×uninlined_format_args,single_element_loop).pkg/store/src/gpu.rs: removed a stray, unparseable duplicated inner doc-comment block that brokerustfmt(cfg-gated, so the normal build never caught it).Docs honesty
usearch" — it isn't;usearchis a declared-but-unused dep staged for a future swap (per the modernization roadmap). Corrected to "custom Rust HNSW; cosine/dot/L2". Kept the dep (intentional, roadmapped).Benchmarks (perf_bench, release, 10k fixture)
Same-machine single runs; deltas are modest because the dominant semantic-retrieve cost is candidate scoring/sorting, not the stored-norm recompute (that's Tier 2 territory). No regressions; notably tighter ANN tail latency.
Not in this PR (next, per the tiered plan)
dense + lexical*0.1weight). Held out because it changes ranking semantics and needs its own tests — kept separate to keep this PR's logic focused/safe.Link to Devin session: https://app.devin.ai/sessions/1676c83410f3487281e58416c49492a1
Requested by: @BHAWESHBHASKAR