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
c5be45ee
Commit
c5be45ee
authored
Mar 31, 2022
by
Lawrence McAfee
Browse files
Merge branch 'main' into lmcafee/distrib-opt-nodupe
parents
b42c3052
15f6bb1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
megatron/model/fused_layer_norm.py
megatron/model/fused_layer_norm.py
+12
-1
No files found.
megatron/model/fused_layer_norm.py
View file @
c5be45ee
...
@@ -23,6 +23,8 @@ from torch.nn.parameter import Parameter
...
@@ -23,6 +23,8 @@ from torch.nn.parameter import Parameter
from
torch.nn
import
init
from
torch.nn
import
init
import
importlib
import
importlib
from
megatron.mpu
import
make_viewless_tensor
try
:
try
:
from
apex.contrib.layer_norm.layer_norm
import
FastLayerNormFN
from
apex.contrib.layer_norm.layer_norm
import
FastLayerNormFN
HAVE_PERSIST_LAYER_NORM
=
True
HAVE_PERSIST_LAYER_NORM
=
True
...
@@ -106,6 +108,15 @@ class MixedFusedLayerNorm(torch.nn.Module):
...
@@ -106,6 +108,15 @@ class MixedFusedLayerNorm(torch.nn.Module):
return
FusedLayerNormAffineFunction
.
apply
(
return
FusedLayerNormAffineFunction
.
apply
(
input
,
self
.
weight
,
self
.
bias
,
self
.
normalized_shape
,
self
.
eps
)
input
,
self
.
weight
,
self
.
bias
,
self
.
normalized_shape
,
self
.
eps
)
else
:
else
:
return
FastLayerNormFN
.
apply
(
output
=
FastLayerNormFN
.
apply
(
input
,
self
.
weight
,
self
.
bias
,
self
.
eps
)
input
,
self
.
weight
,
self
.
bias
,
self
.
eps
)
# Apex's fast layer norm function outputs a 'view' tensor (i.e., has
# a populated '_base' field). This will result in schedule.py's
# deallocate_output_tensor() throwing an error, so a viewless tensor is
# created to prevent this.
output
=
make_viewless_tensor
(
inp
=
output
,
requires_grad
=
input
.
requires_grad
,
keep_graph
=
True
)
return
output
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