Commit Graph
93 Commits
Author SHA1 Message Date
ARYAN SINGH 631d9a2045 align scalar f16 metrics precision with SIMD thresholds (#9788) (#9811)
* - [AI] fix: align scalar f16 metrics precision with SIMD thresholds (#9788)

* remove generated tests
2026-07-14 16:23:39 +02:00
Jojii 0fa7be669c Revert "[TQDT] Asymmetric query support in scorer (#9177)" (#9293)
This reverts commit 98270150c8.
2026-06-03 16:39:25 +02:00
Ivan Pleshkov 98270150c8 [TQDT] Asymmetric query support in scorer (#9177)
* define query type

* asymmetric query scoring

* are you happy fmt
2026-05-28 00:32:25 +02:00
Dimas Prabowo 8226264779 perf(aarch64): optimize cosine_preprocess_neon with NEON SIMD (#8640)
* perf(aarch64): optimize cosine_preprocess_neon with NEON SIMD

* test: use dynamic relative tolerance for NEON stability
2026-04-10 18:12:05 +02:00
dependabot[bot]andtimvisee 18a7587d4b build(deps): bump rand_distr from 0.5.1 to 0.6.0 (#8148)
* build(deps): bump rand_distr from 0.5.1 to 0.6.0

Bumps [rand_distr](https://github.com/rust-random/rand_distr) from 0.5.1 to 0.6.0.
- [Release notes](https://github.com/rust-random/rand_distr/releases)
- [Changelog](https://github.com/rust-random/rand_distr/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand_distr/compare/0.5.1...0.6.0)

---
updated-dependencies:
- dependency-name: rand_distr
  dependency-version: 0.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Migrate main code base to rand 0.10

* Migrate tests

* Migrate benches

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: timvisee <tim@visee.me>
2026-02-25 14:15:04 +01:00
Arnaud Gourlay 104f6ab4eb Fix Clippy v1.92 (#7748) 2025-12-11 17:05:24 +01:00
Tim ViséeandIvan Pleshkov 64690cda53 Hotfix for Windows ARM64 builds, disable some Neon features (#7690)
* On Windows ARM64 builds, disable usage of neon

* Also disable optimized popcount on Windows ARM64

* fix quantization build

* revert changes in BQ

---------

Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>
2025-12-05 10:56:48 +01:00
Jojii 152bc5ef10 Improve h-sum in dot_avx calculation (#7002)
* Reduce amount of h-sum calculations in dot_avx

* Improve HSUM calculation and apply 4way-hsum to other places
2025-08-13 12:21:27 +02:00
Tim Visée da81a35329 Bump MSRV to 1.87 (#6558)
* Bump MSRV to 1.87

* Resolve TODOs
2025-05-20 12:58:01 +02:00
Arnaud Gourlay 5ae56b3777 Fix unecessary unsafe in Clippy 1.87 (#6540)
* Fix unecessary unsafe in Clippy 1.87

* bump Rust version for intrinsics safe API

* ignore until we can bump the MSRV with cargo-chef

* remove unecessary change

* mark clearly as TODO
2025-05-15 21:41:30 +02:00
Tim Visée 3e536347e1 Bump Rust edition to 2024 (#6042)
* Bump Rust edition to 2024

* gen is a reserved keyword now

* Remove ref mut on references

* Mark extern C as unsafe

* Wrap unsafe function bodies in unsafe block

* Geo hash implements Copy, don't reference but pass by value instead

* Replace secluded self import with parent

* Update execute_cluster_read_operation with new match semantics

* Fix lifetime issue

* Replace map_or with is_none_or

* set_var is unsafe now

* Reformat
2025-02-25 11:21:25 +01:00
af74d1b96a bump and migrate to rand 0.9.0 (#5892)
* bump and migrate to rand 0.9.0

also bump rand_distr to 0.5.0 to match it

* Migrate AVX2 and SSE implementations

* Remove unused thread_rng placeholders

* More random migrations

* Migrate GPU tests

* bump seed

---------

Co-authored-by: timvisee <tim@visee.me>
Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2025-01-28 16:19:11 +01:00
xzfc e28e20339c FixedLengthPriorityQueue: explicit sorted/unsorted methods (#5837) 2025-01-22 14:21:11 +00:00
Luis Cossío f20d0dc4e2 fix new pedantic lints on mac target_os (#4732) 2024-07-22 16:22:53 -04:00
xzfc a0ea3caccf Enable some of the pedantic clippy lints (#4715)
* Use workspace lints

* Enable lint: manual_let_else

* Enable lint: enum_glob_use

* Enable lint: filter_map_next

* Enable lint: ref_as_ptr

* Enable lint: ref_option_ref

* Enable lint: manual_is_variant_and

* Enable lint: flat_map_option

* Enable lint: inefficient_to_string

* Enable lint: implicit_clone

* Enable lint: inconsistent_struct_constructor

* Enable lint: unnecessary_wraps

* Enable lint: needless_continue

* Enable lint: unused_self

* Enable lint: from_iter_instead_of_collect

* Enable lint: uninlined_format_args

* Enable lint: doc_link_with_quotes

* Enable lint: needless_raw_string_hashes

* Enable lint: used_underscore_binding

* Enable lint: ptr_as_ptr

* Enable lint: explicit_into_iter_loop

* Enable lint: cast_lossless
2024-07-22 08:19:19 +00:00
Tim Visée 988e3129a7 Fix NaN score for zeroed uint8 vectors (#4661)
* Fix division by zero in SSE2, AVX and NEON implementations of u8 cosine

* Add zero division tests

* Fix incorrect test name

* Also test inverse, and add naive implementation test

* Use correct function in NEON test

* Fix NEON feature check

* Store denominator
2024-07-12 12:28:45 +02:00
Luis Cossío 26f857a323 allow missing_safety_doc and dead_code (#4468) 2024-06-13 20:45:07 +02:00
Ivan Pleshkov d241374a9c check f16 neon in runtime (#4464) 2024-06-13 14:53:33 +02:00
xhjkl f8c586e962 Huge limit now does not crash (#4328)
* commentary

* FixedLengthPriorityQueue: clamp preallocated capacity
2024-05-27 09:34:48 +02:00
Luis Cossío b92c44c548 allow missing safety doc on half float similarities (#4259) 2024-05-17 19:59:13 +02:00
Ivan Pleshkov e80844969f Float16 integration and API (#4234)
* f16 integration

tests

api

fix test

are you happy clippy

* fix build
2024-05-15 10:36:55 +02:00
Kamyar Salahiandgenerall c230a48c50 Half-precision float vector metrics (#4122)
* Adding half-precision floating point SIMD-optimized implementation for vector distance metrics.

* Primitives adjustment

* Remove ds store

* Load assembly only for neon

* Fixing linter errors

* Adding float16 type

* Addressing f16 comments

* Refactoring and adding benchmarks

* Renaming simd functions

* Cleaning openapi

* Merging in changes to dev

* Fixing linter error

* fix clippy

* disable float16 feature in API

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-05-13 23:19:21 +02:00
Ivan Pleshkov 528d759429 byte storage quantization fix and test (#4063)
* byte storage quantization fix and test

* apply quantization_preprocess in quantization scorers

* exact true

* exact true

* calculate sames count

* wrong distance getter

* fix Manhattan distance getter

* less acc check

* fix build

* update acc
2024-04-19 11:04:09 +02:00
Ivan Pleshkovandgenerall 224e4f600a Byte storage integration into segment (#4049)
* byte storage with quantization

raw scorer integration

config and test

are you happy fmt

fn renamings

cow refactor

use quantization branch

quantization update

* are you happy clippy

* don't use distance in quantized scorers

* fix build

* add fn quantization_preprocess

* apply preprocessing for only cosine float metric

* fix sparse vectors tests

* update openapi

* more complicated integration test

* update openapi comment

* mmap byte storages support

* fix async test

* move .unwrap closer to the actual check of the vector presence

* fmt

* remove distance similarity function

* avoid copying data while working with cow

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-04-18 00:42:17 +02:00
Ivan Pleshkov 025ae07948 byte metrics simd acceleration (#3976)
* byte metrics simd acceleration

* manhattan and benches

* simd as separate crate

* are you happy fmt

* add compiler flags to cargo

* speedup simd

* neon simd

* use avx2 feature

* refactor

* are you happy fmt

* fix aarch64

* apply simd

* fix x64 build

* apply simf to metrics

* fix arm

* fix cpu features

* refactor

* add basic omments

* are you happy codespell

* review remark

* review remarks
2024-04-17 20:15:50 +02:00
Tim Visée 6cfc97c607 Stabilize vector renormalisation (#3928)
* Add normalization stability test

* Move stable preprocess test closer to implementation

* Make renormalizing stable, keep old values if within certain threshold

* Test with 1500 dimensions
2024-03-27 17:08:58 +01:00
Andrey Vasnetsov e090dc0fec Refactor vector storage infra to be generic over vector element type (#3900)
* make SimpleDenseVectorStorage generic against VectorElementType

* make generic loading of the simple dense storage

* move memmap_dense_vector_storage

* move mmap_dense_vectors

* move appendable_mmap_dense_vector_storage

* fmt

* move dynamic_mmap_flags

* move simple_dense_vector_storage

* move PrimitiveVectorElement

* fmt

* make MmapDenseVectors generic

* make MemmapDenseVectorStorage generic to data type

* fix UringReader on non-linux platform

* make ChunkedMmapVectors generic of the vector element type

* make AppendableMmapDenseVectorStorage generic of the vector element type

* make PrimitiveVectorElement trait even more global

* make Metric generic over vector element type and refactor it into GenericMetric

* make DenseVectorStorage generic over vector element

* remove temorary trait for migrating Metric

* make CustomQueryScorer generic against vector element type

* refactor PrimitiveVectorElement to use Cow and allow owned conversions

* Move score post-processing out of metric object

* naive implementation of metrics for byte vectors
2024-03-25 13:21:21 +01:00
Arnaud Gourlay ee20b1a331 Remove duplication in cosine similarity (#3843) 2024-03-18 13:44:36 +01:00
Ivan Pleshkov da587f98a5 Rename VectorType to DenseVector (#3192)
* rename vectortype to densevector

* rename enums

* are you happy fmt

* openapi

* revert type renamings
2023-12-13 16:20:23 +00:00
Kaan C. Fidanandtimvisee c7402a45d7 Manhattan distance (#3079)
* implemented Manhattan distance

* updated quantization dependency

* fixed negative distances and doc consistency

* fixed neon implementation

* updated quantization dependency

* updated quantization dependency

* removed redundant copy operation

* updated quantization dependency

* Change back to upstream quantization dependency

---------

Co-authored-by: timvisee <tim@visee.me>
2023-12-02 21:28:38 +01:00
Tim Visée 970fcc3836 Remove redundant copy from sum iterator (#3085)
* Remove redundant copy from sum iterator

* Remove another redundant copied call
2023-11-24 13:02:42 +01:00
Luis Cossíoandtimvisee 904a7ab306 Discovery API (#2861)
* create and connect discovery http and grpc interfaces

* add openapi tests

* fix bad rebase

* Add better descriptions

* remove numpy from openapi tests

* fix rebase artifact

* remove already addressed TODO

* add more tests

* 🤡🔫 (cfg batch handler)

* add timeout query param for discover requests

* More gRPC validation

* make fields pydantic_openapi_generator_v3 friendly

* `context_pairs` -> `context` with struct for pairs

* discovery api is only discovery or context,
move struct description to fields

---------

Co-authored-by: timvisee <tim@visee.me>
2023-11-08 14:22:31 +01:00
Roman Titov bad92e132d Fix ARM-specific import after moving ScoreType to common (#2735) 2023-09-28 14:11:59 +02:00
Arnaud Gourlay 5bb80fbc77 Move ScoredPointOffset into common (#2734) 2023-09-28 12:11:29 +02:00
Luis Cossíoandgenerall 117518b1b7 Recommendation scorer internals (#2538)
* use enum_dispatch on vector_index_base.rs

* add reco_query_scorer.rs

* smol refactor on reco_query_scorer

* add PositiveNegative variant

* recommend query scorer internals

- missing tests

* add test for RecoQuery

* Revert "use enum_dispatch on vector_index_base.rs"

This reverts commit 016e831d00d67ef01e64b4f7a76854e555cd9697.

* remove enum_dispatch usage

* disable score_internal implementation for QuantizedRecoQueryScorer

* refactor test

* refactor with latest preprocess changes

* add reco scorer for async scorer

* add iter_all() helper for RecoQuery

* rename PositiveNegative -> Recommend,
change variable names,
refactor quantized query scorer

* refactor new raw scorer

* add tests for comparison raw against async and u8 quant

* smol test improvements

* fix error after rebase

* fmt

* finish score equivalency test, remove dbgs

* make scorer builder for quantized storage

* move query preprocessing to `new()` of quantized query scorers

* self review

* review suggestions

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2023-09-14 12:37:14 -03:00
Luis Cossío 1f0fcfecb6 refactor: Make preprocess() own its vector argument (#2553)
* make preprocess own its vector argument

* update doc comment
2023-09-01 08:55:22 +02:00
Arnaud Gourlay 790103f888 Fix lints for Clippy 1.72 (#2476) 2023-08-24 16:43:34 +02:00
Arnaud Gourlay 71dd212abd move priority queue to new common crate (#2304) 2023-07-24 15:06:15 +02:00
Andrey Vasnetsov 7e4424ab57 Cosine dist zero vectors (#1198)
* skip pre-processing of zero-length vector for cosine distance

* fmt
2022-11-08 17:36:20 +01:00
Arnaud Gourlay 1ff09516a0 limit set to zero returns an empty result (#1083) 2022-10-24 12:32:46 +02:00
Andrey Vasnetsov ba26e2f85e Faster filtered scroll (#1003)
* faster filtered scroll for low cardinality filters

* add test

* scroll strategy heuristics
2022-09-12 17:55:56 +02:00
Ivan PleshkovandAndrey Vasnetsov f6b2186193 [WIP] Many named vectors per point (#958)
* many named vectors per point (segment-level)

* operation result for dim function

* beautifulized vector name

* fix naming bug

* segment version migration

* fmt

* add segment tests

* are you happy clippy

* fix build

* [WIP] many named vectors per point (collection-level) (#975)

* config and search

* fix placeholders for proxy segment move

* remove VectorType from collection

* are you happy fmt

* vectors in grps messages

* create collections with vectors

* segment holder fixes

* are you happy fmt

* remove default vector name placeholders

* are you happy fmt

* are you happy clippy

* fix build

* fix web api

* are you happy clippy

* are you happy fmt

* record vector&vectors

* openapi update

* fix openapi integration tests

* segment builder fix todo

* vector names for update from segment

* remove unwrap

* backward compatibility

* upd openapi

* backward compatible PointStruct

* upd openapi

* fix record back-comp

* fmt

* vector configuration backward compatibility

* fix vetor storage size estimation

* fmt

* multi-vec segment test + index test

* fmt

* api integration tests

* [WIP] Named vectors struct (#1002)

* move to separate file

* named vectors as struct

* use cow

* fix build

* keys iterator

* avoid copy in PointStruct -> get_vectors

* avoid another copy

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2022-09-11 20:59:23 +02:00
Egor Ivkov 026bd040b0 Add import formatting rules (#820)
* Add import formatting rules

* Review fix: update rusty hook
2022-07-15 15:42:25 +03:00
Ivan Pleshkov 2581a2e3f2 arm unused const warning (#633) 2022-05-27 16:34:00 +04:00
Andrey VasnetsovandArnaud Gourlay 5800319edb refactor distances + add score_threshold + fix negative euclid distance (#569)
* refactor distances + add score_threshold + fix negative euclid distance

* generate docs

* fix clippy

* Update lib/segment/src/spaces/tools.rs

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2022-05-09 17:32:48 +02:00
Ivan Pleshkov 94b874bea0 optimize push in fixed priority queue (#513) 2022-04-27 18:06:12 +04:00
Ivan Pleshkov 5a3408667b Disable simd on small dimensions (#508)
Disable simd on small dimensions
2022-04-25 20:38:59 +04:00
Ivan Pleshkov b479c8c29f revome unsafe functions from crate api 2022-03-16 12:58:20 +04:00
Ivan Pleshkov b6bf803c3a fix build 2022-03-16 12:26:32 +04:00
Ivan Pleshkov 3df7c36c88 remove avx512 2022-03-16 12:25:02 +04:00