[REVIEW] New Dataset API Clarifying Ownership - #1846
Conversation
|
/ok to test 5447a4c |
|
/ok to test 17ab09d |
|
NB: I updated the label to |
@achirkin The problem w/ using mdspan/mdarray for this is that it's not carrying along the proper information to either the algorithms nor the user (which is why we created this specialized class for this in the first place!). Two immediate reasons why this API is necessary:
This new API solves both of these problems while leaving the control over the memory ownership entirely in the user's hands. We've discussed this for a long time. We've known this is needed for a long time. it's time to prioritize this and get it done. I agree that an anstract class might make more sense, but ultimately we should not be moving any owneship over to the algorithm (the user should maintain ownership over the class and underlying memory the entire time). |
|
The doc that outlines some of the API design choices can be found in slack. Let me know if there are any parts of the design that can be altered to better suit our users' needs. The following files are test case files I've added and can be ignored for now. They will be removed before the final merge with upstream repo:
|
|
/ok to test 70b6b58 |
achirkin
left a comment
There was a problem hiding this comment.
Sorry for being so late for the second round of reviews! I have a few suggestions for the dataset type hierarchy.
53f986c to
f221341
Compare
…th only 26.08 ancestry.
Add dispatch on Layout and MemType params within one single centralized build function rather than adding build function overloads with different names at C API layer.
Add lifetime-tracked dataset views and keep deserialized storage coupled to its index handle. This aligns Rust with the new C dataset API and prevents dangling dataset references.
Split the `cagra::index_params::from_hnsw_params` into a core `cagra::index_params::from_dataset` and a thin wrapper ``cagra::index_params::from_hnsw_params`. This solves two problems: 1. Avoid using the HNSW parameters that do not make sense for CAGRA 2. Allow HNSW parameter heuristics change without affecting CAGRA in future The new parameter defaults are selected to yield exactly the same configurations at old call sites of `from_hnsw_params` Authors: - Artem M. Chirkin (https://github.com/achirkin) Approvers: - Corey J. Nolet (https://github.com/cjnolet) - Tamas Bela Feher (https://github.com/tfeher) URL: NVIDIA#2345
…unction that took mdspan. Restore code that calls make_device_padded_dataset() factory within build_ace() and call build_from_device_matrix() instead. This fixes build issue.
This reverts commit 21481e0.
|
/ok to test 2b753ac |
…issing update_dataset() calls on host build
|
/ok to test b4f7d3e |
… to rename. Now updated to use new factory names
|
/ok to test 2ffe67b |
…I. Host vs device is no longer specified in the factory itself. Rather, host vs device is dispatched at the C API layer. If input data is on host, factory returns a host dataset. If input data is on device, factory returns a device dataset. This allowed us to consolidate several dispatch branches in the language wrappers.
|
/ok to test 80905ea |
My change requests are outdated or postponed to follow-up PRs.
|
/ok to test a6dd4eb |
Overview
Addressing #1574 and #1571.
Replaced strided_dataset with padded_dataset class. Added support all the way up to CAGRA code.
Old class structure (Classes + Inheritance):
New Class Structure (ContainerType Tags + Composition):
Inheritance is removed entirely and all dataset types are on the same level of the inheritance tree.
3 Levels:
Ownership
The index and cagra::build / cagra::index do not own raw vector storage, they only take views.
The old code had a type-erased std::unique_ptr<dataset_view<...>>, i.e. non-owning view handles. The new code uses templates on the index type which determines the type of dataset_view the index holds.
ACE v.s. non-ACE paths on Host
ACE path copies datasets that can't entirely fit in CPU memory in chunks onto GPU memory by calling make_padded_dataset. This is 1x memory on CPU and 1x memory on GPU.
Return types:
Used mainly to maintain lifetime of dataset.
cuvs_cagra_c_api_lifetime_holder
It is a single C++ struct in cagra.cpp that groups the real cagra::index with any extra heap-owned things the C API had to create so the index’s non-owning views stay valid.
Miscellaneous: Extend Serialize Deserialize
Will fill in later
Factories:
Places where make_padded_dataset/view are called internally (not by user):
Host non-ACE path
Tiered CAGRA
Ownership in Downstream Functions:
Improvements:
Breaking Changes for Dataset API:
The following functions are removed since index no longer owns the dataset, index only takes views:
Removed old functions that took mdspan or derivatives of mdspan.
4 cases where index previously owned dataset [all deprecated paths]:
2 edge case build() paths when attach_dataset_on_build == true and a successful dense attach:
Compression Param:
Merge:
These paths have since been removed.
Attach Dataset
Compressed Dataset
Merged Dataset
Deserialize
Helpers
How to attach a compressed dataset onto an uncompressed index?
How to attach a searchable device dataset onto an index built with host build?
a. Utilizes map of host dataset type to device dataset type counterpart
TODOs:
Recent Updates:
Future PRs:
PR#2: Add Support for Compressed Datasets
PR#3: Migrate Rest of Algorithms to use Dataset API