Speed up ivfflat build: use float instead of double for dot product#180
Conversation
c93807e to
b798a75
Compare
calculation On ARM this makes CPU using vector multiply-add instruction (fmadd) instead of vector multiplication + conversion to double + addition (fmul + fcvt + fadd) at each vector dimension. Output of distance functions and calculations that are are done once per vector pair are left double as this don't make speed difference and for compatibility.
b798a75 to
e0dc34d
Compare
|
The results of tests are following:
Base: dbpedia-openai-1M, index on inner product and queries using <#> operator, results dbpedia-openai-angular.png. Float calculation has speedup in select queries probably because it is used calculation in query vector to ivfflat list vectors.
Speedup from patch for k-means and assign stage #1 is approximately equal (in percent) |
|
Thanks @pashkinelfe, this is really great!! (both the performance win and the benchmarks) 🚀 🚀 🚀 Looks like it unlocks fused multiply-add on both aarch64 and x86_64 (additional benchmarks). We should probably apply it to the |
|
Updated |
|
Just fyi: switched to |



This is the first patch of patchset #178 as requested in the comments #178 (comment)
Regarding the conversion of the distance functions interface from double to float it will need modification of vector.sql interface which may need a major extension upgrade. If we're ready for this, I'd easily modify the patch as requested in #178 (comment) As of now I've left it as is for compatibility, and as this modifications will not make it much faster to build ivfflat index.