Repository navigation
[Train] [Data] Add epoch-aware file shuffling to enable deterministic multi-epoch training - #59044
Conversation
The GIL makes checking s`elf._serialize_cache is not None` atomic, so we don't need lock. Signed-off-by: Xinyuan <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
justinvyu
left a comment
There was a problem hiding this comment.
Cool stuff. Wondering if we need to update the get_read_tasks internal interface everywhere.
| EXECUTION_CALLBACKS_CONFIG_KEY, | ||
| [IssueDetectionExecutionCallback(), EpochIdxUpdateCallback()], |
There was a problem hiding this comment.
Users can clear this list manually (and Ray Data emits some messages telling users how to do that if they want to disable the issue detectors), which will then break things. Should we always include this callback regardless of what the user set?
There was a problem hiding this comment.
Oh wait nvm we don't ever tell the user to clear this list -- I was thinking of this:
But it's still possible for users to do this:
ray.data.DataContext.get_current().set_config("execution_callbacks", [])There was a problem hiding this comment.
this is fine. if users intentionally try to break things. there is nothing we can do.
| self, | ||
| parallelism: int, | ||
| per_task_row_limit: Optional[int] = None, | ||
| epoch_idx: int = 0, |
There was a problem hiding this comment.
does datasource not have access to the dataset's context? and then just use _epoch_idx
There was a problem hiding this comment.
DataSource is one parameter to create Dataset.
ray/python/ray/data/read_api.py
Lines 360 to 372 in eb4dfe8
So DataSource doesn't have access to dataset's context
raulchen
left a comment
There was a problem hiding this comment.
Looks good overall. Only a few small comments
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
I think so since the calling function is calling |
| reseed_after_epoch: If True, the random seed is ``seed + epoch_idx``, resulting | ||
| in different shuffling orders across epochs. If False, the random seed is | ||
| constantly ``seed``, resulting in the same shuffling order across epochs. | ||
| Only takes effect when ``seed`` is not None. Defaults to True. |
There was a problem hiding this comment.
it should probably be default to false for backward compatibility.
There was a problem hiding this comment.
I think reseeding is a good default. The current fixed seed behavior is not a common pattern and is probably unexpected for them already.
Also, I think most users still use shuffle="files" which defaults to a random seed per epoch anyways.
| reseed_after_epoch: If True, the random seed is ``seed + epoch_idx``, resulting | ||
| in different shuffling orders across epochs. If False, the random seed is | ||
| constantly ``seed``, resulting in the same shuffling order across epochs. | ||
| Only takes effect when ``seed`` is not None. Defaults to True. |
There was a problem hiding this comment.
I think reseeding is a good default. The current fixed seed behavior is not a common pattern and is probably unexpected for them already.
Also, I think most users still use shuffle="files" which defaults to a random seed per epoch anyways.
Signed-off-by: xgui <[email protected]>
Signed-off-by: xgui <[email protected]>
…ministic multi-epoch training (#59044)" This reverts commit 5a757b8. Signed-off-by: Alexey Kudinkin <[email protected]>
…ministic multi-epoch training (#59044)" (#59364) > Thank you for contributing to Ray! 🚀 > Please review the [Ray Contribution Guide](https://docs.ray.io/en/master/ray-contribute/getting-involved.html) 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. Signed-off-by: Alexey Kudinkin <[email protected]>
…stic multi-epoch training (#59528) This PR renamed #59044 ## Description This PR adds execution-aware shuffling to Ray Data's file-based datasources, enabling different file orders across different executions while maintaining determinism. ### Changes **Core functionality:** - Added `execution_idx` field to `DataContext` to track the current epoch - `FileShuffleConfig` can receive `base_seed` to automatically increment seed after each execution - If `FileShuffleConfig` still uses `seed`, the random seed is still the same for each execution. - Modified `FileBasedDatasource.get_read_tasks()` to accept `execution_idx` parameter and pass it through the shuffle logic **Benefits:** - No breaking API change. - Each epoch produces a different but deterministic shuffle when `base_seed` is provided - Ensures that multiple datasets with the same shuffle config produce identical results within each epoch --------- Signed-off-by: Xinyuan <[email protected]> Signed-off-by: xgui <[email protected]>
Description
This PR adds epoch-aware shuffling to Ray Data's file-based datasources, enabling different file orders across training epochs while maintaining determinism.
Changes
Core functionality:
epoch_idxfield toDataContextto track the current epochFileShuffleConfigcan receivebase_seedto automatically increment seed after each executionFileShuffleConfigstill usesseed, the random seed is still the same for each epoch.FileBasedDatasource.get_read_tasks()to acceptepoch_idxparameter and pass it through the shuffle logicBenefits:
base_seedis provided