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
5caf95ca
Commit
5caf95ca
authored
May 30, 2020
by
Thor Johnsen
Browse files
Make step global state variable
parent
7741808b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
apex/contrib/optimizers/distributed_fused_lamb.py
apex/contrib/optimizers/distributed_fused_lamb.py
+8
-7
No files found.
apex/contrib/optimizers/distributed_fused_lamb.py
View file @
5caf95ca
...
...
@@ -135,11 +135,6 @@ class DistributedFusedLAMB(torch.optim.Optimizer):
1.0
-
beta1
if
grad_averaging
else
1.0
,
group
[
'eps'
]
))
state
=
self
.
state
[
p
]
if
len
(
state
)
==
0
:
state
[
'step'
]
=
0
if
self
.
_param_state
is
None
:
self
.
_param_state
=
state
p_grads_size
=
p
.
numel
()
def
wrapper
(
param
,
param_i
,
param_grads_size
,
param_offset
):
param_tmp
=
param
.
expand_as
(
param
)
...
...
@@ -463,7 +458,7 @@ class DistributedFusedLAMB(torch.optim.Optimizer):
self
.
_contrib_beta2
,
self
.
_contrib_beta3
,
self
.
_contrib_bias_correction
,
self
.
_param_
state
[
'step'
]
+
1
,
self
.
_param_
group
[
'step'
],
self
.
_contrib_epsilon
,
self
.
_adam_w_mode
,
self
.
_contrib_weight_decay
,
...
...
@@ -547,11 +542,17 @@ class DistributedFusedLAMB(torch.optim.Optimizer):
if
closure
is
not
None
:
loss
=
closure
()
# assume same step across group now to simplify things
# per parameter step can be easily support by making it tensor, or pass list into kernel
if
'step'
in
self
.
_param_group
:
self
.
_param_group
[
'step'
]
+=
1
else
:
self
.
_param_group
[
'step'
]
=
1
self
.
_pipeline_step
()
with
torch
.
cuda
.
stream
(
self
.
_completion_st
):
# Copy self._new_params to model params
for
p
in
self
.
_model_params
:
self
.
state
[
p
][
'step'
]
+=
1
if
self
.
_packed_flat_to_model_params_fp16
is
not
None
:
multi_tensor_applier
(
fused_adam_cuda
.
maybe_cast_mt
,
...
...
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