Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
e1da89cc
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "0b62bbb52eab853e20ee85a2a855518f2bc2cbc7"
Unverified
Commit
e1da89cc
authored
Mar 17, 2022
by
Sylvain Gugger
Committed by
GitHub
Mar 17, 2022
Browse files
Fix reproducibility in Training for PyTorch 1.11 (#16209)
parent
e5101c2e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
src/transformers/trainer.py
src/transformers/trainer.py
+12
-3
No files found.
src/transformers/trainer.py
View file @
e1da89cc
...
...
@@ -1354,9 +1354,18 @@ class Trainer:
# Skip the first epochs_trained epochs to get the random state of the dataloader at the right point.
if
not
args
.
ignore_data_skip
:
for
epoch
in
range
(
epochs_trained
):
is_random_sampler
=
hasattr
(
train_dataloader
,
"sampler"
)
and
isinstance
(
train_dataloader
.
sampler
,
RandomSampler
)
if
version
.
parse
(
torch
.
__version__
)
<
version
.
parse
(
"1.11"
)
or
not
is_random_sampler
:
# We just need to begin an iteration to create the randomization of the sampler.
# That was before PyTorch 1.11 however...
for
_
in
train_dataloader
:
break
else
:
# Otherwise we need to call the whooooole sampler cause there is some random operation added
# AT THE VERY END!
_
=
list
(
train_dataloader
.
sampler
)
for
epoch
in
range
(
epochs_trained
,
num_train_epochs
):
if
isinstance
(
train_dataloader
,
DataLoader
)
and
isinstance
(
train_dataloader
.
sampler
,
DistributedSampler
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment