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
fe794c5a
Commit
fe794c5a
authored
Jul 27, 2020
by
Boris Fomitchev
Browse files
Replacing --erf-gelu option with explicit --onnx-safe option
Signed-off-by:
Boris Fomitchev
<
bfomitchev@nvidia.com
>
parent
7917774a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
6 deletions
+4
-6
megatron/arguments.py
megatron/arguments.py
+2
-3
megatron/model/bert_model.py
megatron/model/bert_model.py
+1
-2
megatron/model/language_model.py
megatron/model/language_model.py
+1
-1
No files found.
megatron/arguments.py
View file @
fe794c5a
...
@@ -158,9 +158,8 @@ def _add_network_size_args(parser):
...
@@ -158,9 +158,8 @@ def _add_network_size_args(parser):
help
=
'Use OpenAIs GeLU implementation. This option'
help
=
'Use OpenAIs GeLU implementation. This option'
'should not be used unless for backward compatibility'
'should not be used unless for backward compatibility'
'reasons.'
)
'reasons.'
)
group
.
add_argument
(
'--erf-gelu'
,
action
=
'store_true'
,
group
.
add_argument
(
'--onnx-safe'
,
action
=
'store_true'
,
help
=
'Python GeLU implementation equivalent to one in Torch. This option'
help
=
'Use workarounds for known problems with Torch ONNX exporter'
)
'should only be used to work around Torch bug exporting gelu() to ONNX in FP16'
)
return
parser
return
parser
...
...
megatron/model/bert_model.py
View file @
fe794c5a
...
@@ -95,8 +95,7 @@ class BertLMHead(MegatronModule):
...
@@ -95,8 +95,7 @@ class BertLMHead(MegatronModule):
self
.
gelu
=
torch
.
nn
.
functional
.
gelu
self
.
gelu
=
torch
.
nn
.
functional
.
gelu
if
args
.
openai_gelu
:
if
args
.
openai_gelu
:
self
.
gelu
=
openai_gelu
self
.
gelu
=
openai_gelu
# make it override
elif
args
.
onnx_safe
:
if
args
.
erf_gelu
:
self
.
gelu
=
erf_gelu
self
.
gelu
=
erf_gelu
def
forward
(
self
,
hidden_states
,
word_embeddings_weight
):
def
forward
(
self
,
hidden_states
,
word_embeddings_weight
):
...
...
megatron/model/language_model.py
View file @
fe794c5a
...
@@ -52,7 +52,7 @@ def get_language_model(attention_mask_func, num_tokentypes, add_pooler,
...
@@ -52,7 +52,7 @@ def get_language_model(attention_mask_func, num_tokentypes, add_pooler,
gelu
=
F
.
gelu
gelu
=
F
.
gelu
if
args
.
openai_gelu
:
if
args
.
openai_gelu
:
gelu
=
openai_gelu
gelu
=
openai_gelu
if
args
.
erf_gelu
:
el
if
args
.
onnx_safe
:
gelu
=
erf_gelu
gelu
=
erf_gelu
# Language model.
# Language model.
...
...
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