-
Notifications
You must be signed in to change notification settings - Fork 166
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
Add shuffling in Nanotron for subsequent epochs when data is repeated #247
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! LGTM 🤗
Minor sugg before merging
src/nanotron/data/nanoset.py
Outdated
|
||
# Shuffle indices in each epoch with different random seeds and concatenate them | ||
r = np.random.RandomState(self.random_seed) | ||
epoch_random_seeds = r.randint(0, 2**32 - 1, num_epochs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just use self.random_seed + num_epoch
for easier reproducibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, makes it a lot simpler and clearer what's going on. I've changed the code to incorporate this in latest commit:
nanotron/src/nanotron/data/nanoset.py
Lines 116 to 123 in f060414
dataset_indices = [] | |
dataset_sample_indices = [] | |
for num_epoch in range(num_epochs): | |
# Shuffle the sample and dataset indices in epoch with a given seed | |
numpy_random_state = np.random.RandomState(self.random_seed + num_epoch) | |
numpy_random_state.shuffle(dataset_index) | |
numpy_random_state = np.random.RandomState(self.random_seed + num_epoch) | |
numpy_random_state.shuffle(dataset_sample_index) |
fe4aa4e
to
f060414
Compare
More details here: huggingface#247 "Nanoset's index builder does not re-shuffle dataset and sample indices within epochs when training secondary, third, etc epochs. It instead concatenates a copy of the same indices for any repeated data. This commit adds unique within-epoch shuffling for each epoch." Squashed commit of the following: commit f73d111 Author: Thomas Bouvier <[email protected]> Date: Sun Mar 23 01:19:15 2025 +0100 docs: document the shuffling process in Nanoset commit f060414 Author: Lauler <[email protected]> Date: Thu Nov 28 09:04:17 2024 +0100 Simplify random seed in epoch data for reproducibility commit eab4770 Author: Lauler <[email protected]> Date: Sun Nov 24 14:29:31 2024 +0100 Add shuffling for subsequent epochs when data is repeated
Nanoset's index builder does not re-shuffle dataset and sample indices within epochs when training secondary, third, etc epochs. It instead concatenates a copy of the same indices for any repeated data. This PR adds unique within-epoch shuffling for each epoch.
See the following issue: #237
I ran the tests in
tests/nanotron
:@TJ-Solergibert