Commit a9777af
authored
Fix VectorScorerOSQBenchmarkTests (elastic#142742)
This PR fixes several VectorScorerOSQBenchmarkTests failures.
The native C code (score_common.h) is either compiled with -O3 (e.g. on aarch64), which enables FMA (fused multiply-add) instructions, or uses FMA SIMD instructions directly. Java's float arithmetic rounds at every operation per IEEE 754, but FMA computes a * b + c with a single rounding, preserving extra intermediate precision.
The score correction formula involves terms like ax * ay * dims + ay * lx * tcs + .... When correction values come from random bytes, they can represent extreme floats (e.g., ±1e+30). These large terms nearly cancel, and the FMA vs non-FMA rounding difference becomes catastrophic — the scalar gets score ≈ -1 (result 0.0) while the native gets score ≈ 5.5e+37 (result 2.7e+37).
This is NOT an issue in production — real quantized corrections from OptimizedScalarQuantizer produce small, well-behaved floats where FMA differences are negligible (the ESNextOSQVectorsScorerTests.testScoreBulk test validates this with real data).
The PR extracts the same input data generation used in ESNextOSQVectorsScorerTests.testScoreBulk, extracting it and exposing it via test fixture, so both tests share the same input data setup.
Fixes elastic#142289
Fixes elastic#142413
Fixes elastic#142490
Fixes elastic#142491
Fixes elastic#142492
Fixes elastic#142587
Fixes elastic#142588
Fixes elastic#1425891 parent 605c05b commit a9777af
File tree
10 files changed
+268
-226
lines changed- benchmarks
- src
- main/java/org/elasticsearch/benchmark/vector/scorer
- test/java/org/elasticsearch/benchmark/vector/scorer
- libs/simdvec
- src
- testFixtures/java/org/elasticsearch/simdvec/internal/vectorization
- test/java/org/elasticsearch/simdvec/internal/vectorization
- qa/vector/src/main/java/org/elasticsearch/test/knn
- server/src/main/java/org/elasticsearch/index/codec/vectors/diskbbq/next
10 files changed
+268
-226
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
Lines changed: 36 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
75 | | - | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
| |||
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
93 | | - | |
94 | | - | |
95 | | - | |
| 99 | + | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
| |||
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 118 | + | |
120 | 119 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
125 | 124 | | |
126 | 125 | | |
127 | 126 | | |
| |||
130 | 129 | | |
131 | 130 | | |
132 | 131 | | |
133 | | - | |
| 132 | + | |
134 | 133 | | |
135 | 134 | | |
136 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
137 | 138 | | |
138 | | - | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 144 | + | |
150 | 145 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
154 | 151 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
| 152 | + | |
162 | 153 | | |
163 | 154 | | |
164 | 155 | | |
| |||
202 | 193 | | |
203 | 194 | | |
204 | 195 | | |
205 | | - | |
| 196 | + | |
206 | 197 | | |
207 | 198 | | |
208 | 199 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
213 | 204 | | |
214 | 205 | | |
215 | 206 | | |
| |||
231 | 222 | | |
232 | 223 | | |
233 | 224 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
239 | 230 | | |
240 | 231 | | |
241 | 232 | | |
| |||
Lines changed: 11 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | | - | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
37 | | - | |
| 43 | + | |
38 | 44 | | |
39 | 45 | | |
40 | 46 | | |
| |||
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
53 | | - | |
| 59 | + | |
54 | 60 | | |
55 | 61 | | |
56 | 62 | | |
| |||
85 | 91 | | |
86 | 92 | | |
87 | 93 | | |
88 | | - | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
128 | 134 | | |
129 | 135 | | |
130 | 136 | | |
131 | | - | |
| 137 | + | |
132 | 138 | | |
133 | 139 | | |
134 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
Lines changed: 3 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | | - | |
239 | | - | |
| 237 | + | |
240 | 238 | | |
241 | 239 | | |
242 | 240 | | |
| |||
0 commit comments