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

Introduces NativeEngineKNNQuery which executes ANN on rewrite #1877

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

shatejas
Copy link
Contributor

@shatejas shatejas commented Jul 25, 2024

Description

All integration tests are passing. Cannot support radial currently since k is not significant, there are ways to do it but since its not planned for 2.17 this should work

Related Issues

Resolves #1845

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@navneet1v
Copy link
Collaborator

navneet1v commented Jul 25, 2024

@shatejas Lets ensure all CI are working. I know this code is only for feedback. but successful CIs gives confidence.

Copy link
Collaborator

@navneet1v navneet1v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall code looks good to me. I would like to see other usecase of KNNQuery getting added here like currently filters are not present here. Similarly Radial search, other ITs and BWC tests.

@shatejas shatejas force-pushed the poc/rewrite branch 2 times, most recently from d923ba0 to 8d9b082 Compare August 1, 2024 02:17
@shatejas shatejas changed the title [DO NOT MERGE][NEED INITIAL FEEDBACK]Introduces NativeEngineKNNQuery which executes ANN on rewrite Introduces NativeEngineKNNQuery which executes ANN on rewrite Aug 1, 2024
Copy link
Member

@jmazanec15 jmazanec15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Few minor comments

@shatejas shatejas force-pushed the poc/rewrite branch 5 times, most recently from 5ec1eb6 to ff64081 Compare August 1, 2024 22:52
jmazanec15
jmazanec15 previously approved these changes Aug 1, 2024
Copy link
Member

@jmazanec15 jmazanec15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@Vikasht34 Vikasht34 left a 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 .

CHANGELOG.md Outdated Show resolved Hide resolved
* @param context LeafReaderContext
* @return A Map of docId to scores for top k results
*/
public Map<Integer, Float> searchLeaf(LeafReaderContext context) throws IOException {

final BitSet filterBitSet = getFilteredDocsBitSet(context);
int cardinality = filterBitSet.cardinality();
// We don't need to go to JNI layer if no documents are found which satisfy the filters
// We should give this condition a deeper look that where it should be placed. For now I feel this is a good
// place,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment does not describe the new change added. Can you describe why are we returning an empty Map?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still applies - Its an optimization where we don't search (don't go to JNI layer). filters being empty indicates no results were found. Doing additional search will always results in empty response.

We are returning empty Map to indicate that there were no matches. This is for both NativeEngineKnnVectorQuery as well as scorer in this class. The emtyScorer part is simply moved to line 113

@navneet1v
Copy link
Collaborator

Minor comments, overall code looks good to me

@navneet1v
Copy link
Collaborator

@shatejas please resolve conflicts.

Copy link
Member

@jmazanec15 jmazanec15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix changelog? Other than that looks good

CHANGELOG.md Outdated
@@ -28,5 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* Clean up parsing for query [#1824](https://github.com/opensearch-project/k-NN/pull/1824)
* Refactor engine package structure [#1913](https://github.com/opensearch-project/k-NN/pull/1913)
* Refactor method structure and definitions [#1920](https://github.com/opensearch-project/k-NN/pull/1920)
* Generalize lib interface to return context objects [#1925](https://github.com/opensearch-project/k-NN/pull/1925)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate changelog entry

Signed-off-by: Tejas Shah <shatejas@amazon.com>
Copy link
Member

@jmazanec15 jmazanec15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

@navneet1v navneet1v merged commit df7627c into opensearch-project:main Aug 6, 2024
27 of 29 checks passed
@navneet1v navneet1v added backport 2.x v2.17.0 Enhancements Increases software capabilities beyond original client specifications Refactoring Improve the design, structure, and implementation while preserving its functionality labels Aug 6, 2024
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1877-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 df7627c6e580843beb2361f5c2ec3519efd52280
# Push it to GitHub
git push --set-upstream origin backport/backport-1877-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-1877-to-2.x.

shatejas added a commit to shatejas/k-NN that referenced this pull request Aug 8, 2024
…arch-project#1877)

Signed-off-by: Tejas Shah <shatejas@amazon.com>
(cherry picked from commit df7627c)
shatejas added a commit to shatejas/k-NN that referenced this pull request Aug 8, 2024
…arch-project#1877)

Signed-off-by: Tejas Shah <shatejas@amazon.com>
(cherry picked from commit df7627c)
junqiu-lei pushed a commit that referenced this pull request Aug 9, 2024
…#1943)

Signed-off-by: Tejas Shah <shatejas@amazon.com>
(cherry picked from commit df7627c)
@shatejas shatejas deleted the poc/rewrite branch August 12, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Enhancements Increases software capabilities beyond original client specifications Refactoring Improve the design, structure, and implementation while preserving its functionality v2.17.0
Projects
Status: 2.17.0
Development

Successfully merging this pull request may close these issues.

None yet

5 participants