Skip to content

RAG ANN test: build the recall check index on one thread - #16308

Merged
danielhanchen merged 2 commits into
mainfrom
dh/rag-ann-recall-single-thread-build
Oct 31, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
dh/rag-ann-recall-single-thread-build

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

studio/backend/tests/test_rag_vec_ann.py::test_search_recalls_the_exact_neighbours failed in (Python 3.13, g-r) on #16298, which only touches the frontend:

tests/test_rag_vec_ann.py:57: in test_search_recalls_the_exact_neighbours
E   assert (590 / (20 * 30)) >= 0.99

Why

The data and the queries are seeded, but the index was built with threads = 2. A parallel HNSW build inserts nodes in whatever order the two threads interleave, and the graph, and so the recall, depends on that order. That is scheduling, not anything the test means to measure. Measured on this file's data and queries, torch 2.10 CPU, usearch 2.26.6:

build recall over 60 builds
threads = 2 0.9950 to 1.0000, four distinct values
threads = 1 1.0000 every time

The hosted 4-vCPU runner interleaves differently and produced 0.983.

Change

_built takes a threads argument, defaulting to the 2 it used before. Only the recall test passes threads = 1, so the other five tests that use _built still exercise the parallel add path.

Verification

  • The file passes 7 tests, three runs in a row.
  • Sabotage: with new_index switched from metric = "cos" to "l2sq", the recall test fails with 28 / 600, so the single-thread build still catches a real retrieval regression.

test_search_recalls_the_exact_neighbours built its HNSW index with threads = 2, so the graph, and with it
the recall it measured, depended on how the two threads interleaved: 0.983 against the 0.99 bar on a CI
runner, 0.995 to 1.0 across 60 local builds. A one-thread build gives 1.0 every time. The other tests
keep the two-thread build, so the parallel add path stays covered.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T15:38:06.803541Z c8c399e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: c8c399efce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Successfully merging this pull request may close these issues.

1 participant