-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Enable Intel ScalableVectorSearch support #4548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dian-lun-lin
wants to merge
174
commits into
facebookresearch:main
Choose a base branch
from
ahuber21:svs-io
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,003
−2
Open
Changes from 147 commits
Commits
Show all changes
174 commits
Select commit
Hold shift + click to select a range
8fd27d6
init SVS uncompressed data support
c499b93
Merge branch 'facebookresearch:main' into svs-init
0bd1fdd
initial naive additional of SVS i/o
ahuber21 6885f30
use Tempfilename
ahuber21 0215940
Add I/O to example
ahuber21 d4d1226
revise, add LVQ, and python bindings
48904f3
on going work
b4c768a
cleanup after cherry-picking aaron's latest commits
ahuber21 5cf26a9
First implementation of IndexSVSFlat
ahuber21 11b44f7
implement first feedback
ahuber21 9854e82
Merge remote-tracking branch 'origin/main' into svs-io
ahuber21 0df0771
Fix tests for LVQ4x4
ahuber21 014960d
add LVQ4x8
ahuber21 09c0db5
initial set of SVS python tests
ahuber21 969d595
fix some tests
ahuber21 9e3c48e
support LVQ/LeanVec runtime quantization level
a585e9d
Merge pull request #2 from ahuber21/svs-lvq-leanvec-run-params
ahuber21 7eb6289
Fix LVQ in test_svs.cpp
ahuber21 6dbb96f
clang-format
ahuber21 90b15b6
fix impl cleanup in destructor
ahuber21 38b7eea
continue work on C++ & py tests
ahuber21 4f36df5
enable SVS LeanVec
713cc36
Merge pull request #3 from ahuber21/svs-leanvec
ahuber21 8f16863
I/O support for LeanVec
ahuber21 034320b
support SVS index factory
c7c3577
enable clang format
9ff7b53
Merge pull request #4 from ahuber21/svs-factory
ahuber21 b2b9819
streaming write to disk
ahuber21 d31bcb1
change how files are streamed
ahuber21 483193a
Update SVS version
ahuber21 caf1f90
Add FAISS_USE_SVS flag
ahuber21 38ef801
fixup
ahuber21 42b2208
fix FAISS_USE_SVS
ahuber21 6873aa3
add LeanVec load test
ahuber21 b51ce17
add I/O to IndexSVSFlat
ahuber21 c7fb7df
Refactor I/O functions into svs_io
ahuber21 42adb07
cleanup includes and fwd decl
ahuber21 3378077
rename FAISS_USE_SVS -> FAISS_ENABLE_SVS
ahuber21 363ec05
Swith SVS threading to OpenMP
250b74f
Merge pull request #5 from ahuber21/svs-omp
ahuber21 00dd505
fix tests
ahuber21 4f83fd0
fix avx and sve builds
ahuber21 d264256
update svs version for omp bug fix
d7ad33f
Merge pull request #6 from ahuber21/svs-omp-fix
ahuber21 32d5063
support svs factory format
0a62dee
Merge pull request #7 from ahuber21/svs-factory-format
ahuber21 95bf6bd
fix tests after renaming classes
ahuber21 0542ed7
Merge remote-tracking branch 'origin/main' into svs-io
ahuber21 021c558
fix typo
ahuber21 19c9181
cleanup
ahuber21 ff37171
fixup merge error
ahuber21 4f5dc9a
support svs remove_ids
d61d1cb
update ts
2e19a56
Merge pull request #8 from ahuber21/svs-remove-ids
ahuber21 a28c1ee
support fallback for non-intel hardware
87e85c4
enable clang format
b634f6a
Merge pull request #9 from ahuber21/svs-fallback
ahuber21 da72c1a
svs factory format update
fd52aa1
Merge pull request #10 from ahuber21/svs-factory-format-update
ahuber21 26023b0
Add Float16 and SQ I8 support to `IndexSVSVamana` class
rfsaliev 741d0ed
delete accidentally added file
ahuber21 4da3db8
Merge pull request #13 from ahuber21/chore/rm-file
ahuber21 53bd413
Merge pull request #12 from ahuber21/rfsaliev/fp16-sq
ahuber21 7a7931c
fix(svs-io): Don't rely on EOF when loading SVS indices
ahuber21 9e05e00
Merge pull request #21 from ahuber21/dev/ahuber/improve-io
ahuber21 d7009fc
chore(test-svs): remove need for temp files
ahuber21 d5ccad6
chore(test-svs): remove need for temp files
ahuber21 8cb7a7e
chore(test-svs): skip tests if compiled without SVS
ahuber21 40dc90d
Merge pull request #23 from ahuber21/dev/ahuber/skip-svs-if-not-compiled
ahuber21 c45d09a
[SVS] Add support for IDSelecttor and range_search()
rfsaliev 278e9ba
Fix distance comparison in
rfsaliev 734e5f3
Define SearchParametersSVSVamana
rfsaliev baa42c9
Add python tests
rfsaliev 38fe2ea
Fix iterator batch size in range_search()
rfsaliev dce50d9
Parallelize batch iterators
rfsaliev c74b659
Code review fixes and range search refactoring
rfsaliev 21f8bf4
Code review s1e2
rfsaliev 2a8bac7
basic testing idselector & range_search (#24)
ahuber21 421e582
Fix-update CPP SVS tests
rfsaliev 009e135
Merge pull request #17 from ahuber21/rfsaliev/filered-search
1fcbc1e
Merge branch 'facebookresearch:main' into svs-io
a9e5235
update intel license/copyright
d7b276f
Merge pull request #27 from ahuber21/svs-license-copyright
972818c
revise based on comments and enable clang format
ba0e52a
Merge pull request #28 from ahuber21/svs-revise
38cc069
refactor
2469976
Merge pull request #29 from ahuber21/svs-refactor
96ba302
Merge branch 'facebookresearch:main' into svs-io
be5560c
Use new SVS Vamana streaming capabilities
rfsaliev 22600e3
Update IndexSVSFlat serialization and remove SVSTempDirectory
rfsaliev 5811cde
update SVS package
f5fb356
Merge pull request #30 from ahuber21/rfsaliev/save-load-stream
3ce665a
Merge branch 'facebookresearch:main' into svs-io
c85c538
enable clang format
13e3897
clang format for conecpt
3537df7
Merge pull request #32 from ahuber21/svs-clang-format
4c3c82e
update submodule to support gcc14
c14ab71
Merge pull request #33 from ahuber21/svs-update
6da649f
Merge branch 'main' into svs-io
b9ef77f
Initial commit for FAISS bindings in SVS
rfsaliev 8c80f6a
Reflect SVS Flat implementation cahnges.
rfsaliev 95e8f66
fix(io): don't read too many bytes from IOReader
ahuber21 63ba062
Merge pull request #36 from ahuber21/svs-io-fix-buffering
ahuber21 2dce7f4
fix(svsio): allow writing/reading of non-initialized index
ahuber21 a5800d4
Merge pull request #38 from ahuber21/svs-io-fix-noninit-serialization
ahuber21 074f645
Restore SVS integration files but based in the new API.
rfsaliev 01ab8df
fix nulllptr return
ahuber21 2414431
LVQ nad LeanVec enums redefinition to fix swigfaiss build
rfsaliev f71cf1e
add test cases for saving/loading uninitialized index & trained index…
ahuber21 230d202
store leanvec matrix
ahuber21 27b1b9d
store leanvec matrix
ahuber21 edbe9cd
update svs release
ahuber21 b709fa1
Merge pull request #39 from ahuber21/svs-io-fix-noninit-serialization…
ahuber21 06a1f31
runtime namespace updates
ethanglaser d4c0557
Update SVS_URL to GH releases bindings tarball
ethanglaser 6539d5e
Merge pull request #40 from ethanglaser/rfsaliev/svs-faiss-bindings
ahuber21 d6ab3f1
Merge branch 'svs-io' into rfsaliev/svs-faiss-bindings
ahuber21 3cedda6
fix: is_trained logic and serializing members
ahuber21 a20d2a7
fixup: remove redundant semicolon
ahuber21 d895b99
Use training info
ahuber21 9fdd2f6
updates for new interface version
ahuber21 6b42374
update flat to new runtime; use v0 api
ahuber21 e6f2c9a
fix python tests
ahuber21 29086ae
Remove unused enum
ahuber21 211832f
rename SVS_RUNTIME_VERSION -> FAISS_SVS_RUNTIME_VERSION
ahuber21 056cb8c
Merge pull request #41 from ahuber21/ahuber/svs-faiss-bindings
ahuber21 bef9914
Update svs runtime usage according to latest changes
rfsaliev 0a63ff9
Update library URL
ahuber21 203760c
Merge pull request #34 from ahuber21/rfsaliev/svs-faiss-bindings
ahuber21 82ebccf
clean up removed class
ahuber21 63542b1
update svs defaults
ahuber21 34b0dfa
inline v0
ahuber21 e755372
Merge pull request #42 from ahuber21/svs-io-cleanup
ahuber21 26c404e
Merge remote-tracking branch 'origin/main' into svs-io-pull-main
ahuber21 3871583
Merge pull request #43 from ahuber21/svs-io-pull-main
ahuber21 64c6910
set FAISS_SVS_RUNTIME_VERSION as string instead of bool
ethanglaser 6650142
Merge pull request #44 from ethanglaser/eglaser/runtime-version-revision
mihaic 83b39e0
Merge branch 'main' into svs-io
mnorris11 4abda24
fix test skip if SVS not compiled in
ahuber21 f715931
Merge pull request #45 from ahuber21/dev/svs-io/fix-test-skip
ahuber21 268eaca
Merge branch 'facebookresearch:main' into svs-io
ahuber21 3e25e2b
check supported storage kind in constructor
ahuber21 0e043e2
add comment explaining behavior
ahuber21 a184486
formatting fix
ahuber21 9a0fa75
add tests for lvq/leanvec enabled
ahuber21 a2f33f2
renamed SQ8 -> SQI8
ahuber21 e9c76cd
split tests
ahuber21 462908d
change is_lvq_leanvec_enabled() implementation
ahuber21 952563d
add portions copyright
ahuber21 34a411f
missing newline
ahuber21 7dbdd60
clean up comments
ahuber21 ea50f11
add_ref_in_constructor for new classes
ahuber21 7a342f4
cleanup swigfaiss.swig
ahuber21 faeb765
Merge pull request #47 from ahuber21/dev/svs-io/review-2
ahuber21 5d5d464
Merge branch 'main' into svs-io
ahuber21 8c838a4
Apply output buffer converter to FaissResultsAllocator
rfsaliev bf7c9f2
Merge pull request #46 from ahuber21/dev/svs-io/check-storage-kind
ahuber21 0cf8c2a
fix double free
ahuber21 6d5ad77
Merge pull request #48 from ahuber21/dev/svs-io/fix-double-free
ahuber21 4b6c644
fix errorcode check
ahuber21 3831e8e
add svs workflows
ahuber21 33b0cd3
Merge pull request #49 from ahuber21/dev/svs-io/tests-and-ci
ahuber21 e672cf5
Merge branch 'main' into svs-io
ahuber21 2af4cf1
update SVS lib
ahuber21 d81dc00
test fixes
ahuber21 f82831a
Update SVS_URL to latest binary
ethanglaser 7bf2b62
Merge pull request #50 from ethanglaser/eglaser/svs-binary-update
ahuber21 2f5bae6
fix no lvq/leanvec test
ahuber21 d06d2fb
harmonize exception behavior if storage is not supported
ahuber21 a4edce0
fix leanvec fallback test
ahuber21 4bbf61e
Merge branch 'main' into svs-io
mnorris11 2a14910
fix: artifact name with svs enabled
ahuber21 ca7f66b
add FAISS_ENABLE_SVS
ahuber21 7346953
copy/install svs runtime if available
ahuber21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Portions Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
| /* | ||
| * Portions Copyright 2025 Intel Corporation | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include <faiss/impl/svs_io.h> | ||
|
|
||
| #include <algorithm> | ||
| #include <cstdlib> | ||
|
|
||
| #include <faiss/impl/FaissAssert.h> | ||
|
|
||
| namespace faiss { | ||
| namespace svs_io { | ||
|
|
||
| WriterStreambuf::WriterStreambuf(IOWriter* w_) : w(w_) {} | ||
|
|
||
| WriterStreambuf::~WriterStreambuf() = default; | ||
|
|
||
| std::streamsize WriterStreambuf::xsputn(const char* s, std::streamsize n) { | ||
| if (n <= 0) | ||
| return 0; | ||
| size_t wrote = (*w)(s, 1, static_cast<size_t>(n)); | ||
| return static_cast<std::streamsize>(wrote); | ||
| } | ||
|
|
||
| int WriterStreambuf::overflow(int ch) { | ||
| if (ch == traits_type::eof()) | ||
| return 0; | ||
| char c = static_cast<char>(ch); | ||
| size_t wrote = (*w)(&c, 1, 1); | ||
| return wrote == 1 ? ch : traits_type::eof(); | ||
| } | ||
|
|
||
| ReaderStreambuf::ReaderStreambuf(IOReader* rr) : r(rr), single_char_buffer(0) { | ||
| // Initialize with empty get area | ||
| setg(nullptr, nullptr, nullptr); | ||
| } | ||
|
|
||
| ReaderStreambuf::~ReaderStreambuf() = default; | ||
|
|
||
| std::streambuf::int_type ReaderStreambuf::underflow() { | ||
| // Called by std::istream for single-character operations (get, peek, etc.) | ||
| // when the get area is exhausted. Reads one byte from IOReader. | ||
| size_t got = (*r)(&single_char_buffer, 1, 1); | ||
| if (got == 0) { | ||
| return traits_type::eof(); | ||
| } | ||
|
|
||
| // Configure get area to expose the single buffered character | ||
| setg(&single_char_buffer, &single_char_buffer, &single_char_buffer + 1); | ||
| return traits_type::to_int_type(single_char_buffer); | ||
| } | ||
|
|
||
| std::streamsize ReaderStreambuf::xsgetn(char* s, std::streamsize n) { | ||
| // Called by std::istream for bulk reads (read, readsome, etc.). | ||
| // Forwards directly to IOReader without intermediate buffering to avoid | ||
| // advancing IOReader beyond what the stream consumer requested. | ||
| if (n <= 0) { | ||
| return 0; | ||
| } | ||
|
|
||
| size_t got = (*r)(s, 1, n); | ||
| return static_cast<std::streamsize>(got); | ||
| } | ||
|
|
||
| } // namespace svs_io | ||
| } // namespace faiss | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about directly implementing the I/O with the Faiss routines?
It seems that the amount of extra code needed to wrap the SVS I/O routines is about as large as just rewriting the I/O.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We plan to provide a cleaner interface for exactly this at a later point. For now, while this is quite some code, it's still a lot simpler than re-implementing SVS I/O entirely. Also, it gives us full flexibility to align with FAISS expectations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the update, this file now only provides a small utility to convert
IOReader/IOWriterobjects to std streams, which are now accepted in SVS.