Add DataLoader module and introduce custom StopTraining exception #1862
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces
data_loader.py
, a new module dedicated to encapsulating and streamlining the logic for loading and batching data for model training. This refactors data handling out oftrain.py
, where it was previously imported by various trainers (e.g., sft_trainer, grpo_trainer, elastic_train). By centralizing this functionality, we significantly reduce the complexity oftrain.py
and enhance overall code readability and maintainability. TheDataLoader
module now serves as a dedicated, modular, and efficient component for preparing training data.Tests
E2E with train.py
Checklist
Before submitting this PR, please make sure (put X in square brackets):