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

hnswlib.v0.8.0: checkIntegrity fail on tests/cpp/sift_1b.cpp #586

Open
lyj-fdu opened this issue Aug 31, 2024 · 2 comments
Open

hnswlib.v0.8.0: checkIntegrity fail on tests/cpp/sift_1b.cpp #586

lyj-fdu opened this issue Aug 31, 2024 · 2 comments

Comments

@lyj-fdu
Copy link

lyj-fdu commented Aug 31, 2024

My branch is at v0.8.0. When building hnsw index in tests/cpp/sift_1b.cpp, I add appr_alg->checkIntegrity(); on line 346 to see if the graph built by the algorithm has in-edge for every node during report_every. However, the assertion fail!

the code fragment I modified is as follows

                if (j1 % report_every == 0) {
                    cout << j1 / (0.01 * vecsize) << " %, "
                         << report_every / (1000.0 * 1e-6 * stopw.getElapsedTimeMicro()) << " kips " << " Mem: "
                         << getCurrentRSS() / 1000000 << " Mb \n";
                    stopw.reset();
                    appr_alg->checkIntegrity(); // add this at line 346
                }

the output of command line like this

~/code/hnswlib/tests/cpp/downloads$ ../../../build/main 
Loading GT:
Loading queries:
Building index:
0.05 %, 40.9574 kips  Mem: 40877 Mb 
main: ~/code/hnswlib/tests/cpp/../../hnswlib/hnswalg.h:1403: void hnswlib::HierarchicalNSW<dist_t>::checkIntegrity() [with dist_t = int]: Assertion `inbound_connections_num[i] > 0' failed.
Aborted (core dumped)

If some node has no in-edge, then it's totally isolated, which means that search on the graph will never visisted it, even it has out-edge.

@lyj-fdu lyj-fdu changed the title checkIntegrity failed on cpp/tests/sift_1b.cpp checkIntegrity failed on tests/cpp/sift_1b.cpp Aug 31, 2024
@lyj-fdu lyj-fdu changed the title checkIntegrity failed on tests/cpp/sift_1b.cpp hnswlib.v0.8.0: checkIntegrity failed on tests/cpp/sift_1b.cpp Aug 31, 2024
@lyj-fdu lyj-fdu changed the title hnswlib.v0.8.0: checkIntegrity failed on tests/cpp/sift_1b.cpp hnswlib.v0.8.0: checkIntegrity fail on tests/cpp/sift_1b.cpp Aug 31, 2024
@YReddice
Copy link

YReddice commented Sep 8, 2024

Yes, I've encountered the same situation, and it does look as if the hnsw algorithm can't avoid nodes with in-degree 0, even if all points have out-degree.

@YReddice
Copy link

YReddice commented Sep 8, 2024

i think it may be because when the new insertion point creates an edge with its immediate neighbors, the cropping of the neighbor points happens to crop out the new insertion point. Do you know the cause or any other findings?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants