Kernels:
Trusted publisher
Remove builds incompatible with kernels >= 0.14
Browse files- build/torch210-xpu20253-x86_64-windows/__init__.py +0 -27
- build/torch210-xpu20253-x86_64-windows/_ops.py +0 -9
- build/torch210-xpu20253-x86_64-windows/_rmsnorm_xpu_1e2f028.pyd +0 -3
- build/torch210-xpu20253-x86_64-windows/layers.py +0 -59
- build/torch210-xpu20253-x86_64-windows/metadata.json +0 -8
- build/torch210-xpu20253-x86_64-windows/rmsnorm/__init__.py +0 -26
- build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/__init__.py +0 -14
- build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/__pycache__/layers.cpython-313.pyc +0 -0
- build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/_ops.py +0 -9
- build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so +0 -3
- build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/layers.py +0 -36
- build/torch28-cxx11-cpu-x86_64-linux/__init__.py +0 -27
- build/torch28-cxx11-cpu-x86_64-linux/_ops.py +0 -9
- build/torch28-cxx11-cpu-x86_64-linux/_rmsnorm_235cde1.abi3.so +0 -3
- build/torch28-cxx11-cpu-x86_64-linux/layers.py +0 -59
- build/torch28-cxx11-cpu-x86_64-linux/metadata.json +0 -4
- build/torch28-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py +0 -26
- build/torch28-cxx11-xpu20251-x86_64-linux/__init__.py +0 -27
- build/torch28-cxx11-xpu20251-x86_64-linux/_ops.py +0 -9
- build/torch28-cxx11-xpu20251-x86_64-linux/_rmsnorm_235cde1.abi3.so +0 -3
- build/torch28-cxx11-xpu20251-x86_64-linux/layers.py +0 -59
- build/torch28-cxx11-xpu20251-x86_64-linux/metadata.json +0 -4
- build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/__init__.py +0 -26
- build/torch29-cxx11-cpu-x86_64-linux/__init__.py +0 -27
- build/torch29-cxx11-cpu-x86_64-linux/_ops.py +0 -9
- build/torch29-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_b3d66c6.abi3.so +0 -3
- build/torch29-cxx11-cpu-x86_64-linux/layers.py +0 -59
- build/torch29-cxx11-cpu-x86_64-linux/metadata.json +0 -5
- build/torch29-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py +0 -26
- build/torch29-cxx11-xpu20252-x86_64-linux/__init__.py +0 -27
- build/torch29-cxx11-xpu20252-x86_64-linux/_ops.py +0 -9
- build/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_xpu_cec90b8.abi3.so +0 -3
- build/torch29-cxx11-xpu20252-x86_64-linux/layers.py +0 -59
- build/torch29-cxx11-xpu20252-x86_64-linux/metadata.json +0 -8
- build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__init__.py +0 -26
- build/torch29-xpu20252-x86_64-windows/metadata.json +0 -4
- build/torch29-xpu20252-x86_64-windows/rmsnorm/__init__.py +0 -27
- build/torch29-xpu20252-x86_64-windows/rmsnorm/_ops.py +0 -9
- build/torch29-xpu20252-x86_64-windows/rmsnorm/_rmsnorm_96c9886.pyd +0 -3
- build/torch29-xpu20252-x86_64-windows/rmsnorm/layers.py +0 -59
build/torch210-xpu20253-x86_64-windows/__init__.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
from . import layers
|
| 2 |
-
|
| 3 |
-
from ._ops import ops
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def apply_rms_norm(input, weight, eps):
|
| 7 |
-
# ops.apply_rms_norm returns [output, rstd]
|
| 8 |
-
return ops.apply_rms_norm(
|
| 9 |
-
input,
|
| 10 |
-
weight,
|
| 11 |
-
eps,
|
| 12 |
-
)[0]
|
| 13 |
-
|
| 14 |
-
def apply_rms_norm_backward(grad_output, input, weight, output, rstd, eps, input_requires_grad=True, weight_requires_grad=True):
|
| 15 |
-
return ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
input,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
eps,
|
| 22 |
-
input_requires_grad,
|
| 23 |
-
weight_requires_grad
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
__all__ = ["layers", "apply_rms_norm_forward", "apply_rms_norm_backward"]
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch210-xpu20253-x86_64-windows/_ops.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from . import _rmsnorm_xpu_1e2f028
|
| 3 |
-
ops = torch.ops._rmsnorm_xpu_1e2f028
|
| 4 |
-
|
| 5 |
-
def add_op_namespace_prefix(op_name: str):
|
| 6 |
-
"""
|
| 7 |
-
Prefix op by namespace.
|
| 8 |
-
"""
|
| 9 |
-
return f"_rmsnorm_xpu_1e2f028::{op_name}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch210-xpu20253-x86_64-windows/_rmsnorm_xpu_1e2f028.pyd
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:3406c8ace46216f6b49350810fa2a022ddfda89b1975ede4e556301a136f9d49
|
| 3 |
-
size 2363904
|
|
|
|
|
|
|
|
|
|
|
|
build/torch210-xpu20253-x86_64-windows/layers.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from ._ops import ops
|
| 3 |
-
|
| 4 |
-
class RMSNormFunction(torch.autograd.Function):
|
| 5 |
-
@staticmethod
|
| 6 |
-
def forward(ctx, hidden_states, weight, variance_epsilon):
|
| 7 |
-
ctx.variance_epsilon = variance_epsilon
|
| 8 |
-
output, rstd = ops.apply_rms_norm(hidden_states, weight, variance_epsilon)
|
| 9 |
-
ctx.save_for_backward(hidden_states, weight, output, rstd)
|
| 10 |
-
return output
|
| 11 |
-
|
| 12 |
-
@staticmethod
|
| 13 |
-
def backward(ctx, grad_output):
|
| 14 |
-
hidden_states, weight, output, rstd = ctx.saved_tensors
|
| 15 |
-
grads = ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
hidden_states,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
ctx.variance_epsilon,
|
| 22 |
-
ctx.needs_input_grad[0],
|
| 23 |
-
ctx.needs_input_grad[1]
|
| 24 |
-
)
|
| 25 |
-
return grads[0], grads[1], None
|
| 26 |
-
|
| 27 |
-
class RMSNorm(torch.nn.Module):
|
| 28 |
-
"""
|
| 29 |
-
RMSNorm module that uses the optimized LigerRMSNormFunction.
|
| 30 |
-
|
| 31 |
-
Args:
|
| 32 |
-
hidden_size (int): The size of the hidden dimension.
|
| 33 |
-
eps (float, optional): The epsilon value for numerical stability. Defaults to 1e-6.
|
| 34 |
-
offset (float, optional): Offset value to shift the weight tensor. Defaults to 0.0.
|
| 35 |
-
casting_mode (str, optional): The casting mode to use. Defaults to "llama".
|
| 36 |
-
in_place (bool, optional): Whether to modify dY in-place to store dX during backward. Defaults to True.
|
| 37 |
-
"""
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
weight: torch.Tensor
|
| 41 |
-
variance_epsilon: float
|
| 42 |
-
|
| 43 |
-
def forward(self, hidden_states):
|
| 44 |
-
"""
|
| 45 |
-
Apply RMS normalization to the input tensor.
|
| 46 |
-
|
| 47 |
-
Args:
|
| 48 |
-
hidden_states (torch.Tensor): Input tensor of shape (B, T, H) or (BxT, H)
|
| 49 |
-
|
| 50 |
-
Returns:
|
| 51 |
-
torch.Tensor: Normalized tensor of the same shape as input
|
| 52 |
-
"""
|
| 53 |
-
return RMSNormFunction.apply(
|
| 54 |
-
hidden_states,
|
| 55 |
-
self.weight,
|
| 56 |
-
self.variance_epsilon,
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
__all__ = ["RMSNorm"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch210-xpu20253-x86_64-windows/metadata.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"version": 1,
|
| 3 |
-
"license": "Apache-2.0",
|
| 4 |
-
"python-depends": [],
|
| 5 |
-
"backend": {
|
| 6 |
-
"type": "xpu"
|
| 7 |
-
}
|
| 8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch210-xpu20253-x86_64-windows/rmsnorm/__init__.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
import ctypes
|
| 2 |
-
import importlib.util
|
| 3 |
-
import sys
|
| 4 |
-
from pathlib import Path
|
| 5 |
-
from types import ModuleType
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
def _import_from_path(file_path: Path) -> ModuleType:
|
| 9 |
-
# We cannot use the module name as-is, after adding it to `sys.modules`,
|
| 10 |
-
# it would also be used for other imports. So, we make a module name that
|
| 11 |
-
# depends on the path for it to be unique using the hex-encoded hash of
|
| 12 |
-
# the path.
|
| 13 |
-
path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 14 |
-
module_name = path_hash
|
| 15 |
-
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
| 16 |
-
if spec is None:
|
| 17 |
-
raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
|
| 18 |
-
module = importlib.util.module_from_spec(spec)
|
| 19 |
-
if module is None:
|
| 20 |
-
raise ImportError(f"Cannot load module {module_name} from spec")
|
| 21 |
-
sys.modules[module_name] = module
|
| 22 |
-
spec.loader.exec_module(module) # type: ignore
|
| 23 |
-
return module
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/__init__.py
DELETED
|
@@ -1,14 +0,0 @@
|
|
| 1 |
-
from . import layers
|
| 2 |
-
|
| 3 |
-
from ._ops import ops
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def apply_rms_norm(input, weight, eps):
|
| 7 |
-
return ops.apply_rms_norm(
|
| 8 |
-
input,
|
| 9 |
-
weight,
|
| 10 |
-
eps,
|
| 11 |
-
)
|
| 12 |
-
|
| 13 |
-
__all__ = ["layers", "apply_rms_norm"]
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/__pycache__/__init__.cpython-313.pyc
DELETED
|
Binary file (491 Bytes)
|
|
|
build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/__pycache__/_ops.cpython-313.pyc
DELETED
|
Binary file (520 Bytes)
|
|
|
build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/__pycache__/layers.cpython-313.pyc
DELETED
|
Binary file (1.68 kB)
|
|
|
build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/_ops.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from . import _rmsnorm_0d12ee5
|
| 3 |
-
ops = torch.ops._rmsnorm_0d12ee5
|
| 4 |
-
|
| 5 |
-
def add_op_namespace_prefix(op_name: str):
|
| 6 |
-
"""
|
| 7 |
-
Prefix op by namespace.
|
| 8 |
-
"""
|
| 9 |
-
return f"_rmsnorm_0d12ee5::{op_name}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:79eb24cb07a24a3f829ce1d210bd0cbd79badd0cc236710a84e83c15575ddf04
|
| 3 |
-
size 100963504
|
|
|
|
|
|
|
|
|
|
|
|
build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/layers.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from ._ops import ops
|
| 3 |
-
|
| 4 |
-
class RMSNorm(torch.nn.Module):
|
| 5 |
-
"""
|
| 6 |
-
RMSNorm module that uses the optimized LigerRMSNormFunction.
|
| 7 |
-
|
| 8 |
-
Args:
|
| 9 |
-
hidden_size (int): The size of the hidden dimension.
|
| 10 |
-
eps (float, optional): The epsilon value for numerical stability. Defaults to 1e-6.
|
| 11 |
-
offset (float, optional): Offset value to shift the weight tensor. Defaults to 0.0.
|
| 12 |
-
casting_mode (str, optional): The casting mode to use. Defaults to "llama".
|
| 13 |
-
in_place (bool, optional): Whether to modify dY in-place to store dX during backward. Defaults to True.
|
| 14 |
-
"""
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
weight: torch.Tensor
|
| 18 |
-
variance_epsilon: float
|
| 19 |
-
|
| 20 |
-
def forward(self, hidden_states):
|
| 21 |
-
"""
|
| 22 |
-
Apply RMS normalization to the input tensor.
|
| 23 |
-
|
| 24 |
-
Args:
|
| 25 |
-
hidden_states (torch.Tensor): Input tensor of shape (B, T, H) or (BxT, H)
|
| 26 |
-
|
| 27 |
-
Returns:
|
| 28 |
-
torch.Tensor: Normalized tensor of the same shape as input
|
| 29 |
-
"""
|
| 30 |
-
return ops.apply_rms_norm(
|
| 31 |
-
hidden_states,
|
| 32 |
-
self.weight,
|
| 33 |
-
self.variance_epsilon,
|
| 34 |
-
)
|
| 35 |
-
|
| 36 |
-
__all__ = ["RMSNorm"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-cpu-x86_64-linux/__init__.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
from . import layers
|
| 2 |
-
|
| 3 |
-
from ._ops import ops
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def apply_rms_norm(input, weight, eps):
|
| 7 |
-
# ops.apply_rms_norm returns [output, rstd]
|
| 8 |
-
return ops.apply_rms_norm(
|
| 9 |
-
input,
|
| 10 |
-
weight,
|
| 11 |
-
eps,
|
| 12 |
-
)[0]
|
| 13 |
-
|
| 14 |
-
def apply_rms_norm_backward(grad_output, input, weight, output, rstd, eps, input_requires_grad=True, weight_requires_grad=True):
|
| 15 |
-
return ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
input,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
eps,
|
| 22 |
-
input_requires_grad,
|
| 23 |
-
weight_requires_grad
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
__all__ = ["layers", "apply_rms_norm_forward", "apply_rms_norm_backward"]
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-cpu-x86_64-linux/_ops.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from . import _rmsnorm_235cde1
|
| 3 |
-
ops = torch.ops._rmsnorm_235cde1
|
| 4 |
-
|
| 5 |
-
def add_op_namespace_prefix(op_name: str):
|
| 6 |
-
"""
|
| 7 |
-
Prefix op by namespace.
|
| 8 |
-
"""
|
| 9 |
-
return f"_rmsnorm_235cde1::{op_name}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-cpu-x86_64-linux/_rmsnorm_235cde1.abi3.so
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:16c92de9cefabeeadc60ffff87189a1e66ecb9ea19b343570ac55e9d9c7d98fe
|
| 3 |
-
size 156648
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-cpu-x86_64-linux/layers.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from ._ops import ops
|
| 3 |
-
|
| 4 |
-
class RMSNormFunction(torch.autograd.Function):
|
| 5 |
-
@staticmethod
|
| 6 |
-
def forward(ctx, hidden_states, weight, variance_epsilon):
|
| 7 |
-
ctx.variance_epsilon = variance_epsilon
|
| 8 |
-
output, rstd = ops.apply_rms_norm(hidden_states, weight, variance_epsilon)
|
| 9 |
-
ctx.save_for_backward(hidden_states, weight, output, rstd)
|
| 10 |
-
return output
|
| 11 |
-
|
| 12 |
-
@staticmethod
|
| 13 |
-
def backward(ctx, grad_output):
|
| 14 |
-
hidden_states, weight, output, rstd = ctx.saved_tensors
|
| 15 |
-
grads = ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
hidden_states,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
ctx.variance_epsilon,
|
| 22 |
-
ctx.needs_input_grad[0],
|
| 23 |
-
ctx.needs_input_grad[1]
|
| 24 |
-
)
|
| 25 |
-
return grads[0], grads[1], None
|
| 26 |
-
|
| 27 |
-
class RMSNorm(torch.nn.Module):
|
| 28 |
-
"""
|
| 29 |
-
RMSNorm module that uses the optimized LigerRMSNormFunction.
|
| 30 |
-
|
| 31 |
-
Args:
|
| 32 |
-
hidden_size (int): The size of the hidden dimension.
|
| 33 |
-
eps (float, optional): The epsilon value for numerical stability. Defaults to 1e-6.
|
| 34 |
-
offset (float, optional): Offset value to shift the weight tensor. Defaults to 0.0.
|
| 35 |
-
casting_mode (str, optional): The casting mode to use. Defaults to "llama".
|
| 36 |
-
in_place (bool, optional): Whether to modify dY in-place to store dX during backward. Defaults to True.
|
| 37 |
-
"""
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
weight: torch.Tensor
|
| 41 |
-
variance_epsilon: float
|
| 42 |
-
|
| 43 |
-
def forward(self, hidden_states):
|
| 44 |
-
"""
|
| 45 |
-
Apply RMS normalization to the input tensor.
|
| 46 |
-
|
| 47 |
-
Args:
|
| 48 |
-
hidden_states (torch.Tensor): Input tensor of shape (B, T, H) or (BxT, H)
|
| 49 |
-
|
| 50 |
-
Returns:
|
| 51 |
-
torch.Tensor: Normalized tensor of the same shape as input
|
| 52 |
-
"""
|
| 53 |
-
return RMSNormFunction.apply(
|
| 54 |
-
hidden_states,
|
| 55 |
-
self.weight,
|
| 56 |
-
self.variance_epsilon,
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
__all__ = ["RMSNorm"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-cpu-x86_64-linux/metadata.json
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"version": 1,
|
| 3 |
-
"python-depends": []
|
| 4 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
import ctypes
|
| 2 |
-
import sys
|
| 3 |
-
|
| 4 |
-
import importlib
|
| 5 |
-
from pathlib import Path
|
| 6 |
-
from types import ModuleType
|
| 7 |
-
|
| 8 |
-
def _import_from_path(file_path: Path) -> ModuleType:
|
| 9 |
-
# We cannot use the module name as-is, after adding it to `sys.modules`,
|
| 10 |
-
# it would also be used for other imports. So, we make a module name that
|
| 11 |
-
# depends on the path for it to be unique using the hex-encoded hash of
|
| 12 |
-
# the path.
|
| 13 |
-
path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 14 |
-
module_name = path_hash
|
| 15 |
-
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
| 16 |
-
if spec is None:
|
| 17 |
-
raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
|
| 18 |
-
module = importlib.util.module_from_spec(spec)
|
| 19 |
-
if module is None:
|
| 20 |
-
raise ImportError(f"Cannot load module {module_name} from spec")
|
| 21 |
-
sys.modules[module_name] = module
|
| 22 |
-
spec.loader.exec_module(module) # type: ignore
|
| 23 |
-
return module
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-xpu20251-x86_64-linux/__init__.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
from . import layers
|
| 2 |
-
|
| 3 |
-
from ._ops import ops
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def apply_rms_norm(input, weight, eps):
|
| 7 |
-
# ops.apply_rms_norm returns [output, rstd]
|
| 8 |
-
return ops.apply_rms_norm(
|
| 9 |
-
input,
|
| 10 |
-
weight,
|
| 11 |
-
eps,
|
| 12 |
-
)[0]
|
| 13 |
-
|
| 14 |
-
def apply_rms_norm_backward(grad_output, input, weight, output, rstd, eps, input_requires_grad=True, weight_requires_grad=True):
|
| 15 |
-
return ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
input,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
eps,
|
| 22 |
-
input_requires_grad,
|
| 23 |
-
weight_requires_grad
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
__all__ = ["layers", "apply_rms_norm_forward", "apply_rms_norm_backward"]
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-xpu20251-x86_64-linux/_ops.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from . import _rmsnorm_235cde1
|
| 3 |
-
ops = torch.ops._rmsnorm_235cde1
|
| 4 |
-
|
| 5 |
-
def add_op_namespace_prefix(op_name: str):
|
| 6 |
-
"""
|
| 7 |
-
Prefix op by namespace.
|
| 8 |
-
"""
|
| 9 |
-
return f"_rmsnorm_235cde1::{op_name}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-xpu20251-x86_64-linux/_rmsnorm_235cde1.abi3.so
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:77c4b43d63dc74b210633da81630023a6d6e359a7a1115bff55da9f4436053d9
|
| 3 |
-
size 103700632
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-xpu20251-x86_64-linux/layers.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from ._ops import ops
|
| 3 |
-
|
| 4 |
-
class RMSNormFunction(torch.autograd.Function):
|
| 5 |
-
@staticmethod
|
| 6 |
-
def forward(ctx, hidden_states, weight, variance_epsilon):
|
| 7 |
-
ctx.variance_epsilon = variance_epsilon
|
| 8 |
-
output, rstd = ops.apply_rms_norm(hidden_states, weight, variance_epsilon)
|
| 9 |
-
ctx.save_for_backward(hidden_states, weight, output, rstd)
|
| 10 |
-
return output
|
| 11 |
-
|
| 12 |
-
@staticmethod
|
| 13 |
-
def backward(ctx, grad_output):
|
| 14 |
-
hidden_states, weight, output, rstd = ctx.saved_tensors
|
| 15 |
-
grads = ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
hidden_states,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
ctx.variance_epsilon,
|
| 22 |
-
ctx.needs_input_grad[0],
|
| 23 |
-
ctx.needs_input_grad[1]
|
| 24 |
-
)
|
| 25 |
-
return grads[0], grads[1], None
|
| 26 |
-
|
| 27 |
-
class RMSNorm(torch.nn.Module):
|
| 28 |
-
"""
|
| 29 |
-
RMSNorm module that uses the optimized LigerRMSNormFunction.
|
| 30 |
-
|
| 31 |
-
Args:
|
| 32 |
-
hidden_size (int): The size of the hidden dimension.
|
| 33 |
-
eps (float, optional): The epsilon value for numerical stability. Defaults to 1e-6.
|
| 34 |
-
offset (float, optional): Offset value to shift the weight tensor. Defaults to 0.0.
|
| 35 |
-
casting_mode (str, optional): The casting mode to use. Defaults to "llama".
|
| 36 |
-
in_place (bool, optional): Whether to modify dY in-place to store dX during backward. Defaults to True.
|
| 37 |
-
"""
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
weight: torch.Tensor
|
| 41 |
-
variance_epsilon: float
|
| 42 |
-
|
| 43 |
-
def forward(self, hidden_states):
|
| 44 |
-
"""
|
| 45 |
-
Apply RMS normalization to the input tensor.
|
| 46 |
-
|
| 47 |
-
Args:
|
| 48 |
-
hidden_states (torch.Tensor): Input tensor of shape (B, T, H) or (BxT, H)
|
| 49 |
-
|
| 50 |
-
Returns:
|
| 51 |
-
torch.Tensor: Normalized tensor of the same shape as input
|
| 52 |
-
"""
|
| 53 |
-
return RMSNormFunction.apply(
|
| 54 |
-
hidden_states,
|
| 55 |
-
self.weight,
|
| 56 |
-
self.variance_epsilon,
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
__all__ = ["RMSNorm"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-xpu20251-x86_64-linux/metadata.json
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"version": 1,
|
| 3 |
-
"python-depends": []
|
| 4 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/__init__.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
import ctypes
|
| 2 |
-
import sys
|
| 3 |
-
|
| 4 |
-
import importlib
|
| 5 |
-
from pathlib import Path
|
| 6 |
-
from types import ModuleType
|
| 7 |
-
|
| 8 |
-
def _import_from_path(file_path: Path) -> ModuleType:
|
| 9 |
-
# We cannot use the module name as-is, after adding it to `sys.modules`,
|
| 10 |
-
# it would also be used for other imports. So, we make a module name that
|
| 11 |
-
# depends on the path for it to be unique using the hex-encoded hash of
|
| 12 |
-
# the path.
|
| 13 |
-
path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 14 |
-
module_name = path_hash
|
| 15 |
-
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
| 16 |
-
if spec is None:
|
| 17 |
-
raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
|
| 18 |
-
module = importlib.util.module_from_spec(spec)
|
| 19 |
-
if module is None:
|
| 20 |
-
raise ImportError(f"Cannot load module {module_name} from spec")
|
| 21 |
-
sys.modules[module_name] = module
|
| 22 |
-
spec.loader.exec_module(module) # type: ignore
|
| 23 |
-
return module
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-cpu-x86_64-linux/__init__.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
from . import layers
|
| 2 |
-
|
| 3 |
-
from ._ops import ops
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def apply_rms_norm(input, weight, eps):
|
| 7 |
-
# ops.apply_rms_norm returns [output, rstd]
|
| 8 |
-
return ops.apply_rms_norm(
|
| 9 |
-
input,
|
| 10 |
-
weight,
|
| 11 |
-
eps,
|
| 12 |
-
)[0]
|
| 13 |
-
|
| 14 |
-
def apply_rms_norm_backward(grad_output, input, weight, output, rstd, eps, input_requires_grad=True, weight_requires_grad=True):
|
| 15 |
-
return ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
input,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
eps,
|
| 22 |
-
input_requires_grad,
|
| 23 |
-
weight_requires_grad
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
__all__ = ["layers", "apply_rms_norm_forward", "apply_rms_norm_backward"]
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-cpu-x86_64-linux/_ops.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from . import _rmsnorm_cpu_b3d66c6
|
| 3 |
-
ops = torch.ops._rmsnorm_cpu_b3d66c6
|
| 4 |
-
|
| 5 |
-
def add_op_namespace_prefix(op_name: str):
|
| 6 |
-
"""
|
| 7 |
-
Prefix op by namespace.
|
| 8 |
-
"""
|
| 9 |
-
return f"_rmsnorm_cpu_b3d66c6::{op_name}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_b3d66c6.abi3.so
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:cf3b3a68445d97357b4c08dd07ed0d197d18c9e7449ad62172dd55dfc49e7d08
|
| 3 |
-
size 1999776
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-cpu-x86_64-linux/layers.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from ._ops import ops
|
| 3 |
-
|
| 4 |
-
class RMSNormFunction(torch.autograd.Function):
|
| 5 |
-
@staticmethod
|
| 6 |
-
def forward(ctx, hidden_states, weight, variance_epsilon):
|
| 7 |
-
ctx.variance_epsilon = variance_epsilon
|
| 8 |
-
output, rstd = ops.apply_rms_norm(hidden_states, weight, variance_epsilon)
|
| 9 |
-
ctx.save_for_backward(hidden_states, weight, output, rstd)
|
| 10 |
-
return output
|
| 11 |
-
|
| 12 |
-
@staticmethod
|
| 13 |
-
def backward(ctx, grad_output):
|
| 14 |
-
hidden_states, weight, output, rstd = ctx.saved_tensors
|
| 15 |
-
grads = ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
hidden_states,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
ctx.variance_epsilon,
|
| 22 |
-
ctx.needs_input_grad[0],
|
| 23 |
-
ctx.needs_input_grad[1]
|
| 24 |
-
)
|
| 25 |
-
return grads[0], grads[1], None
|
| 26 |
-
|
| 27 |
-
class RMSNorm(torch.nn.Module):
|
| 28 |
-
"""
|
| 29 |
-
RMSNorm module that uses the optimized LigerRMSNormFunction.
|
| 30 |
-
|
| 31 |
-
Args:
|
| 32 |
-
hidden_size (int): The size of the hidden dimension.
|
| 33 |
-
eps (float, optional): The epsilon value for numerical stability. Defaults to 1e-6.
|
| 34 |
-
offset (float, optional): Offset value to shift the weight tensor. Defaults to 0.0.
|
| 35 |
-
casting_mode (str, optional): The casting mode to use. Defaults to "llama".
|
| 36 |
-
in_place (bool, optional): Whether to modify dY in-place to store dX during backward. Defaults to True.
|
| 37 |
-
"""
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
weight: torch.Tensor
|
| 41 |
-
variance_epsilon: float
|
| 42 |
-
|
| 43 |
-
def forward(self, hidden_states):
|
| 44 |
-
"""
|
| 45 |
-
Apply RMS normalization to the input tensor.
|
| 46 |
-
|
| 47 |
-
Args:
|
| 48 |
-
hidden_states (torch.Tensor): Input tensor of shape (B, T, H) or (BxT, H)
|
| 49 |
-
|
| 50 |
-
Returns:
|
| 51 |
-
torch.Tensor: Normalized tensor of the same shape as input
|
| 52 |
-
"""
|
| 53 |
-
return RMSNormFunction.apply(
|
| 54 |
-
hidden_states,
|
| 55 |
-
self.weight,
|
| 56 |
-
self.variance_epsilon,
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
__all__ = ["RMSNorm"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-cpu-x86_64-linux/metadata.json
DELETED
|
@@ -1,5 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"version": 1,
|
| 3 |
-
"license": "Apache-2.0",
|
| 4 |
-
"python-depends": []
|
| 5 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
import ctypes
|
| 2 |
-
import sys
|
| 3 |
-
|
| 4 |
-
import importlib
|
| 5 |
-
from pathlib import Path
|
| 6 |
-
from types import ModuleType
|
| 7 |
-
|
| 8 |
-
def _import_from_path(file_path: Path) -> ModuleType:
|
| 9 |
-
# We cannot use the module name as-is, after adding it to `sys.modules`,
|
| 10 |
-
# it would also be used for other imports. So, we make a module name that
|
| 11 |
-
# depends on the path for it to be unique using the hex-encoded hash of
|
| 12 |
-
# the path.
|
| 13 |
-
path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 14 |
-
module_name = path_hash
|
| 15 |
-
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
| 16 |
-
if spec is None:
|
| 17 |
-
raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
|
| 18 |
-
module = importlib.util.module_from_spec(spec)
|
| 19 |
-
if module is None:
|
| 20 |
-
raise ImportError(f"Cannot load module {module_name} from spec")
|
| 21 |
-
sys.modules[module_name] = module
|
| 22 |
-
spec.loader.exec_module(module) # type: ignore
|
| 23 |
-
return module
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-xpu20252-x86_64-linux/__init__.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
from . import layers
|
| 2 |
-
|
| 3 |
-
from ._ops import ops
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def apply_rms_norm(input, weight, eps):
|
| 7 |
-
# ops.apply_rms_norm returns [output, rstd]
|
| 8 |
-
return ops.apply_rms_norm(
|
| 9 |
-
input,
|
| 10 |
-
weight,
|
| 11 |
-
eps,
|
| 12 |
-
)[0]
|
| 13 |
-
|
| 14 |
-
def apply_rms_norm_backward(grad_output, input, weight, output, rstd, eps, input_requires_grad=True, weight_requires_grad=True):
|
| 15 |
-
return ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
input,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
eps,
|
| 22 |
-
input_requires_grad,
|
| 23 |
-
weight_requires_grad
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
__all__ = ["layers", "apply_rms_norm_forward", "apply_rms_norm_backward"]
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-xpu20252-x86_64-linux/_ops.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from . import _rmsnorm_xpu_cec90b8
|
| 3 |
-
ops = torch.ops._rmsnorm_xpu_cec90b8
|
| 4 |
-
|
| 5 |
-
def add_op_namespace_prefix(op_name: str):
|
| 6 |
-
"""
|
| 7 |
-
Prefix op by namespace.
|
| 8 |
-
"""
|
| 9 |
-
return f"_rmsnorm_xpu_cec90b8::{op_name}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_xpu_cec90b8.abi3.so
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:b5fb0e95d3b6be17bd03833abcf461bb10d9c62fbf1336d9226dce0950dce1fa
|
| 3 |
-
size 102179544
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-xpu20252-x86_64-linux/layers.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from ._ops import ops
|
| 3 |
-
|
| 4 |
-
class RMSNormFunction(torch.autograd.Function):
|
| 5 |
-
@staticmethod
|
| 6 |
-
def forward(ctx, hidden_states, weight, variance_epsilon):
|
| 7 |
-
ctx.variance_epsilon = variance_epsilon
|
| 8 |
-
output, rstd = ops.apply_rms_norm(hidden_states, weight, variance_epsilon)
|
| 9 |
-
ctx.save_for_backward(hidden_states, weight, output, rstd)
|
| 10 |
-
return output
|
| 11 |
-
|
| 12 |
-
@staticmethod
|
| 13 |
-
def backward(ctx, grad_output):
|
| 14 |
-
hidden_states, weight, output, rstd = ctx.saved_tensors
|
| 15 |
-
grads = ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
hidden_states,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
ctx.variance_epsilon,
|
| 22 |
-
ctx.needs_input_grad[0],
|
| 23 |
-
ctx.needs_input_grad[1]
|
| 24 |
-
)
|
| 25 |
-
return grads[0], grads[1], None
|
| 26 |
-
|
| 27 |
-
class RMSNorm(torch.nn.Module):
|
| 28 |
-
"""
|
| 29 |
-
RMSNorm module that uses the optimized LigerRMSNormFunction.
|
| 30 |
-
|
| 31 |
-
Args:
|
| 32 |
-
hidden_size (int): The size of the hidden dimension.
|
| 33 |
-
eps (float, optional): The epsilon value for numerical stability. Defaults to 1e-6.
|
| 34 |
-
offset (float, optional): Offset value to shift the weight tensor. Defaults to 0.0.
|
| 35 |
-
casting_mode (str, optional): The casting mode to use. Defaults to "llama".
|
| 36 |
-
in_place (bool, optional): Whether to modify dY in-place to store dX during backward. Defaults to True.
|
| 37 |
-
"""
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
weight: torch.Tensor
|
| 41 |
-
variance_epsilon: float
|
| 42 |
-
|
| 43 |
-
def forward(self, hidden_states):
|
| 44 |
-
"""
|
| 45 |
-
Apply RMS normalization to the input tensor.
|
| 46 |
-
|
| 47 |
-
Args:
|
| 48 |
-
hidden_states (torch.Tensor): Input tensor of shape (B, T, H) or (BxT, H)
|
| 49 |
-
|
| 50 |
-
Returns:
|
| 51 |
-
torch.Tensor: Normalized tensor of the same shape as input
|
| 52 |
-
"""
|
| 53 |
-
return RMSNormFunction.apply(
|
| 54 |
-
hidden_states,
|
| 55 |
-
self.weight,
|
| 56 |
-
self.variance_epsilon,
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
__all__ = ["RMSNorm"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-xpu20252-x86_64-linux/metadata.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"version": 1,
|
| 3 |
-
"license": "Apache-2.0",
|
| 4 |
-
"python-depends": [],
|
| 5 |
-
"backend": {
|
| 6 |
-
"type": "xpu"
|
| 7 |
-
}
|
| 8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__init__.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
import ctypes
|
| 2 |
-
import importlib.util
|
| 3 |
-
import sys
|
| 4 |
-
from pathlib import Path
|
| 5 |
-
from types import ModuleType
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
def _import_from_path(file_path: Path) -> ModuleType:
|
| 9 |
-
# We cannot use the module name as-is, after adding it to `sys.modules`,
|
| 10 |
-
# it would also be used for other imports. So, we make a module name that
|
| 11 |
-
# depends on the path for it to be unique using the hex-encoded hash of
|
| 12 |
-
# the path.
|
| 13 |
-
path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 14 |
-
module_name = path_hash
|
| 15 |
-
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
| 16 |
-
if spec is None:
|
| 17 |
-
raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
|
| 18 |
-
module = importlib.util.module_from_spec(spec)
|
| 19 |
-
if module is None:
|
| 20 |
-
raise ImportError(f"Cannot load module {module_name} from spec")
|
| 21 |
-
sys.modules[module_name] = module
|
| 22 |
-
spec.loader.exec_module(module) # type: ignore
|
| 23 |
-
return module
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-xpu20252-x86_64-windows/metadata.json
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"version": 1,
|
| 3 |
-
"python-depends": []
|
| 4 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-xpu20252-x86_64-windows/rmsnorm/__init__.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
from . import layers
|
| 2 |
-
|
| 3 |
-
from ._ops import ops
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def apply_rms_norm(input, weight, eps):
|
| 7 |
-
# ops.apply_rms_norm returns [output, rstd]
|
| 8 |
-
return ops.apply_rms_norm(
|
| 9 |
-
input,
|
| 10 |
-
weight,
|
| 11 |
-
eps,
|
| 12 |
-
)[0]
|
| 13 |
-
|
| 14 |
-
def apply_rms_norm_backward(grad_output, input, weight, output, rstd, eps, input_requires_grad=True, weight_requires_grad=True):
|
| 15 |
-
return ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
input,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
eps,
|
| 22 |
-
input_requires_grad,
|
| 23 |
-
weight_requires_grad
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
__all__ = ["layers", "apply_rms_norm_forward", "apply_rms_norm_backward"]
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-xpu20252-x86_64-windows/rmsnorm/_ops.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from . import _rmsnorm_96c9886
|
| 3 |
-
ops = torch.ops._rmsnorm_96c9886
|
| 4 |
-
|
| 5 |
-
def add_op_namespace_prefix(op_name: str):
|
| 6 |
-
"""
|
| 7 |
-
Prefix op by namespace.
|
| 8 |
-
"""
|
| 9 |
-
return f"_rmsnorm_96c9886::{op_name}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-xpu20252-x86_64-windows/rmsnorm/_rmsnorm_96c9886.pyd
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:c0cfb67260dcf293c71463a698f1531e9d86fb497f9dcf86c296d612ffa4c142
|
| 3 |
-
size 2379264
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-xpu20252-x86_64-windows/rmsnorm/layers.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from ._ops import ops
|
| 3 |
-
|
| 4 |
-
class RMSNormFunction(torch.autograd.Function):
|
| 5 |
-
@staticmethod
|
| 6 |
-
def forward(ctx, hidden_states, weight, variance_epsilon):
|
| 7 |
-
ctx.variance_epsilon = variance_epsilon
|
| 8 |
-
output, rstd = ops.apply_rms_norm(hidden_states, weight, variance_epsilon)
|
| 9 |
-
ctx.save_for_backward(hidden_states, weight, output, rstd)
|
| 10 |
-
return output
|
| 11 |
-
|
| 12 |
-
@staticmethod
|
| 13 |
-
def backward(ctx, grad_output):
|
| 14 |
-
hidden_states, weight, output, rstd = ctx.saved_tensors
|
| 15 |
-
grads = ops.apply_rms_norm_backward(
|
| 16 |
-
grad_output,
|
| 17 |
-
hidden_states,
|
| 18 |
-
weight,
|
| 19 |
-
output,
|
| 20 |
-
rstd,
|
| 21 |
-
ctx.variance_epsilon,
|
| 22 |
-
ctx.needs_input_grad[0],
|
| 23 |
-
ctx.needs_input_grad[1]
|
| 24 |
-
)
|
| 25 |
-
return grads[0], grads[1], None
|
| 26 |
-
|
| 27 |
-
class RMSNorm(torch.nn.Module):
|
| 28 |
-
"""
|
| 29 |
-
RMSNorm module that uses the optimized LigerRMSNormFunction.
|
| 30 |
-
|
| 31 |
-
Args:
|
| 32 |
-
hidden_size (int): The size of the hidden dimension.
|
| 33 |
-
eps (float, optional): The epsilon value for numerical stability. Defaults to 1e-6.
|
| 34 |
-
offset (float, optional): Offset value to shift the weight tensor. Defaults to 0.0.
|
| 35 |
-
casting_mode (str, optional): The casting mode to use. Defaults to "llama".
|
| 36 |
-
in_place (bool, optional): Whether to modify dY in-place to store dX during backward. Defaults to True.
|
| 37 |
-
"""
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
weight: torch.Tensor
|
| 41 |
-
variance_epsilon: float
|
| 42 |
-
|
| 43 |
-
def forward(self, hidden_states):
|
| 44 |
-
"""
|
| 45 |
-
Apply RMS normalization to the input tensor.
|
| 46 |
-
|
| 47 |
-
Args:
|
| 48 |
-
hidden_states (torch.Tensor): Input tensor of shape (B, T, H) or (BxT, H)
|
| 49 |
-
|
| 50 |
-
Returns:
|
| 51 |
-
torch.Tensor: Normalized tensor of the same shape as input
|
| 52 |
-
"""
|
| 53 |
-
return RMSNormFunction.apply(
|
| 54 |
-
hidden_states,
|
| 55 |
-
self.weight,
|
| 56 |
-
self.variance_epsilon,
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
__all__ = ["RMSNorm"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|