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] Preserve block format on map_batches over empty blocks #38161

Merged
merged 7 commits into from
Aug 8, 2023

Conversation

amogkam
Copy link
Contributor

@amogkam amogkam commented Aug 7, 2023

Preserve the original block format when calling map_batches over empty blocks. Previously, map_batches would default to always outputting an Arrow block regardless of the format of the input empty blocks. Changing the underlying block format for empty blocks can lead to the dataset having multiple block formats, which does not work for sort or aggregation operations.

Why are these changes needed?

Related issue number

Closes #37963

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

Signed-off-by: amogkam <amogkamsetty@yahoo.com>
@@ -105,6 +106,12 @@ def process_next_batch(batch: DataBatch) -> Iterator[Block]:
else:
raise e from None

try:
first_block = next(blocks)
Copy link
Contributor

Choose a reason for hiding this comment

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

This would hold the an extra block in-memory during execution, right? To avoid the increased memory overhead, can we create the corresponding output block builder here?

Copy link
Contributor Author

@amogkam amogkam Aug 7, 2023

Choose a reason for hiding this comment

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

No I don't think it will hold any extra memory? We're not copying the block anywhere. There's always just one reference to the block.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, but in this case, the first block is always living in object store memory, until the map_batches is finished, right? because we hold the reference here.

python/ray/data/_internal/delegating_block_builder.py Outdated Show resolved Hide resolved
python/ray/data/_internal/output_buffer.py Outdated Show resolved Hide resolved
Signed-off-by: amogkam <amogkamsetty@yahoo.com>
Signed-off-by: amogkam <amogkamsetty@yahoo.com>
Signed-off-by: amogkam <amogkamsetty@yahoo.com>
Signed-off-by: amogkam <amogkamsetty@yahoo.com>
Signed-off-by: amogkam <amogkamsetty@yahoo.com>
Copy link
Contributor

@c21 c21 left a comment

Choose a reason for hiding this comment

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

LG

@amogkam amogkam merged commit 18bf299 into ray-project:master Aug 8, 2023
58 of 63 checks passed
@amogkam amogkam deleted the map-batches-empty-block branch August 8, 2023 03:14
NripeshN pushed a commit to NripeshN/ray that referenced this pull request Aug 15, 2023
…project#38161)

Preserve the original block format when calling map_batches over empty blocks. Previously, map_batches would default to always outputting an Arrow block regardless of the format of the input empty blocks. Changing the underlying block format for empty blocks can lead to the dataset having multiple block formats, which does not work for sort or aggregation operations.

---------

Signed-off-by: amogkam <amogkamsetty@yahoo.com>
Signed-off-by: NripeshN <nn2012@hw.ac.uk>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
…project#38161)

Preserve the original block format when calling map_batches over empty blocks. Previously, map_batches would default to always outputting an Arrow block regardless of the format of the input empty blocks. Changing the underlying block format for empty blocks can lead to the dataset having multiple block formats, which does not work for sort or aggregation operations.

---------

Signed-off-by: amogkam <amogkamsetty@yahoo.com>
Signed-off-by: harborn <gangsheng.wu@intel.com>
harborn pushed a commit to harborn/ray that referenced this pull request Aug 17, 2023
…project#38161)

Preserve the original block format when calling map_batches over empty blocks. Previously, map_batches would default to always outputting an Arrow block regardless of the format of the input empty blocks. Changing the underlying block format for empty blocks can lead to the dataset having multiple block formats, which does not work for sort or aggregation operations.


---------

Signed-off-by: amogkam <amogkamsetty@yahoo.com>
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
…project#38161)

Preserve the original block format when calling map_batches over empty blocks. Previously, map_batches would default to always outputting an Arrow block regardless of the format of the input empty blocks. Changing the underlying block format for empty blocks can lead to the dataset having multiple block formats, which does not work for sort or aggregation operations.

---------

Signed-off-by: amogkam <amogkamsetty@yahoo.com>
Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
vymao pushed a commit to vymao/ray that referenced this pull request Oct 11, 2023
…project#38161)

Preserve the original block format when calling map_batches over empty blocks. Previously, map_batches would default to always outputting an Arrow block regardless of the format of the input empty blocks. Changing the underlying block format for empty blocks can lead to the dataset having multiple block formats, which does not work for sort or aggregation operations.

---------

Signed-off-by: amogkam <amogkamsetty@yahoo.com>
Signed-off-by: Victor <vctr.y.m@example.com>
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.

[Data] Aggregating on dataset with mixture of Block types causes pyarrow AttributeError
2 participants