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

[ENH] Add new value type for spann posting lists #3022

Merged
merged 4 commits into from
Nov 13, 2024
Merged

Conversation

sanketkedia
Copy link
Contributor

@sanketkedia sanketkedia commented Oct 29, 2024

Description of changes

Summarize the changes made by this PR.

  • Implements the ArrowWriteableValue and ArrowReadableValue traits
  • Implements the delta and various sizing functions

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Documentation Changes

None

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link

Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas

@sanketkedia sanketkedia changed the title Add new value type for spann posting lists [ENH] Add new value type for spann posting lists Oct 29, 2024
@sanketkedia sanketkedia requested a review from HammadB October 29, 2024 01:30
@sanketkedia sanketkedia marked this pull request as ready for review October 29, 2024 01:30
@sanketkedia sanketkedia mentioned this pull request Oct 30, 2024
1 task
Copy link
Contributor

@rescrv rescrv left a comment

Choose a reason for hiding this comment

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

LGTM

pub struct SpannPostingList<'referred_data> {
pub doc_offset_ids: &'referred_data [u32],
pub doc_versions: &'referred_data [u32],
// Flattened out embeddings for all documents.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Assuming that we assume dimension is bookkeeped elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well the dimension is assumed to be doc_embeddings.len() / doc_offset_ids.len() lol. Curious, do you think of that as brittle and error prone?

rust/blockstore/src/key.rs Outdated Show resolved Hide resolved
@@ -250,7 +250,7 @@ impl<V: ArrowWriteableValue<SizeTracker = SingleColumnSizeTracker>> SingleColumn
)
.into_inner();

let mut value_builder = V::get_arrow_builder(inner.size_tracker);
let mut value_builder = V::get_arrow_builder(inner.size_tracker.clone());
Copy link
Collaborator

Choose a reason for hiding this comment

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

This clone could be hairy! What if code makes assumptions about it. Does this really need to take ownership?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah can we change this to not take ownership - I know thats out of scope of your PR but this is bug-prone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this interface is very restrictive. It assumes that only the size tracker is needed to construct the builder. You could require more than just the size information for that. For instance, I needed the embedding dimension (which is conveniently a part of size tracker as an optional field since some value types don't possess that).

Even below, For V::finish(), I needed the embedding dimension so I had to add the size_tracker param again.

In general, It's hard to predict ahead of time what future value types added will need to construct their corresponding arrow arrays. Having a broad API V::into_arrow(delta) that returns the arrow array and the field from the delta is sufficient IMO.

Curious on thoughts @HammadB @codetheweb

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would largely be fixed with the generic tuple API we've talked about before? e.g. then we wouldn't need specialization like this (I suppose if you wanted to have Vec<f32> -> FixedSizeList as an optimization you would still need a separate wrapper trait)

Copy link
Collaborator

@HammadB HammadB left a comment

Choose a reason for hiding this comment

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

Have some comments that would be good to address before merging.

Copy link
Contributor Author

sanketkedia commented Nov 13, 2024

Merge activity

  • Nov 13, 5:09 PM EST: A user started a stack merge that includes this pull request via Graphite.
  • Nov 13, 5:10 PM EST: A user merged this pull request with Graphite.

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.

4 participants