vector search: add float16 support #1679
Merged
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.
Context
We are continue adding compression support and now
float16
is on the way!This PR implements float16 support as a vector column table and vector index compression parameters in the
LibSQL
.In current implementation we are basically implement conversion
f16 <-> f32
and this way supports all important operations (distance calculation + conversion). This is not that optimal from the performance perspective - but since the main purpose off16
- is the compression (without much sacrifice in the precision) - I think this is fine to start with.Reference of the
float16
format: https://en.wikipedia.org/wiki/Half-precision_floating-point_formatChanges
float16
functionsFLOAT16
/F16_BLOB
column namescompress_neighbors=float16
vector index parameterf16 <-> f32
works the same as reference implementation from python/numpy (seetest_libsql_f16.c
andtest_libsql_f16.py
; note thattest_libsql_f16.py
generatestest_libsql_f16_table.h
required for the test to work)