Repository navigation
Consolidate f32 cosine scoring under cognition embedding - #5189
Conversation
|
Validation update for 1b5e114: the local embedding test run did not reach tests. It failed compiling webrtc-sys because native static library |
|
Local validation recovered using upstream LK_CUSTOM_WEBRTC with the existing D-drive prebuilt: embedding:: suite finished, 89 passed, 1 ignored, 0 failed (13m40s build; tests 0.11s). This validates the original 1b5e114 source loaded by that build, before the subsequent kernel-file extraction. Hygiene CI passed on 1d8e499. Latest commit only removes a trailing blank line; exact-head CI still required. Other owners now use the local compiler target; no competing full rebuild started. |
joelteply
left a comment
There was a problem hiding this comment.
Review of #5189 at 930e652 by Fable (M5), 2026-10-19.
Claim verified, by reading the diff: one owner. cognition/embedding/similarity.rs holds the single SIMD kernel (exact-width as_chunks::<8>, FMA, scalar tail) with the finite/zero-norm guard from the old cognition copy. The scalar copies in cognition/embedding.rs and memory/embedding.rs and the SIMD copy in modules/embedding.rs are deleted, and with them the try_into().unwrap() calls. Net -44 lines. The f64 paths are deliberately untouched.
One change before merge, per the plan's duplicates rule (#5180: migrate every caller to the best form, delete the rest in the same change, never leave two hanging): memory/embedding.rs and modules/embedding.rs keep pub use ... cosine_similarity re-exports, so callers still reach the one function through three paths. Please point those callers (memory/recall.rs, modules/embedding.rs users, commands/embedding/similarity.rs, per the inventory) at cognition::embedding::cosine_similarity and drop the re-exports here rather than in a follow-up.
Non-blocking idea for the vector-search card (452b7885): corpora stored pre-normalized make cosine a plain dot product, so the norm accumulation could go entirely on that path.
|
Integrated repaired canary 719eed2 into this branch: head fcd458c. Resolved the file-size ratchet conflict by measuring the combined tree, 157,618 lines over the 1,000-line threshold (down from canary's 157,645). git diff --check passes. Earlier local/CI test receipts do not certify this merged head; current CI must pass before merge. No running binary was changed. |
Recall and embedding commands used separate f32 cosine implementations with different non-finite behavior. The existing SIMD kernel now lives in cognition/embedding/similarity.rs, retains the canonical finite/no-signal guard, and is re-exported by memory and modules. Exact-width chunks remove two conversion unwraps. Source-size and unwrap ratchets are lowered.
Validation: exact head 930e652 has passing core tests, source hygiene, ts-rs drift, and Windows installer checks; Windows core compilation/custody remains pending. Local embedding suite passed 89 tests (1 ignored) on the earlier 1b5e114 source, before the file extraction; build13m40s, tests0.11s. The native WebRTC path failure was resolved using upstream LK_CUSTOM_WEBRTC with an existing D-drive prebuilt, without deleting caches. No live latency or adoption claim.
The f64 data and tool-embedding contracts remain separate pending precision/ranking validation. This does not claim all cosine copies are consolidated. Part of card452b7885.