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

[data] add dataloader for lance datasource #49459

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Jay-ju
Copy link
Contributor

@Jay-ju Jay-ju commented Dec 27, 2024

Why are these changes needed?

The storage format of lance will be used in multimodal preprocessing and training. When used for training, it needs to be loaded by Dataloader. Here are two relatively important characteristics:

  1. lance supports point query and can be randomly shuffled.
  2. After lance is adapted to dataloader, it can load data in a streaming manner to prevent memory overflow and excessive loading time of training data.

Therefore, this provides how lance can form a Dataset for torch Dataloader implementation, enabling the unification of ray train and ray data.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@Jay-ju Jay-ju requested a review from a team as a code owner December 27, 2024 09:06
@jcotant1 jcotant1 added the data Ray Data-related issues label Dec 27, 2024
@Jay-ju Jay-ju force-pushed the add_lance_dataloader branch 7 times, most recently from 3b19750 to cb50e72 Compare January 2, 2025 09:34
Signed-off-by: jukejian <jukejian@bytedance.com>
@Jay-ju Jay-ju force-pushed the add_lance_dataloader branch from f7ed8d1 to 05b0e09 Compare January 2, 2025 11:15
else:
return [item[0] for item in batch]

dataloader = DataLoader(
Copy link
Contributor

Choose a reason for hiding this comment

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

ooc can you show example of how this work with ray.train.torch. TorchTrainer?. Currently it takes Ray Dataset as input and not Datasource.

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 is indeed using Dataaset.

def to_torch_dataset(
self,
) -> Dataset:
return self.LanceDataset(ds=self)
Copy link
Contributor

Choose a reason for hiding this comment

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

In Ray Data, a Datasource is to used to create a Ray Dataset, ray.data.read_datasource(...).
Users are not supposed to directly use the Datasource class for training ingestion.
If you want to do this, I think you can directly create a torch Dataset based on LanceDB without using Ray Data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From a theoretical perspective, directly creating a torch Dataset is also possible. it is inherited from Torch Dataset. The reason for placing it here is mainly that it can be directly converted into a dataset through the datasource, facilitating the implementation of the ray train + ray data mode.
WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry I still don't think this makes sense.
because "Users are not supposed to directly use the Datasource class for training ingestion."

Copy link

stale bot commented Feb 25, 2025

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

  • If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@stale stale bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data Ray Data-related issues stale The issue is stale. It will be closed within 7 days unless there are further conversation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants