pgvecto.rs icon indicating copy to clipboard operation
pgvecto.rs copied to clipboard

Any plan to speed up pgvector.rs with Intel AMX instruction?

Open george-gu-2021 opened this issue 1 year ago • 4 comments

I came across the highly creative project which addresses the vector search inside PosgreSQL, one of the most popular open source databases.

Intel Xeon platform supports AMX instruction which can accelerate vector inner-product computation significantly. May I know if we have a plan to speed up pgvevtor.rs with the advanced CPU instruction? @gaocegege

george-gu-2021 avatar Aug 03 '24 06:08 george-gu-2021

I had some investigation with AMX before. The conclusion I got is that AMX won't provide speed up for dot product. It's possible to provide some speed up but not too much on matrix vector multiplication. Is this right?

We're interested in AMX but doesn't know it a lot. Would be nice if we can have some collaborations here!

VoVAllen avatar Aug 03 '24 07:08 VoVAllen

Regarding the gain from AMX instruction, it may depend on the scenario and usage method.

May I know the vectors are stored in continuous memory in column oriented? If it is, AMX may speed up ~4X for single query in index flat algorithm per our estimation.

george-gu-2021 avatar Aug 03 '24 07:08 george-gu-2021

The storage layout is flexible for us, and we're also doing some new algorithm on IVF. Therefore we're definitely interested on the acceleration for vector matrix distance computation. Is there any real world AMX code we can learn from?

VoVAllen avatar Aug 03 '24 07:08 VoVAllen

Here is the PR which illustrates the AMX acceleration for FAISS library for your reference. https://github.com/facebookresearch/faiss/pull/3266

george-gu-2021 avatar Aug 03 '24 07:08 george-gu-2021