forked from microsoft/Megatron-DeepSpeed
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge: Resolve merge conflicts pulling in from Microsoft upstream
- Loading branch information
Showing
5 changed files
with
34 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
from megatron import get_args | ||
|
||
import torch | ||
from torch.nn.parameter import Parameter | ||
from torch.nn import init | ||
import intel_extension_for_pytorch as ipex # noqa | ||
|
||
|
||
# Taken from facebookresearch/llama | ||
class RMSNorm(torch.nn.Module): | ||
# def __init__(self, dim: int, eps: float = 1e-6): | ||
def __init__(self, dim: int, eps: float = 1e-6, sequence_parallel: bool = False): | ||
def __init__( | ||
self, dim: int, eps: float = 1e-6, sequence_parallel: bool = False | ||
): | ||
super().__init__() | ||
self.eps = eps | ||
self.weight = Parameter(torch.ones(dim)) | ||
self.weight = Parameter(torch.ones(dim, dtype=get_args().params_dtype)) | ||
self.sequence_parallel = sequence_parallel | ||
setattr(self.weight, "sequence_parallel", self.sequence_parallel) | ||
|
||
def forward(self, x): | ||
output = torch.xpu.IpexRmsNorm(x, self.weight.shape, self.weight, self.eps) | ||
output = torch.xpu.IpexRmsNorm( | ||
x, self.weight.shape, self.weight, self.eps | ||
) | ||
return output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters