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
1815d186
Unverified
Commit
1815d186
authored
Jun 21, 2023
by
Meghan Cowan
Committed by
GitHub
Jun 21, 2023
Browse files
[Trainer] Fix optimizer step on PyTorch TPU (#24389)
* update optimizer step for tpu * add comment
parent
4c6e4295
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
src/transformers/trainer.py
src/transformers/trainer.py
+2
-1
No files found.
src/transformers/trainer.py
View file @
1815d186
...
...
@@ -1859,7 +1859,8 @@ class Trainer:
self
.
scaler
.
step
(
self
.
optimizer
)
self
.
scaler
.
update
()
else
:
xm
.
optimizer_step
(
self
.
optimizer
)
# tpu-comment: accelerate wrapped optimizers call xm.optimizer_step
self
.
optimizer
.
step
()
elif
self
.
do_grad_scaling
:
scale_before
=
self
.
scaler
.
get_scale
()
self
.
scaler
.
step
(
self
.
optimizer
)
...
...
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