Skip to content

[BUG] Test TestCagraToHnswSerializationAndSearch fails intermittently in CI #3082

Open

Description

@mc8max

Describe the bug
The test TestCagraToHnswSerializationAndSearch fails intermittently its recall assertion with a fixed seed AE135E2A8E29E166:B76BE3D67B11916A:

5 results were not among the closest 15, at most 4 allowed:
  query 1: ids [42, 723, 1730, 1500, 866] at ranks [17, 21, 23, 27, 28]

This test failure can be found in different PRs:

Steps/Code to reproduce bug
To produce this bug on an isolated environment,

  • Check out 7a3f538c and prepare the Lucene test environment as CI does.
  • Install the plain cuvs-java JAR into the local Maven repository, restore the lucene-10.5/target directory from the CI artifact, and add the directory containing the matching libcuvs_c.so to LD_LIBRARY_PATH. CI setup, build artifacts
  • Run the commands:
cd java/cuvs-lucene
mvn -B -ntp -pl lucene-10.5 test \
  -Dskip.compile=true -DfailIfNoTests=true \
  '-Dtest=TestCagraToHnswSerializationAndSearch#testCagraToHnswSerializationAndSearch' \
  -Dtests.seed=AE135E2A8E29E166:B76BE3D67B11916A -Dtests.iters=50 \
  -Dtests.locale=tt-RU -Dtests.timezone=Africa/Kigali \
  -Dtests.asserts=true -Dtests.file.encoding=UTF-8

This setup fails 7 of 50 iterations.

Expected behavior
At most 4 of 50 returned neighbors should fail compared to the query's brute-force top 15.

Environment details (please complete the following information):

  • Ubuntu 24.04 on x86-64, NVIDIA RTX PRO 6000 Blackwell Server Edition, and driver 595.112.07.
  • Standalone cuVS C library built from 7a3f538c with CUDA 13.4.3. CUDA 13.4 runtime libraries from Conda.
  • cuvs-java 27.02.0, Lucene 10.5.2, OpenJDK 22.0.1-internal, and Maven 3.10.1.

Activity

  1. mc8max commented on Nov 17, 2026

    @mc8max
    ContributorAuthor

    Hi @imotov, the Lucence test fails in current CI into main branch. Have you seen this issue before?

  2. imotov commented on Nov 17, 2026

    @imotov
    Contributor

    I was able to reproduce it. I ran a few experiments and I am pretty sure it was introduced by #2031. One way to fix it would be by recalibrating the check, but the test might be indicating recall drop that this test was actually trying to verify, so I am not sure that's the right approach here. @achirkin, any thoughts on this?

  3. mc8max commented on Nov 19, 2026

    @mc8max
    ContributorAuthor

    Hi @imotov, @achirkin, I double checked when setting variable_graph_degree_fraction=1.0:

    • Ran the test with 25 repetitions, all of them passed the tests
    • 24 / 25 returned top5 which are within top15 of brute-force.
    • Only 1 query returned a neighbor which is outside of top15.
    • The recall rate is 99.92% for all 25 repeats.

    Then the fraction is 0.35, this recall is around 65-70% on passing repetitions, and 0% on some failed runs.

    The original #2031 mentioned default faction is 1.00 as default value, which is no-longer the case here.

    So I guess, in short-term, we either do:

    • Change the fraction to another value which is higher than 0.35
    • Or recalibrate the test

    and in long-term:

    • Improve the quality of graph construction (or extend the search effort) for lower fraction values.

    Currently, I think any new PRs to main branch fails the same test.

  4. achirkin commented on Nov 19, 2026

    @achirkin
    Contributor

    The variable degree logic removes a lot of nodes from the graph. In the build heuristics, we set it to an aggressive value 0.35 and compensate it by increasing the maximum number of nodes in the final graph. So what we see here looks like a flaky test: pre-variable-degree we may have set a bit too optimistic parameters; once we changed the logic, the graph quality decreased naturally, but the tests remained to keep the high bar.
    I think it makes sense to reduce the quality threshold or, perhaps, set this threshold dynamically by running CPU hnsw and comparing its results against brute force (i.e. CAGRA-built graph should be no worse than 95% of the quality of HNSW-built graph)?

  5. achirkin commented on Nov 19, 2026

    @achirkin
    Contributor

    Also worth mentioning #3046 and #3067 may improve the situation here

  6. mc8max commented on Nov 19, 2026

    @mc8max
    ContributorAuthor

    In perspective of test, let's keep the current quality bar for 1.0 or some high fraction numbers, which help validate future changes.
    For more aggressive lower value, we should recalibrate the number and add respective thresholds into the test case list.

  7. mc8max commented on Nov 20, 2026

    @mc8max
    ContributorAuthor

    I ran the test with different fraction values and here is the result:

    Setup
    Commit: 9606988
    Software: CUDA 12.9, Lucene 10.5.2, and Java 22
    Hardware: RTX PRO 6000 Blackwell Server Edition on Linux x86-64
    Test: sweep from 0.35 to 1.00 with 50 fresh graph builds per fraction and a graph capacity of 64 neighbors per node. All 450 runs used the same 2,000 32-dimensional vectors and ten top-5 Euclidean queries, generated with seed AE135E2A8E29E166:B76BE3D67B11916A.

    Metrics:

    • Exact recall@5 measures how many of the 50 returned neighbors were in their query’s brute-force top five.
    • Top-15 misses count returned neighbors outside their query’s brute-force top 15. The sweep’s assertion passed with at most four misses across all 50 results.
    • Mean outgoing degree measures the actual directed edges per node in the reopened graph.

    Result:
    Recall increases as the fraction increases
    image

    Number of misses decreases as the fraction increases
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions