faiss 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/ext/faiss/extconf.rb +1 -1
  4. data/ext/faiss/index.cpp +10 -14
  5. data/ext/faiss/numo.hpp +957 -833
  6. data/lib/faiss/version.rb +1 -1
  7. data/vendor/faiss/faiss/AutoTune.cpp +11 -8
  8. data/vendor/faiss/faiss/Clustering.cpp +0 -16
  9. data/vendor/faiss/faiss/IVFlib.cpp +213 -0
  10. data/vendor/faiss/faiss/IVFlib.h +42 -0
  11. data/vendor/faiss/faiss/Index.h +1 -1
  12. data/vendor/faiss/faiss/IndexBinaryFlat.cpp +9 -7
  13. data/vendor/faiss/faiss/IndexBinaryFlat.h +2 -1
  14. data/vendor/faiss/faiss/IndexFlatCodes.cpp +1 -1
  15. data/vendor/faiss/faiss/IndexFlatCodes.h +4 -2
  16. data/vendor/faiss/faiss/IndexHNSW.cpp +13 -20
  17. data/vendor/faiss/faiss/IndexHNSW.h +1 -1
  18. data/vendor/faiss/faiss/IndexIVF.cpp +20 -3
  19. data/vendor/faiss/faiss/IndexIVF.h +5 -2
  20. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +2 -1
  21. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h +2 -1
  22. data/vendor/faiss/faiss/IndexIVFFlat.cpp +2 -1
  23. data/vendor/faiss/faiss/IndexIVFFlat.h +2 -1
  24. data/vendor/faiss/faiss/IndexIVFPQ.cpp +2 -1
  25. data/vendor/faiss/faiss/IndexIVFPQ.h +2 -1
  26. data/vendor/faiss/faiss/IndexIVFRaBitQ.cpp +277 -0
  27. data/vendor/faiss/faiss/IndexIVFRaBitQ.h +70 -0
  28. data/vendor/faiss/faiss/IndexIVFSpectralHash.cpp +2 -1
  29. data/vendor/faiss/faiss/IndexIVFSpectralHash.h +2 -1
  30. data/vendor/faiss/faiss/IndexRaBitQ.cpp +148 -0
  31. data/vendor/faiss/faiss/IndexRaBitQ.h +65 -0
  32. data/vendor/faiss/faiss/IndexScalarQuantizer.cpp +2 -1
  33. data/vendor/faiss/faiss/IndexScalarQuantizer.h +2 -1
  34. data/vendor/faiss/faiss/clone_index.cpp +38 -3
  35. data/vendor/faiss/faiss/cppcontrib/factory_tools.cpp +19 -0
  36. data/vendor/faiss/faiss/cppcontrib/factory_tools.h +4 -11
  37. data/vendor/faiss/faiss/gpu/GpuAutoTune.cpp +2 -1
  38. data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +13 -3
  39. data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +1 -1
  40. data/vendor/faiss/faiss/gpu/StandardGpuResources.h +1 -1
  41. data/vendor/faiss/faiss/gpu/test/TestGpuIcmEncoder.cpp +112 -0
  42. data/vendor/faiss/faiss/impl/HNSW.cpp +35 -13
  43. data/vendor/faiss/faiss/impl/HNSW.h +5 -4
  44. data/vendor/faiss/faiss/impl/NNDescent.cpp +1 -1
  45. data/vendor/faiss/faiss/impl/RaBitQuantizer.cpp +519 -0
  46. data/vendor/faiss/faiss/impl/RaBitQuantizer.h +78 -0
  47. data/vendor/faiss/faiss/impl/ResultHandler.h +2 -2
  48. data/vendor/faiss/faiss/impl/code_distance/code_distance-sve.h +3 -4
  49. data/vendor/faiss/faiss/impl/index_read.cpp +220 -25
  50. data/vendor/faiss/faiss/impl/index_write.cpp +29 -0
  51. data/vendor/faiss/faiss/impl/io.h +2 -2
  52. data/vendor/faiss/faiss/impl/io_macros.h +2 -0
  53. data/vendor/faiss/faiss/impl/mapped_io.cpp +313 -0
  54. data/vendor/faiss/faiss/impl/mapped_io.h +51 -0
  55. data/vendor/faiss/faiss/impl/maybe_owned_vector.h +316 -0
  56. data/vendor/faiss/faiss/impl/platform_macros.h +7 -3
  57. data/vendor/faiss/faiss/impl/simd_result_handlers.h +1 -1
  58. data/vendor/faiss/faiss/impl/zerocopy_io.cpp +67 -0
  59. data/vendor/faiss/faiss/impl/zerocopy_io.h +32 -0
  60. data/vendor/faiss/faiss/index_factory.cpp +16 -5
  61. data/vendor/faiss/faiss/index_io.h +4 -0
  62. data/vendor/faiss/faiss/invlists/InvertedLists.cpp +3 -3
  63. data/vendor/faiss/faiss/invlists/InvertedLists.h +5 -3
  64. data/vendor/faiss/faiss/invlists/InvertedListsIOHook.cpp +3 -3
  65. data/vendor/faiss/faiss/python/python_callbacks.cpp +24 -0
  66. data/vendor/faiss/faiss/python/python_callbacks.h +22 -0
  67. data/vendor/faiss/faiss/utils/approx_topk_hamming/approx_topk_hamming.h +30 -12
  68. data/vendor/faiss/faiss/utils/hamming.cpp +45 -21
  69. data/vendor/faiss/faiss/utils/hamming.h +7 -3
  70. data/vendor/faiss/faiss/utils/hamming_distance/avx512-inl.h +1 -1
  71. data/vendor/faiss/faiss/utils/utils.cpp +4 -4
  72. data/vendor/faiss/faiss/utils/utils.h +3 -3
  73. metadata +18 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae4ad57a987514417c76771a7318c454a505d108c60ee312eef12548c97bb21a
