-
Notifications
You must be signed in to change notification settings - Fork 22
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
CNDB-12922: Implement rerank_k in SAI ANN queries #1562
base: main
Are you sure you want to change the base?
Conversation
Before this, we had minor inconcistencies where the in memory and the on disk indexes diverged. This might have been intentional, but I'm not certain, so changing this here to force the discussion in the PR review. Now, everything is consistently rerankK when estimating the cost to search the graph in order to determine if brute force is cheaper.
Checklist before you submit for review
|
// Default to no warning and failure at 4 times the maxTopK value | ||
int maxTopK = CassandraRelevantProperties.SAI_VECTOR_SEARCH_MAX_TOP_K.getInt(); | ||
enforceDefault(sai_ann_rerank_k_warn_threshold, v -> sai_ann_rerank_k_warn_threshold = v, -1, -1); | ||
enforceDefault(sai_ann_rerank_k_failure_threshold, v -> sai_ann_rerank_k_failure_threshold = v, 4 * maxTopK, 4 * maxTopK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another approach could be to cap the ratio of LIMIT
to rerank_k
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great! I have dropped some comments about the messaging version bump and testing.
test/unit/org/apache/cassandra/guardrails/GuardrailSAIAnnRerankKTest.java
Outdated
Show resolved
Hide resolved
@michaeljmarshall for the CNDB PR, besides the messaging version bump, we will need to add the new guardrail to this test (I learned it the hard way) |
This can be reverted later when we support non-positive numbers, which will mean that we can do a rerankless search.
public static ANNOptions fromMap(String keyspace, Map<String, String> map) | ||
{ | ||
assert keyspace != null; | ||
// ensure that all nodes in the cluster are in a version that supports ANN options, including this one | ||
Set<InetAddressAndPort> badNodes = MessagingService.instance().endpointsWithVersionBelow(MessagingService.VERSION_DS_11); | ||
Set<InetAddressAndPort> badNodes = MessagingService.instance().endpointsWithVersionBelow(keyspace, MessagingService.VERSION_DS_11); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adelapena - what do you think about moving this validation to the validate
method? It seems odd to pass the keyspace
in to this method since it is only needed for validation and not for building the object from the map. I left it as is for now since it is a minor detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, +1
@adelapena - will you please re-review this PR? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, with a few trivial suggestions. I haven't looked at the CNDB PR yet.
test/unit/org/apache/cassandra/guardrails/GuardrailSAIAnnRerankKTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/guardrails/GuardrailSAIAnnRerankKTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/guardrails/GuardrailSAIAnnRerankKTest.java
Outdated
Show resolved
Hide resolved
|
❌ Build ds-cassandra-pr-gate/PR-1562 rejected by Butler3 new test failure(s) in 7 builds Found 3 new test failures
Found 15 known test failures |
What is the issue
Fixes https://github.com/riptano/cndb/issues/12922
What does this PR fix and why was it fixed
This PR follows up on #1525 by integrating the CQL configured
rerank_k
in to SAI so that the ANN query can take the user input and let it influence query execution.Key changes:
MessagingService
toVERSION_DS_11
MessagingService.instance().endpointsWithVersionBelow
by using thekeyspace
variant, which is necessary for CNDB.rerank_k
is used as the graph'srerankK
parameter. The only detail worth mentioning here is that we ignore the segment proportionality computation ifrerank_k
is provided. This diverges from the smart default design, but not too greatly.rerank_k
to prevent it from exceeding 4 times thecassandra.sai.vector_search.max_top_k
. This is debatable and easily changed, so please let me know if we want something different.rerankK
value instead of thelimit
. I am pretty sure this is correct, but please review closely.Instead of validating
rerank_k
's value within the query, I added a test that ensures that as we increase the rerank k, we increase the recall.CNDB pr: https://github.com/riptano/cndb/pull/13095