Open QDXG-CXK opened 7 months ago
Hi there, thanks for a good question! It's been on our radars for a while, but it hasn't been clear so far whether pre-computing lookup tables per-query may get in the way of other raft optimizations.
In raft, the lookup table fully encodes distance components from the query to all possible vectors in a list (cluster). In particular, it depends on the distance from the query to the cluster center. Hence, it's unique for every (query, probe) pair.
As far as I know, some other implementations only encode the residual distances in the lookup table; in that case the lookup table needs only be constructed once per query. Both approaches have their pros and cons. Couple reasons to back up our choice:
I'd suggest we keep it open as a feature request, so that we can prioritize and try this as an optional optimization at some point.
Thanks @QDXG-CXK and @achirkin. I've gone ahead and converted this to a feature request so we can keep it on our radar.
Hi, I feel a little confused when readding the source code about the lut(lookup table) of IVF-PQ search.
Specifically, in
cpp/include/raft/neighbors/detail/ivf_pq_compute_similarity-inl.cuh
,it seems that the lookup table of a query is created multiple times whthin each block that focuses on that query. Given that each block handles a (query,probe) pair, a lookup table is createdn_probes
times. I'm curious about why we don't consider creating lookup tables for all querys and storing them in global memory before calling thecompute_similarity_kernel()
?Firstly, if we use shared memory for lut(
EnableSMemLut==true
), we can copy the prepared lut from global memory to shared memory for faster access. This approach would avoid slowly readding fromqueries
andcluster_centers
which located in global memory during the redundantly creatation of lut.Moreover, even if we don't use shared memory, creating lookup table only once before using it still looks better.
As a parallel computing novice, I acknowledge that I might be overlooking something crucial. Could you kindly provide insights or guidance on this matter?