4
- data.tar.gz: ccb724de6af1ea2b4e1a820ff28827cfdc881ca953ef9f0c03c2dcf3602567f1
3
+ metadata.gz: 57303540dbb2c3de9e0d34e8a3ffcbb7c31ed44bb71ece9cafeb8de80594660d
4
+ data.tar.gz: 31c77390c331a0622c230bb245751ab3799196b0918f542fb4ba49b7582f28c9
5
5
  SHA512:
6
- metadata.gz: 0d936042d4e70c21abfa584b1154a23bf312e6f2418df963a1a076abd7f7b3179782c10aa5eefa8e3f95a0984594e7e1ebecb858ca3673dd28208a895a2c3252
7
- data.tar.gz: 45588388c9d15510d57f3d0db66d2ff9868f59c5eddc49507d72e247b962f270e62b5a44a7b70d38c570b31af5cc604156ab71dd7477a0240baa089d73a709af
6
+ metadata.gz: 2879d2d866bf10d1dc745841b5047933f43d9e84003b8b3c49a9ac5862be48c9fae31d042d2b39f2aaf188e1f110aa1ffd05b050c0f6510a35670724f890652c
7
+ data.tar.gz: 92dcbf603c5fab0b5f3fadfe377b91ec92e40840d91169cabb86f7c32d87f3b611937f4ad2423fe76abdc787af418de02bd23467a78a9b15633dd06a3c9d8187
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.4.0 (2025-04-25)
2
+
3
+ - Updated Faiss to 1.11.0
4
+ - Dropped support for Ruby < 3.2
5
+
6
+ ## 0.3.4 (2025-02-10)
7
+
8
+ - Fixed error with Rice 4.5
9
+
1
10
  ## 0.3.3 (2025-01-30)
2
11
 
3
12
  - Updated Faiss to 1.10.0
data/ext/faiss/extconf.rb CHANGED
@@ -20,7 +20,7 @@ abort "Numo not found" unless find_header("numo/narray.h", numo)
20
20
  $LDFLAGS += " -Wl,-undefined,dynamic_lookup" if RbConfig::CONFIG["host_os"] =~ /darwin/i
21
21
 
22
22
  $CXXFLAGS += " -std=c++17 $(optflags) -DFINTEGER=int"
23
- $CXXFLAGS += " -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wno-deprecated-declarations -Wno-sign-compare"
23
+ $CXXFLAGS += " -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wno-unused-private-field -Wno-deprecated-declarations -Wno-sign-compare"
24
24
 
25
25
  # -march=native not supported with ARM Mac
26
26
  default_optflags = RbConfig::CONFIG["host_os"] =~ /darwin/i && RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i ? "" : " -march=native"
