Skip to content
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

add skip_storage flag to HNSW #3487

Closed
wants to merge 1 commit into from

Conversation

mdouze
Copy link
Contributor

@mdouze mdouze commented May 29, 2024

Summary:
Sometimes it is not useful to serialize the storage index along with a HNSW index. This diff adds a flag that supports skipping the storage of the index.

Searchign and adding to the index is not possible until a storage index is added back in.

Differential Revision: D57911060

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D57911060

WRITE1(n4);
} else {
write_index(idxhnsw->storage, f);
}
write_index(idxhnsw->storage, f);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writing the storage twice, dupilcate rows 770 and 772

@@ -251,7 +249,8 @@ void hnsw_search(
const SearchParameters* params_in) {
FAISS_THROW_IF_NOT_MSG(
index->storage,
"Please use IndexHNSWFlat (or variants) instead of IndexHNSW directly");
"No storage index, please use IndexHNSWFlat (or variants) "
"instead of IndexHNSW directly");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do we prefer to using IndexHNSW and when should we use IndexHNSWFlat?

@@ -531,7 +530,10 @@ Index* read_index(IOReader* f, int io_flags) {
Index* idx = nullptr;
uint32_t h;
READ1(h);
if (h == fourcc("IxFI") || h == fourcc("IxF2") || h == fourcc("IxFl")) {
if (h == fourcc("null")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do we see the caller provide null ?

@@ -765,6 +763,12 @@ void write_index(const Index* idx, IOWriter* f) {
WRITE1(h);
write_index_header(idxhnsw, f);
write_HNSW(&idxhnsw->hnsw, f);
if (io_flags & IO_FLAG_SKIP_STORAGE) {
uint32_t n4 = fourcc("null");
WRITE1(n4);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it gonna to output in stdout?

np.testing.assert_array_equal(Dnew, Dref)
np.testing.assert_array_equal(Inew, Iref)

if False:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do we define the False?

@junjieqi
Copy link
Contributor

format & internal linter

Summary:

Sometimes it is not useful to serialize the storage index along with a HNSW index. This diff adds a flag that supports skipping the storage of the index.

Searchign and adding to the index is not possible until a storage index is added back in.

Reviewed By: junjieqi

Differential Revision: D57911060
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D57911060

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in bf73e38.

tarang-jain pushed a commit to tarang-jain/faiss that referenced this pull request Jul 5, 2024
Summary:
Pull Request resolved: facebookresearch#3487

Sometimes it is not useful to serialize the storage index along with a HNSW index. This diff adds a flag that supports skipping the storage of the index.

Searchign and adding to the index is not possible until a storage index is added back in.

Reviewed By: junjieqi

Differential Revision: D57911060

fbshipit-source-id: 5a4ceee4a8f53f6f746df59af3942b813a99c14f
abhinavdangeti pushed a commit to blevesearch/faiss that referenced this pull request Jul 12, 2024
Summary:
Pull Request resolved: facebookresearch#3487

Sometimes it is not useful to serialize the storage index along with a HNSW index. This diff adds a flag that supports skipping the storage of the index.

Searchign and adding to the index is not possible until a storage index is added back in.

Reviewed By: junjieqi

Differential Revision: D57911060

fbshipit-source-id: 5a4ceee4a8f53f6f746df59af3942b813a99c14f
aalekhpatel07 pushed a commit to aalekhpatel07/faiss that referenced this pull request Oct 17, 2024
Summary:
Pull Request resolved: facebookresearch#3487

Sometimes it is not useful to serialize the storage index along with a HNSW index. This diff adds a flag that supports skipping the storage of the index.

Searchign and adding to the index is not possible until a storage index is added back in.

Reviewed By: junjieqi

Differential Revision: D57911060

fbshipit-source-id: 5a4ceee4a8f53f6f746df59af3942b813a99c14f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants