Skip to content

Revert "[Train] [Data] Add epoch-aware file shuffling to enable deterministic multi-epoch training (#59044)" - #59364

Merged
richardliaw merged 1 commit into
masterfrom
ak/rev
Dec 11, 2025
Merged

richardliaw merged 1 commit into
masterfrom
ak/rev

Conversation

@alexeykudinkin

Copy link
Copy Markdown
Contributor

Thank you for contributing to Ray! 🚀
Please review the Ray Contribution Guide before opening a pull request.

⚠️ Remove these instructions before submitting your PR.

💡 Tip: Mark as draft if you want early feedback, or ready for review when it's complete.

Description

Reverting to unblock release.

Related issues

Link related issues: "Fixes #1234", "Closes #1234", or "Related to #1234".

Additional information

Optional: Add implementation details, API changes, usage examples, screenshots, etc.

…ministic multi-epoch training (#59044)"

This reverts commit 5a757b8.

Signed-off-by: Alexey Kudinkin <[email protected]>
@alexeykudinkin
alexeykudinkin requested review from a team as code owners December 10, 2025 22:41

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request reverts the recent changes that added epoch-aware file shuffling. The revert seems to be comprehensive, touching datasource implementations, execution logic, and tests to remove all traces of the new feature.

My review focuses on ensuring the revert is clean and doesn't re-introduce any old issues. I've found one minor issue in python/ray/data/_internal/datasource/parquet_datasource.py where argument validation for shuffle was removed as part of the revert. I've suggested adding it back to prevent silent failures on invalid input. Otherwise, the revert looks good.

_shuffle_file_metadata,
_validate_shuffle_arg,
)
from ray.data.datasource.file_based_datasource import FileShuffleConfig

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To ensure the shuffle argument is validated, please also import _validate_shuffle_arg from file_based_datasource. This is needed for a suggested change in __init__.

Suggested change
from ray.data.datasource.file_based_datasource import FileShuffleConfig
from ray.data.datasource.file_based_datasource import FileShuffleConfig, _validate_shuffle_arg

Comment on lines +432 to +438
self._file_metadata_shuffler = None
self._include_paths = include_paths
self._partitioning = partitioning
_validate_shuffle_arg(shuffle)
self._shuffle = shuffle
if shuffle == "files":
self._file_metadata_shuffler = np.random.default_rng()
elif isinstance(shuffle, FileShuffleConfig):
self._file_metadata_shuffler = np.random.default_rng(shuffle.seed)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

It's good practice to validate the shuffle argument to prevent silent failures for invalid values. The original change that is being reverted had this validation, and it would be good to keep it.

Suggested change
self._file_metadata_shuffler = None
self._include_paths = include_paths
self._partitioning = partitioning
_validate_shuffle_arg(shuffle)
self._shuffle = shuffle
if shuffle == "files":
self._file_metadata_shuffler = np.random.default_rng()
elif isinstance(shuffle, FileShuffleConfig):
self._file_metadata_shuffler = np.random.default_rng(shuffle.seed)
_validate_shuffle_arg(shuffle)
self._file_metadata_shuffler = None
self._include_paths = include_paths
self._partitioning = partitioning
if shuffle == "files":
self._file_metadata_shuffler = np.random.default_rng()
elif isinstance(shuffle, FileShuffleConfig):
self._file_metadata_shuffler = np.random.default_rng(shuffle.seed)

files_metadata[i]
for i in self._file_metadata_shuffler.permutation(len(files_metadata))
]
paths, file_sizes = list(map(list, zip(*shuffled_files_metadata)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Empty file list causes crash when shuffling enabled

When the file list is empty and file shuffling is enabled, the code crashes with a ValueError: not enough values to unpack. The removed _shuffle_file_metadata function had a guard if len(paths) == 0: return paths, file_metadata that prevented this issue. The inline shuffle code now calls zip(*shuffled_files_metadata) on an empty list, which returns an empty iterator that can't be unpacked into two variables. This affects both FileBasedDatasource and ParquetDatasource.

Additional Locations (1)

Fix in Cursor Fix in Web

if shuffle == "files":
self._file_metadata_shuffler = np.random.default_rng()
elif isinstance(shuffle, FileShuffleConfig):
self._file_metadata_shuffler = np.random.default_rng(shuffle.seed)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: ParquetDatasource missing shuffle argument validation

The revert removed the call to _validate_shuffle_arg(shuffle) in ParquetDatasource but didn't restore it. Unlike FileBasedDatasource which validates the shuffle argument, ParquetDatasource now silently ignores invalid shuffle values (e.g., shuffle=True or shuffle="random"). Invalid values will simply not trigger shuffling without any error, causing confusing silent failures for users who expect their data to be shuffled.

Fix in Cursor Fix in Web

@ray-gardener ray-gardener Bot added train Ray Train Related Issue data Ray Data-related issues labels Dec 11, 2025
@xinyuangui2 xinyuangui2 added the go add ONLY when ready to merge, run all tests label Dec 11, 2025
@richardliaw
richardliaw merged commit cf58ec4 into master Dec 11, 2025
@richardliaw
richardliaw deleted the ak/rev branch December 11, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests train Ray Train Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ray fails to serialize self-reference objects

3 participants