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] Remove prefetch_blocks parameter of batch-based iteration APIs #43347

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion python/ray/air/util/check_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def train_loop_per_worker():
batch_start = time.perf_counter()
for batch in data_shard.iter_batches(
prefetch_batches=prefetch_batches,
prefetch_blocks=prefetch_blocks,
bveeramani marked this conversation as resolved.
Show resolved Hide resolved
batch_size=batch_size,
):
batch_delay = time.perf_counter() - batch_start
Expand Down
15 changes: 0 additions & 15 deletions python/ray/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3656,8 +3656,6 @@ def iter_batches(
local_shuffle_buffer_size: Optional[int] = None,
local_shuffle_seed: Optional[int] = None,
_collate_fn: Optional[Callable[[DataBatch], CollatedData]] = None,
# Deprecated.
prefetch_blocks: int = 0,
) -> Iterable[DataBatch]:
"""Return an iterable over batches of data.

Expand Down Expand Up @@ -3709,7 +3707,6 @@ def iter_batches(
batch_format = _apply_batch_format(batch_format)
return self.iterator().iter_batches(
prefetch_batches=prefetch_batches,
prefetch_blocks=prefetch_blocks,
batch_size=batch_size,
batch_format=batch_format,
drop_last=drop_last,
Expand All @@ -3730,8 +3727,6 @@ def iter_torch_batches(
drop_last: bool = False,
local_shuffle_buffer_size: Optional[int] = None,
local_shuffle_seed: Optional[int] = None,
# Deprecated
prefetch_blocks: int = 0,
) -> Iterable[TorchBatchType]:
"""Return an iterable over batches of data represented as Torch tensors.

