Skip to content

Commit f9349fb

Browse files
committed
Improve: Switch to bf16::dot over ::cos
1 parent 299c4d0 commit f9349fb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

scripts/search.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ fn create_distributed_embeddings(
6464
memory_scope_percent: usize,
6565
) -> Option<DistributedEmbeddings> {
6666
let colocations_count = fu::count_colocations();
67-
println!(
68-
"Initializing storage across {colocations_count} colocations"
69-
);
67+
println!("Initializing storage across {colocations_count} colocations");
7068

7169
// Calculate total capacity based on total system memory and scope percentage
7270
let total_memory = fu::volume_any_pages();
@@ -164,7 +162,7 @@ fn numa_aware_search(
164162
// Search vectors assigned to this thread
165163
for local_vector_idx in range {
166164
if let Some(vector) = node_vectors.get(local_vector_idx) {
167-
let similarity = bf16::cosine(query, vector).unwrap();
165+
let similarity = bf16::dot(query, vector).unwrap();
168166
// Convert local index to global round-robin index using the new method
169167
let global_index =
170168
storage.local_to_global_index(colocation_index, local_vector_idx);
@@ -228,7 +226,7 @@ fn worst_case_search(
228226
// Search vectors assigned to this thread, regardless of NUMA locality
229227
for local_vector_idx in range {
230228
if let Some(vector) = node_vectors.get(local_vector_idx) {
231-
let similarity = bf16::cosine(query, vector).unwrap();
229+
let similarity = bf16::dot(query, vector).unwrap();
232230
// Convert to global index for consistent comparison
233231
let global_index =
234232
storage.local_to_global_index(colocation_index, local_vector_idx);

0 commit comments

Comments
 (0)