NVIDIA / NVIDIA/cuvs

[BUG] CagraIndex with IVF-PQ fails with too many invalid or duplicated neighbor nodes

Open
#1,297 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Cuda
Stars
854
Forks
236
Avg merge
3d 3h
Merged PRs (30d)
62

Description

Describe the bug
When building a CagraIndex with IVF_PQ algorithm on a dataset of 768 dims, I am getting a failure " too many invalid or duplicated neighbor nodes". If I change the algorithm to "NN_DESCENT", the building of the graph succeeds.

Using Java API with default params for IVF.

  CagraIndexParams params = new CagraIndexParams.Builder().withNumWriterThreads(1) 
            .withCagraGraphBuildAlgo(CagraIndexParams.CagraGraphBuildAlgo.IVF_PQ)
            .withGraphDegree(M)
            .withIntermediateGraphDegree(intDegree)
            .withMetric(distanceType)
            .build();

 var indexBuilder = CagraIndex.newBuilder(cuVSResources).withDataset(dataset).withIndexParams(params);
var index = indexBuilder.build();
Caused by: java.lang.RuntimeException: cuvsCagraBuild returned 0[RAFT failure at file=/home/mayya/Elastic/cuvs/cpp/src/neighbors/detail/cagra/graph_core.cuh line=1417: Could not generate an intermediate CAGRA graph because the initial kNN graph contains too many invalid or duplicated neighbor nodes. This error can occur, for example, if too many overflows occur during the norm computation between the dataset vectors.
Obtained 6 stack frames
#1 in /home/mayya/Elastic/cuvs/cpp/build/install/lib/libcuvs_c.so: raft::logic_error::logic_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) +0x94 [0x731229877944]
#2 in /home/mayya/Elastic/cuvs/cpp/build/install/lib/libcuvs.so: void cuvs::neighbors::cagra::detail::graph::optimize<unsigned int, raft::host_device_accessor<std::experimental::default_accessor<unsigned int>, (raft::memory_type)0> >(raft::resources const&, std::experimental::mdspan<unsigned int, std::experimental::extents<long, 18446744073709551615ul, 18446744073709551615ul>, std::experimental::layout_right, raft::host_device_accessor<std::experimental::default_accessor<unsigned int>, (raft::memory_type)0> >, std::experimental::mdspan<unsigned int, std::experimental::extents<long, 18446744073709551615ul, 18446744073709551615ul>, std::experimental::layout_right, raft::host_device_accessor<std::experimental::default_accessor<unsigned int>, (raft::memory_type)0> >, bool, bool) +0x1ed1 [0x731176710701]
#3 in /home/mayya/Elastic/cuvs/cpp/build/install/lib/libcuvs.so: cuvs::neighbors::cagra::index<float, unsigned int> cuvs::neighbors::cagra::detail::build<float, unsigned int, raft::host_device_accessor<std::experimental::default_accessor<float const>, (raft::memory_type)0> >(raft::resources const&, cuvs::neighbors::cagra::index_params const&, std::experimental::mdspan<float const, std::experimental::extents<long, 18446744073709551615ul, 18446744073709551615ul>, std::experimental::layout_right, raft::host_device_accessor<std::experimental::default_accessor<float const>, (raft::memory_type)0> >) +0x93d [0x73117672c5ed]
#4 in /home/mayya/Elastic/cuvs/cpp/build/install/lib/libcuvs.so: cuvs::neighbors::cagra::build(raft::resources const&, cuvs::neighbors::cagra::index_params const&, std::experimental::mdspan<float const, std::experimental::extents<long, 18446744073709551615ul, 18446744073709551615ul>, std::experimental::layout_right, raft::host_device_accessor<std::experimental::default_accessor<float const>, (raft::memory_type)0> >) +0x35 [0x7311766f3205]
#5 in /home/mayya/Elastic/cuvs/cpp/build/install/lib/libcuvs_c.so: cuvsCagraBuild +0x410 [0x7312298a4280]
#6 in [0x731357e2a227]
]
        at com.nvidia.cuvs.internal.common.Util.checkCuVSError(Util.java:74) ~[?:?]
        at com.nvidia.cuvs.internal.CagraIndexImpl.build(CagraIndexImpl.java:194) ~[?:?]
        at com.nvidia.cuvs.internal.CagraIndexImpl.<init>(CagraIndexImpl.java:81) ~[?:?]
        at com.nvidia.cuvs.internal.CagraIndexImpl$Builder.build(CagraIndexImpl.java:777) ~[?:?]
        at com.nvidia.cuvs.internal.CagraIndexImpl$Builder.build(CagraIndexImpl.java:721) ~[?:?]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CAGRA graph-building failure at cpp/src/neighbors/detail/cagra/graph_core.cuh:1417 and trace how IVF_PQ differs from NN_DESCENT. Review the Java path in CagraIndexImpl.java, especially the build call around lines 194 and 721-777. Reproduce the 768-dimensional dataset case and identify a reliable fix or documented handling for the invalid or duplicated neighbor error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, java
Domain
machine-learning, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.