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
767e6e92
Commit
767e6e92
authored
Oct 28, 2020
by
Deepak Narayanan
Browse files
Simplify logic in megatron/fp16/fp16.py
parent
aa9cae27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
9 deletions
+2
-9
megatron/fp16/fp16.py
megatron/fp16/fp16.py
+2
-9
No files found.
megatron/fp16/fp16.py
View file @
767e6e92
...
@@ -72,17 +72,10 @@ class FP16_Module(MegatronModule):
...
@@ -72,17 +72,10 @@ class FP16_Module(MegatronModule):
self
.
add_module
(
'module'
,
module
.
half
())
self
.
add_module
(
'module'
,
module
.
half
())
def
forward
(
self
,
*
inputs
,
**
kwargs
):
def
forward
(
self
,
*
inputs
,
**
kwargs
):
convert_inputs
=
True
if
mpu
.
is_pipeline_first_stage
():
convert_outputs
=
True
if
mpu
.
get_pipeline_model_parallel_world_size
()
>
1
:
if
not
mpu
.
is_pipeline_first_stage
():
convert_inputs
=
False
if
not
mpu
.
is_pipeline_last_stage
():
convert_outputs
=
False
if
convert_inputs
:
inputs
=
fp32_to_fp16
(
inputs
)
inputs
=
fp32_to_fp16
(
inputs
)
outputs
=
self
.
module
(
*
inputs
,
**
kwargs
)
outputs
=
self
.
module
(
*
inputs
,
**
kwargs
)
if
convert_outputs
:
if
mpu
.
is_pipeline_last_stage
()
:
outputs
=
fp16_to_fp32
(
outputs
)
outputs
=
fp16_to_fp32
(
outputs
)
return
outputs
return
outputs
...
...
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