mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-12 02:13:36 +00:00
Support CPU quantizer parameters in GPU autotune
Summary: IVF GPU indexes now support CPU quantizers. In order for the the auto-tuning to support accessing the parameters of the quantizers, GpuAutoTune needs to be adapted. Reviewed By: algoriddle Differential Revision: D42633348 fbshipit-source-id: ef472855aa882ccde9d878ae09782204045e38c5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2ae369c276
commit
c74cf4f52f
@@ -53,6 +53,14 @@ void GpuParameterSpace::initialize(const Index* index) {
|
||||
break;
|
||||
pr.values.push_back(nprobe);
|
||||
}
|
||||
|
||||
ParameterSpace ivf_pspace;
|
||||
ivf_pspace.initialize(ix->quantizer);
|
||||
|
||||
for (const ParameterRange& p : ivf_pspace.parameter_ranges) {
|
||||
ParameterRange& pr = add_range("quantizer_" + p.name);
|
||||
pr.values = p.values;
|
||||
}
|
||||
}
|
||||
// not sure we should call the parent initializer
|
||||
}
|
||||
@@ -83,6 +91,14 @@ void GpuParameterSpace::set_index_parameter(
|
||||
}
|
||||
}
|
||||
|
||||
if (name.find("quantizer_") == 0) {
|
||||
if (DC(GpuIndexIVF)) {
|
||||
std::string sub_name = name.substr(strlen("quantizer_"));
|
||||
set_index_parameter(ix->quantizer, sub_name, val);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// maybe normal index parameters apply?
|
||||
ParameterSpace::set_index_parameter(index, name, val);
|
||||
}
|
||||
|
||||
@@ -574,3 +574,21 @@ class TestLSQIcmEncoder(unittest.TestCase):
|
||||
def test_multiple_gpu(self):
|
||||
ngpu = faiss.get_num_gpus()
|
||||
self.subtest_gpu_encoding(ngpu)
|
||||
|
||||
|
||||
class TestGpuAutoTune(unittest.TestCase):
|
||||
|
||||
def test_params(self):
|
||||
index = faiss.index_factory(32, "IVF65536_HNSW,PQ16")
|
||||
index = faiss.index_cpu_to_gpu(faiss.StandardGpuResources(), 0, index)
|
||||
ps = faiss.GpuParameterSpace()
|
||||
ps.initialize(index)
|
||||
for i in range(ps.parameter_ranges.size()):
|
||||
pr = ps.parameter_ranges.at(i)
|
||||
if pr.name == "quantizer_efSearch":
|
||||
break
|
||||
else:
|
||||
self.fail("should include efSearch")
|
||||
ps.set_index_parameter(index, "quantizer_efSearch", 123)
|
||||
quantizer = faiss.downcast_index(index.quantizer)
|
||||
self.assertEqual(quantizer.hnsw.efSearch, 123)
|
||||
|
||||
@@ -246,6 +246,7 @@ namespace std {
|
||||
%template(InvertedListsPtrVector) std::vector<faiss::InvertedLists*>;
|
||||
%template(RepeatVector) std::vector<faiss::Repeat>;
|
||||
%template(ClusteringIterationStatsVector) std::vector<faiss::ClusteringIterationStats>;
|
||||
%template(ParameterRangeVector) std::vector<faiss::ParameterRange>;
|
||||
|
||||
#ifndef SWIGWIN
|
||||
%template(OnDiskOneListVector) std::vector<faiss::OnDiskOneList>;
|
||||
|
||||
Reference in New Issue
Block a user