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
Megatron-LM
Commits
f597f02e
Commit
f597f02e
authored
Aug 11, 2021
by
Lawrence McAfee
Browse files
added asserts/checks for local ddp and params_have_main_grad
parent
21a11ca0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
megatron/arguments.py
megatron/arguments.py
+5
-0
megatron/optimizer/optimizer.py
megatron/optimizer/optimizer.py
+5
-1
No files found.
megatron/arguments.py
View file @
f597f02e
...
...
@@ -154,6 +154,11 @@ def parse_args(extra_args_provider=None, defaults={},
assert
args
.
DDP_impl
==
'local'
args
.
use_contiguous_buffers_in_ddp
=
True
# If we use a contiguous buffer to hold main grads, we need to have
# local DDP.
if
args
.
use_contiguous_buffers_in_ddp
:
assert
args
.
DDP_impl
==
'local'
if
args
.
dataloader_type
is
None
:
args
.
dataloader_type
=
'single'
...
...
megatron/optimizer/optimizer.py
View file @
f597f02e
...
...
@@ -80,6 +80,9 @@ class MegatronOptimizer(ABC):
self
.
params_have_main_grad
=
params_have_main_grad
self
.
use_contiguous_buffers_in_ddp
=
use_contiguous_buffers_in_ddp
if
self
.
use_contiguous_buffers_in_ddp
:
assert
self
.
params_have_main_grad
,
\
"use of contiguous buffer requires that params have main grad"
def
get_parameters
(
self
):
params
=
[]
...
...
@@ -319,7 +322,8 @@ class Float16OptimizerWithFloat16Params(MegatronOptimizer):
# (If using contiguous buffers, main_grad's memory should
# persist and therefore should not be deallocated.)
model_param
.
grad
=
None
if
not
self
.
use_contiguous_buffers_in_ddp
:
if
self
.
params_have_main_grad
and
\
not
self
.
use_contiguous_buffers_in_ddp
:
model_param
.
main_grad
=
None
# For fp32 grads, we need to reset the grads to main grad.
...
...
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