Skip to content

Commit 59f7904

Browse files
authored
Revert "[DiskBBQ] Add bulk scoring for int7 centroid scoring (#138204)" (#138309)
This reverts commit 8a839dc.
1 parent f1c812c commit 59f7904

File tree

6 files changed

+5
-67
lines changed

6 files changed

+5
-67
lines changed

docs/changelog/138204.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

libs/native/libraries/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ configurations {
1919
}
2020

2121
var zstdVersion = "1.5.5"
22-
var vecVersion = "1.0.14"
22+
var vecVersion = "1.0.13"
2323

2424
repositories {
2525
exclusiveContent {

libs/native/src/main/java/org/elasticsearch/nativeaccess/VectorSimilarityFunctions.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ public interface VectorSimilarityFunctions {
3030
*/
3131
MethodHandle dotProductHandle7u();
3232

33-
MethodHandle dotProductHandle7uBulk();
34-
3533
/**
3634
* Produces a method handle returning the square distance of byte (unsigned int7) vectors.
3735
*

libs/native/src/main/java/org/elasticsearch/nativeaccess/jdk/JdkVectorLibrary.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public final class JdkVectorLibrary implements VectorLibrary {
3232
static final Logger logger = LogManager.getLogger(JdkVectorLibrary.class);
3333

3434
static final MethodHandle dot7u$mh;
35-
static final MethodHandle dot7uBulk$mh;
3635
static final MethodHandle sqr7u$mh;
3736
static final MethodHandle cosf32$mh;
3837
static final MethodHandle dotf32$mh;
@@ -54,11 +53,6 @@ public final class JdkVectorLibrary implements VectorLibrary {
5453
FunctionDescriptor.of(JAVA_INT, ADDRESS, ADDRESS, JAVA_INT),
5554
LinkerHelperUtil.critical()
5655
);
57-
dot7uBulk$mh = downcallHandle(
58-
"dot7u_bulk_2",
59-
FunctionDescriptor.ofVoid(ADDRESS, ADDRESS, JAVA_INT, JAVA_INT, ADDRESS),
60-
LinkerHelperUtil.critical()
61-
);
6256
sqr7u$mh = downcallHandle(
6357
"sqr7u_2",
6458
FunctionDescriptor.of(JAVA_INT, ADDRESS, ADDRESS, JAVA_INT),
@@ -85,11 +79,6 @@ public final class JdkVectorLibrary implements VectorLibrary {
8579
FunctionDescriptor.of(JAVA_INT, ADDRESS, ADDRESS, JAVA_INT),
8680
LinkerHelperUtil.critical()
8781
);
88-
dot7uBulk$mh = downcallHandle(
89-
"dot7u_bulk",
90-
FunctionDescriptor.ofVoid(ADDRESS, ADDRESS, JAVA_INT, JAVA_INT, ADDRESS),
91-
LinkerHelperUtil.critical()
92-
);
9382
sqr7u$mh = downcallHandle(
9483
"sqr7u",
9584
FunctionDescriptor.of(JAVA_INT, ADDRESS, ADDRESS, JAVA_INT),
@@ -119,7 +108,6 @@ public final class JdkVectorLibrary implements VectorLibrary {
119108
enable them in your OS/Hypervisor/VM/container""");
120109
}
121110
dot7u$mh = null;
122-
dot7uBulk$mh = null;
123111
sqr7u$mh = null;
124112
cosf32$mh = null;
125113
dotf32$mh = null;
@@ -154,10 +142,6 @@ static int dotProduct7u(MemorySegment a, MemorySegment b, int length) {
154142
return dot7u(a, b, length);
155143
}
156144

157-
static void dotProduct7uBulk(MemorySegment a, MemorySegment b, int length, int count, MemorySegment result) {
158-
dot7uBulk(a, b, length, count, result);
159-
}
160-
161145
/**
162146
* Computes the square distance of given unsigned int7 byte vectors.
163147
*
@@ -226,14 +210,6 @@ private static int dot7u(MemorySegment a, MemorySegment b, int length) {
226210
}
227211
}
228212

229-
private static void dot7uBulk(MemorySegment a, MemorySegment b, int length, int count, MemorySegment result) {
230-
try {
231-
JdkVectorLibrary.dot7uBulk$mh.invokeExact(a, b, length, count, result);
232-
} catch (Throwable t) {
233-
throw new AssertionError(t);
234-
}
235-
}
236-
237213
private static int sqr7u(MemorySegment a, MemorySegment b, int length) {
238214
try {
239215
return (int) JdkVectorLibrary.sqr7u$mh.invokeExact(a, b, length);
@@ -267,7 +243,6 @@ private static float sqrf32(MemorySegment a, MemorySegment b, int length) {
267243
}
268244

269245
static final MethodHandle DOT_HANDLE_7U;
270-
static final MethodHandle DOT_HANDLE_7U_BULK;
271246
static final MethodHandle SQR_HANDLE_7U;
272247
static final MethodHandle COS_HANDLE_FLOAT32;
273248
static final MethodHandle DOT_HANDLE_FLOAT32;
@@ -278,11 +253,6 @@ private static float sqrf32(MemorySegment a, MemorySegment b, int length) {
278253
var lookup = MethodHandles.lookup();
279254
var mt = MethodType.methodType(int.class, MemorySegment.class, MemorySegment.class, int.class);
280255
DOT_HANDLE_7U = lookup.findStatic(JdkVectorSimilarityFunctions.class, "dotProduct7u", mt);
281-
DOT_HANDLE_7U_BULK = lookup.findStatic(
282-
JdkVectorSimilarityFunctions.class,
283-
"dotProduct7uBulk",
284-
MethodType.methodType(void.class, MemorySegment.class, MemorySegment.class, int.class, int.class, MemorySegment.class)
285-
);
286256
SQR_HANDLE_7U = lookup.findStatic(JdkVectorSimilarityFunctions.class, "squareDistance7u", mt);
287257

288258
mt = MethodType.methodType(float.class, MemorySegment.class, MemorySegment.class, int.class);
@@ -299,11 +269,6 @@ public MethodHandle dotProductHandle7u() {
299269
return DOT_HANDLE_7U;
300270
}
301271

302-
@Override
303-
public MethodHandle dotProductHandle7uBulk() {
304-
return DOT_HANDLE_7U_BULK;
305-
}
306-
307272
@Override
308273
public MethodHandle squareDistanceHandle7u() {
309274
return SQR_HANDLE_7U;

libs/simdvec/src/main21/java/org/elasticsearch/simdvec/internal/Similarities.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,8 @@ public class Similarities {
2222
.orElseThrow(AssertionError::new);
2323

2424
static final MethodHandle DOT_PRODUCT_7U = DISTANCE_FUNCS.dotProductHandle7u();
25-
static final MethodHandle DOT_PRODUCT_7U_BULK = DISTANCE_FUNCS.dotProductHandle7uBulk();
2625
static final MethodHandle SQUARE_DISTANCE_7U = DISTANCE_FUNCS.squareDistanceHandle7u();
2726

28-
static void dotProduct7uBulk(MemorySegment a, MemorySegment b, int length, int count, MemorySegment scores) {
29-
try {
30-
DOT_PRODUCT_7U_BULK.invokeExact(a, b, length, count, scores);
31-
} catch (Throwable e) {
32-
if (e instanceof Error err) {
33-
throw err;
34-
} else if (e instanceof RuntimeException re) {
35-
throw re;
36-
} else {
37-
throw new RuntimeException(e);
38-
}
39-
}
40-
}
41-
4227
static int dotProduct7u(MemorySegment a, MemorySegment b, int length) {
4328
try {
4429
return (int) DOT_PRODUCT_7U.invokeExact(a, b, length);

libs/simdvec/src/main22/java/org/elasticsearch/simdvec/internal/MemorySegmentES92Int7VectorsScorer.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,14 @@ private long nativeInt7DotProduct(byte[] q) throws IOException {
4848
return res;
4949
}
5050

51-
private void nativeInt7DotProductBulk(byte[] q, int count, float[] scores) throws IOException {
52-
final MemorySegment scoresSegment = MemorySegment.ofArray(scores);
53-
final MemorySegment segment = memorySegment.asSlice(in.getFilePointer(), dimensions * count);
54-
final MemorySegment querySegment = MemorySegment.ofArray(q);
55-
Similarities.dotProduct7uBulk(segment, querySegment, dimensions, count, scoresSegment);
56-
in.skipBytes(dimensions * count);
57-
}
58-
5951
@Override
6052
public void int7DotProductBulk(byte[] q, int count, float[] scores) throws IOException {
6153
assert q.length == dimensions;
6254
if (NATIVE_SUPPORTED) {
63-
nativeInt7DotProductBulk(q, count, scores);
55+
// TODO: can we speed up bulks in native code?
56+
for (int i = 0; i < count; i++) {
57+
scores[i] = nativeInt7DotProduct(q);
58+
}
6459
} else {
6560
panamaInt7DotProductBulk(q, count, scores);
6661
}

0 commit comments

Comments
 (0)