data/ext/faiss/index.cpp CHANGED
@@ -17,10 +17,7 @@ namespace Rice::detail {
17
17
  template<>
18
18
  struct Type<faiss::MetricType>
19
19
  {
20
- static bool verify()
21
- {
22
- return true;
23
- }
20
+ static bool verify() { return true; }
24
21
  };
25
22
 
26
23
  template<>
@@ -29,9 +26,9 @@ namespace Rice::detail {
29
26
  public:
30
27
  From_Ruby() = default;
31
28
 
32
- From_Ruby(Arg* arg) : arg_(arg)
33
- {
34
- }
29
+ From_Ruby(Arg* arg) : arg_(arg) {}
30
+
31
+ Convertible is_convertible(VALUE value) { return Convertible::Cast; }
35
32
 
36
33
  faiss::MetricType convert(VALUE x)
37
34
  {
@@ -56,16 +53,15 @@ namespace Rice::detail {
56
53
  template<>
57
54
  struct Type<faiss::ScalarQuantizer::QuantizerType>
58
55
  {
59
- static bool verify()
60
- {
61
- return true;
62
- }
56
+ static bool verify() { return true; }
63
57
  };
64
58
 
65
59
  template<>
66
60
  class From_Ruby<faiss::ScalarQuantizer::QuantizerType>
67
61
  {
68
62
  public:
63
+ Convertible is_convertible(VALUE value) { return Convertible::Cast; }
64
+
69
65
  faiss::ScalarQuantizer::QuantizerType convert(VALUE x)
70
66
  {
71
67
  auto s = Object(x).to_s().str();
@@ -166,10 +162,10 @@ void init_index(Rice::Module& m) {
166
162
  .define_constructor(Rice::Constructor<faiss::IndexFlatIP, int64_t>());
167
163
 
168
164
  Rice::define_class_under<faiss::IndexHNSWFlat, faiss::Index>(m, "IndexHNSWFlat")
169
- .define_constructor(Rice::Constructor<faiss::IndexHNSWFlat, int, int, faiss::MetricType>(), Rice::Arg("d"), Rice::Arg("M"), Rice::Arg("metric") = faiss::METRIC_L2);
165
+ .define_constructor(Rice::Constructor<faiss::IndexHNSWFlat, int, int, faiss::MetricType>(), Rice::Arg("_d"), Rice::Arg("_M"), Rice::Arg("_metric") = faiss::METRIC_L2);
170
166
 
171
167
  Rice::define_class_under<faiss::IndexIVFFlat, faiss::Index>(m, "IndexIVFFlat")
172
- .define_constructor(Rice::Constructor<faiss::IndexIVFFlat, faiss::Index*, size_t, size_t, faiss::MetricType>(), Rice::Arg("quantizer"), Rice::Arg("d"), Rice::Arg("nlist"), Rice::Arg("metric") = faiss::METRIC_L2);
168
+ .define_constructor(Rice::Constructor<faiss::IndexIVFFlat, faiss::Index*, size_t, size_t, faiss::MetricType>(), Rice::Arg("_quantizer"), Rice::Arg("_d"), Rice::Arg("_nlist"), Rice::Arg("_metric") = faiss::METRIC_L2);
173
169
 
174
170
  Rice::define_class_under<faiss::IndexLSH, faiss::Index>(m, "IndexLSH")
175
171
  .define_constructor(Rice::Constructor<faiss::IndexLSH, int64_t, int>());
@@ -184,7 +180,7 @@ void init_index(Rice::Module& m) {
184
180
  .define_constructor(Rice::Constructor<faiss::IndexIVFScalarQuantizer, faiss::Index*, size_t, size_t, faiss::ScalarQuantizer::QuantizerType>());
185
181
 
186
182
  Rice::define_class_under<faiss::IndexIVFPQ, faiss::Index>(m, "IndexIVFPQ")
187
- .define_constructor(Rice::Constructor<faiss::IndexIVFPQ, faiss::Index*, size_t, size_t, size_t, size_t, faiss::MetricType>(), Rice::Arg("quantizer"), Rice::Arg("d"), Rice::Arg("nlist"), Rice::Arg("M"), Rice::Arg("nbits_per_idx"), Rice::Arg("metric") = faiss::METRIC_L2);
183
+ .define_constructor(Rice::Constructor<faiss::IndexIVFPQ, faiss::Index*, size_t, size_t, size_t, size_t, faiss::MetricType>(), Rice::Arg("_quantizer"), Rice::Arg("_d"), Rice::Arg("_nlist"), Rice::Arg("_M"), Rice::Arg("_nbits_per_idx"), Rice::Arg("_metric") = faiss::METRIC_L2);
188
184
 
189
185
  Rice::define_class_under<faiss::IndexIVFPQR, faiss::Index>(m, "IndexIVFPQR")
190
186
  .define_constructor(Rice::Constructor<faiss::IndexIVFPQR, faiss::Index*, size_t, size_t, size_t, size_t, size_t, size_t>());