-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Add bfloat16 to bbq_disk and bbq_hnsw #136179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d305146
to
88b682c
Compare
88b682c
to
c72eda6
Compare
double expected = Double.parseDouble(m.group(1)); | ||
double actual = Double.parseDouble(m.group(2)); | ||
double allowedError = expected * 0.01; // within 1% | ||
assertThat(error.getMessage(), actual, closeTo(expected, allowedError)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loss of precision causes several base vector tests in Lucene to hit assertions. This is one way to solve it - there are several others. This approach does mean that tests exit early and don't run to completion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loss of precision is OK, but yeah, its tricky to handle all the tests
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
.../src/main/java/org/elasticsearch/index/codec/vectors/es818/ES818BinaryFlatVectorsScorer.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/codec/vectors/BFloat16.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/elasticsearch/script/field/vectors/BFloat16RankVectorsDocValuesField.java
Outdated
Show resolved
Hide resolved
qa/vector/src/main/java/org/elasticsearch/test/knn/CmdLineArgs.java
Outdated
Show resolved
Hide resolved
...r/src/main/java/org/elasticsearch/index/codec/vectors/diskbbq/ES920DiskBBQVectorsFormat.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/elasticsearch/index/codec/vectors/es818/ES818BinaryFlatVectorsScorer.java
Show resolved
Hide resolved
static final int DIRECT_MONOTONIC_BLOCK_SHIFT = 16; | ||
private final FlatVectorsScorer vectorsScorer; | ||
|
||
public ES93BFloat16FlatVectorsFormat(FlatVectorsScorer vectorsScorer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should allow injectable scorers here.
We cannot use the getLucene99FlatVectorsScorer
as it will assume vectors are float32, and attempt to score them off-heap if possible, which will completely break with bfloat16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the default vector scorers at the moment, as they work on FloatVectorValues
, which has a bfloat16 implementation here. The panama scorer implementation is also ok, as that only works if HasIndexSlice
is implemented, which it is not (now)
...in/java/org/elasticsearch/index/codec/vectors/es93/ES93HnswBinaryQuantizedVectorsFormat.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/elasticsearch/index/codec/vectors/es93/OffHeapBFloat16VectorValues.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/elasticsearch/index/codec/vectors/es93/OffHeapBFloat16VectorValues.java
Outdated
Show resolved
Hide resolved
double expected = Double.parseDouble(m.group(1)); | ||
double actual = Double.parseDouble(m.group(2)); | ||
double allowedError = expected * 0.01; // within 1% | ||
assertThat(error.getMessage(), actual, closeTo(expected, allowedError)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loss of precision is OK, but yeah, its tricky to handle all the tests
For my We just need to be sure not to forget about it. |
c2c52e7
to
4030f47
Compare
4030f47
to
5ef4cf1
Compare
I've turned the generic format into a proper format - it's a lot neater now |
server/src/main/java/org/elasticsearch/index/codec/vectors/es93/ES93HnswVectorsFormat.java
Outdated
Show resolved
Hide resolved
import java.util.Map; | ||
|
||
public abstract class ES93GenericFlatVectorsFormat extends AbstractFlatVectorsFormat { | ||
public class ES93GenericFlatVectorsFormat extends AbstractFlatVectorsFormat { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
604ed2f
to
e54d4c6
Compare
Add bfloat16 raw vector support to bbq_hnsw and bbq_disk vector types (but not enabled yet). Integration tests are part of #135940