Expand Down Expand Up @@ -3817,7 +3812,6 @@ def iter_torch_batches(
""" # noqa: E501
return self.iterator().iter_torch_batches(
prefetch_batches=prefetch_batches,
prefetch_blocks=prefetch_blocks,
batch_size=batch_size,
dtypes=dtypes,
device=device,
Expand All @@ -3837,8 +3831,6 @@ def iter_tf_batches(
drop_last: bool = False,
local_shuffle_buffer_size: Optional[int] = None,
local_shuffle_seed: Optional[int] = None,
# Deprecated
prefetch_blocks: int = 0,
) -> Iterable[TensorFlowTensorBatchType]:
"""Return an iterable over batches of data represented as TensorFlow tensors.

Expand Down Expand Up @@ -3904,7 +3896,6 @@ def iter_tf_batches(
""" # noqa: E501
return self.iterator().iter_tf_batches(
prefetch_batches=prefetch_batches,
prefetch_blocks=prefetch_blocks,
batch_size=batch_size,
dtypes=dtypes,
drop_last=drop_last,
Expand All @@ -3931,8 +3922,6 @@ def to_torch(
local_shuffle_seed: Optional[int] = None,
unsqueeze_label_tensor: bool = True,
unsqueeze_feature_tensors: bool = True,
# Deprecated
prefetch_blocks: int = 0,
) -> "torch.utils.data.IterableDataset":
"""Return a
`Torch IterableDataset <https://pytorch.org/docs/stable/data.html#torch.utils.data.IterableDataset>`_
Expand Down Expand Up @@ -4032,7 +4021,6 @@ def to_torch(
label_column_dtype=label_column_dtype,
feature_column_dtypes=feature_column_dtypes,
batch_size=batch_size,
prefetch_blocks=prefetch_blocks,
prefetch_batches=prefetch_batches,
drop_last=drop_last,
local_shuffle_buffer_size=local_shuffle_buffer_size,
Expand All @@ -4054,8 +4042,6 @@ def to_tf(
local_shuffle_seed: Optional[int] = None,
feature_type_spec: Union["tf.TypeSpec", Dict[str, "tf.TypeSpec"]] = None,
label_type_spec: Union["tf.TypeSpec", Dict[str, "tf.TypeSpec"]] = None,
# Deprecated
prefetch_blocks: int = 0,
) -> "tf.data.Dataset":
"""Return a `TensorFlow Dataset <https://www.tensorflow.org/api_docs/python/tf/data/Dataset/>`_
over this :class:`~ray.data.Dataset`.
Expand Down Expand Up @@ -4160,7 +4146,6 @@ def to_tf(
feature_columns=feature_columns,
label_columns=label_columns,
prefetch_batches=prefetch_batches,
prefetch_blocks=prefetch_blocks,
drop_last=drop_last,
batch_size=batch_size,
local_shuffle_buffer_size=local_shuffle_buffer_size,
Expand Down
22 changes: 0 additions & 22 deletions python/ray/data/iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ def iter_batches(
local_shuffle_seed: Optional[int] = None,
_collate_fn: Optional[Callable[[DataBatch], "CollatedData"]] = None,
_finalize_fn: Optional[Callable[[Any], Any]] = None,
# Deprecated.
prefetch_blocks: int = 0,
) -> Iterable[DataBatch]:
"""Return a batched iterable over the dataset.

Expand Down Expand Up @@ -152,14 +150,6 @@ def iter_batches(
Returns:
An iterable over record batches.
"""

if prefetch_blocks > 0:
raise DeprecationWarning(
"`prefetch_blocks` arg is deprecated in Ray 2.4. Use "
"the `prefetch_batches` arg instead to specify the amount of "
"prefetching in terms of batches instead of blocks."
)

batch_format = _apply_batch_format(batch_format)

def _create_iterator() -> Iterator[DataBatch]:
Expand Down Expand Up @@ -261,8 +251,6 @@ def iter_torch_batches(
drop_last: bool = False,
local_shuffle_buffer_size: Optional[int] = None,
local_shuffle_seed: Optional[int] = None,
# Deprecated.
prefetch_blocks: int = 0,
) -> Iterable["TorchBatchType"]:
"""Return a batched iterable of Torch Tensors over the dataset.

Expand Down Expand Up @@ -389,7 +377,6 @@ def finalize_fn(batch: Union["torch.Tensor", Dict[str, "torch.Tensor"]]):

return self.iter_batches(
prefetch_batches=prefetch_batches,
prefetch_blocks=prefetch_blocks,
batch_size=batch_size,
drop_last=drop_last,
local_shuffle_buffer_size=local_shuffle_buffer_size,
Expand All @@ -407,8 +394,6 @@ def iter_tf_batches(
drop_last: bool = False,
local_shuffle_buffer_size: Optional[int] = None,
local_shuffle_seed: Optional[int] = None,
# Deprecated.
prefetch_blocks: int = 0,
) -> Iterable["TensorFlowTensorBatchType"]:
"""Return a batched iterable of TensorFlow Tensors over the dataset.

Expand Down Expand Up @@ -464,7 +449,6 @@ def iter_tf_batches(

batch_iterable = self.iter_batches(
prefetch_batches=prefetch_batches,
prefetch_blocks=prefetch_blocks,
batch_size=batch_size,
drop_last=drop_last,
local_shuffle_buffer_size=local_shuffle_buffer_size,
Expand Down Expand Up @@ -497,8 +481,6 @@ def to_torch(
local_shuffle_seed: Optional[int] = None,
unsqueeze_label_tensor: bool = True,
unsqueeze_feature_tensors: bool = True,
# Deprecated.
prefetch_blocks: int = 0,
) -> "torch.utils.data.IterableDataset":
"""Return a Torch IterableDataset over this dataset.

Expand Down Expand Up @@ -632,7 +614,6 @@ def make_generator():
for batch in self.iter_batches(
batch_size=batch_size,
batch_format="pandas",
prefetch_blocks=prefetch_blocks,
prefetch_batches=prefetch_batches,
drop_last=drop_last,
local_shuffle_buffer_size=local_shuffle_buffer_size,
Expand Down Expand Up @@ -687,8 +668,6 @@ def to_tf(
local_shuffle_seed: Optional[int] = None,
feature_type_spec: Union["tf.TypeSpec", Dict[str, "tf.TypeSpec"]] = None,
label_type_spec: Union["tf.TypeSpec", Dict[str, "tf.TypeSpec"]] = None,
# Deprecated.
prefetch_blocks: int = 0,
) -> "tf.data.Dataset":
"""Return a TF Dataset over this dataset.

Expand Down Expand Up @@ -828,7 +807,6 @@ def convert_batch_to_tensors(
def generator():
for batch in self.iter_batches(
prefetch_batches=prefetch_batches,
prefetch_blocks=prefetch_blocks,
batch_size=batch_size,
drop_last=drop_last,
local_shuffle_buffer_size=local_shuffle_buffer_size,
Expand Down