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

[Train] Add support for handling multiple batch data types for prepare_data_loader #26386

Merged
merged 5 commits into from
Jul 12, 2022

Conversation

VishDev12
Copy link
Contributor

Why are these changes needed?

When working with Ray Train, using the ray.train.torch.prepare_data_loader method with a dataset that returns a dictionary instead of a tuple from its __getitem__ method causes issues.

Related issue number

Closes #26385

Checks

  • 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 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 :(

@VishDev12 VishDev12 changed the title Add support for handling multiple batch data types for prepare_data_loader in Ray Train [Train] Add support for handling multiple batch data types for prepare_data_loader Jul 8, 2022
Copy link
Contributor

@amogkam amogkam left a comment

Choose a reason for hiding this comment

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

Thanks @VishDev12! Do you think you can also add a test for this? There's already a test_torch_prepare_dataloader test in test_gpu.py. We can just use that same test but try with DataLoaders that also output dictionaries instead of just tuples.

python/ray/train/torch/train_loop_utils.py Outdated Show resolved Hide resolved
python/ray/train/torch/train_loop_utils.py Outdated Show resolved Hide resolved
@VishDev12
Copy link
Contributor Author

Hey @amogkam, I've added a dict case in the test_torch_prepare_dataloader test.

Please let me know if something doesn't look quite right.

Copy link
Contributor

@amogkam amogkam left a comment

Choose a reason for hiding this comment

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

Thanks @VishDev12 this lgtm! Just left one minor comment

@@ -24,6 +24,11 @@ def __len__(self):
return len(self.x)


class LinearDatasetDict(LinearDataset):
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is only used in the test and not part of the example, can we move this to test_gpu directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense, I've moved it just under the fixtures defined on test_gpu, just to keep the separation between the test_* functions and the rest. But if you want to have it defined just above test_torch_prepare_dataloader, I could do that too.

@amogkam
Copy link
Contributor

amogkam commented Jul 12, 2022

Awesome, thanks @VishDev12!

@amogkam amogkam merged commit 36229d1 into ray-project:master Jul 12, 2022
amogkam added a commit that referenced this pull request Jul 12, 2022
amogkam added a commit that referenced this pull request Jul 13, 2022
amogkam added a commit that referenced this pull request Jul 13, 2022
…types for prepare_data_loader (#26386)" (#26483)"

This reverts commit e6c0403.
amogkam added a commit that referenced this pull request Jul 26, 2022
…types for prepare_data_loader"" (#26491)

Signed-off-by: Amog Kamsetty <[email protected]>

* Revert "Revert "[Train] Add support for handling multiple batch data types for prepare_data_loader (#26386)" (#26483)"

This reverts commit e6c0403.
Rohan138 pushed a commit to Rohan138/ray that referenced this pull request Jul 28, 2022
…types for prepare_data_loader"" (ray-project#26491)

Signed-off-by: Amog Kamsetty <[email protected]>

* Revert "Revert "[Train] Add support for handling multiple batch data types for prepare_data_loader (ray-project#26386)" (ray-project#26483)"

This reverts commit e6c0403.

Signed-off-by: Rohan138 <[email protected]>
Stefan-1313 pushed a commit to Stefan-1313/ray_mod that referenced this pull request Aug 18, 2022
…e_data_loader (ray-project#26386)

When working with Ray Train, using the ray.train.torch.prepare_data_loader method with a dataset that returns a dictionary instead of a tuple from its __getitem__ method causes issues.

Co-authored-by: matthewdeng <[email protected]>
Signed-off-by: Stefan van der Kleij <[email protected]>
Stefan-1313 pushed a commit to Stefan-1313/ray_mod that referenced this pull request Aug 18, 2022
…r prepare_data_loader (ray-project#26386)" (ray-project#26483)

This reverts commit 36229d1.

Signed-off-by: Stefan van der Kleij <[email protected]>
Stefan-1313 pushed a commit to Stefan-1313/ray_mod that referenced this pull request Aug 18, 2022
…types for prepare_data_loader"" (ray-project#26491)

Signed-off-by: Amog Kamsetty <[email protected]>

* Revert "Revert "[Train] Add support for handling multiple batch data types for prepare_data_loader (ray-project#26386)" (ray-project#26483)"

This reverts commit e6c0403.

Signed-off-by: Stefan van der Kleij <[email protected]>
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.

[Train] Add support for handling multiple batch data types for prepare_data_loader
3 participants