Repository navigation
Revert "[Train] [Data] Add epoch-aware file shuffling to enable deterministic multi-epoch training (#59044)" - #59364
Conversation
…ministic multi-epoch training (#59044)" This reverts commit 5a757b8. Signed-off-by: Alexey Kudinkin <[email protected]>
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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__.
| from ray.data.datasource.file_based_datasource import FileShuffleConfig | |
| from ray.data.datasource.file_based_datasource import FileShuffleConfig, _validate_shuffle_arg |
| 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) |
There was a problem hiding this comment.
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.
| 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))) |
There was a problem hiding this comment.
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)
| 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) |
There was a problem hiding this comment.
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.
Description
Reverting to unblock release.
Related issues
Additional information