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
OpenDAS
apex
Commits
7ba6a038
"vscode:/vscode.git/clone" did not exist on "ad3c6d0d72747a6b08682ad6427b91f245b174d6"
Commit
7ba6a038
authored
Apr 10, 2020
by
Thor Johnsen
Browse files
Add option to skip overflow check in step() method
parent
c7b34549
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
apex/contrib/optimizers/distributed_fused_adam.py
apex/contrib/optimizers/distributed_fused_adam.py
+7
-3
No files found.
apex/contrib/optimizers/distributed_fused_adam.py
View file @
7ba6a038
...
@@ -538,7 +538,7 @@ class DistributedFusedAdam(torch.optim.Optimizer):
...
@@ -538,7 +538,7 @@ class DistributedFusedAdam(torch.optim.Optimizer):
for
block_id
in
range
(
self
.
_num_blocks
):
for
block_id
in
range
(
self
.
_num_blocks
):
self
.
_partial_step_single_shard
(
block_id
,
undo
=
True
)
self
.
_partial_step_single_shard
(
block_id
,
undo
=
True
)
def
step
(
self
,
closure
=
None
):
def
step
(
self
,
closure
=
None
,
skip_overflow_check
=
False
):
loss
=
None
loss
=
None
if
closure
is
not
None
:
if
closure
is
not
None
:
loss
=
closure
()
loss
=
closure
()
...
@@ -560,8 +560,12 @@ class DistributedFusedAdam(torch.optim.Optimizer):
...
@@ -560,8 +560,12 @@ class DistributedFusedAdam(torch.optim.Optimizer):
# Check for overflow
# Check for overflow
# Store state for loss scaler calculation
# Store state for loss scaler calculation
self
.
strided_check_finite
(
self
.
_new_params
,
stride
=
self
.
_shard_size
,
start
=
0
,
end
=
self
.
_net_total_param_size
)
if
skip_overflow_check
:
if
self
.
peek_overflow
:
has_overflow
=
False
else
:
self
.
strided_check_finite
(
self
.
_new_params
,
stride
=
self
.
_shard_size
,
start
=
0
,
end
=
self
.
_net_total_param_size
)
has_overflow
=
self
.
peek_overflow
if
has_overflow
:
print
(
"Reverting step"
)
print
(
"Reverting step"
)
self
.
revert_step
()
self
.
revert_step
()
else
:
else
:
...
...
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