Build uploaded using `kernels`.
Browse files- .gitattributes +4 -0
- build/torch28-cxx11-cpu-x86_64-linux/__init__.py +14 -0
- build/{torch29-cxx11-xpu20252-x86_64-linux/rmsnorm → torch28-cxx11-cpu-x86_64-linux}/_ops.py +3 -3
- build/{torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so → torch28-cxx11-cpu-x86_64-linux/_rmsnorm_a7a4369.abi3.so} +2 -2
- build/{torch28-cxx11-xpu20251-x86_64-linux/rmsnorm → torch28-cxx11-cpu-x86_64-linux}/layers.py +0 -0
- build/torch28-cxx11-cpu-x86_64-linux/metadata.json +1 -0
- build/torch28-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py +26 -0
- build/torch28-cxx11-xpu20251-x86_64-linux/__init__.py +14 -0
- build/torch28-cxx11-xpu20251-x86_64-linux/{rmsnorm/_ops.py → _ops.py} +3 -3
- build/{torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so → torch28-cxx11-xpu20251-x86_64-linux/_rmsnorm_a7a4369.abi3.so} +2 -2
- build/{torch29-cxx11-xpu20252-x86_64-linux/rmsnorm → torch28-cxx11-xpu20251-x86_64-linux}/layers.py +0 -0
- build/torch28-cxx11-xpu20251-x86_64-linux/metadata.json +1 -0
- build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/__init__.py +22 -10
- build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/__pycache__/layers.cpython-313.pyc +0 -0
- build/torch29-cxx11-cpu-x86_64-linux/__init__.py +14 -0
- build/torch29-cxx11-cpu-x86_64-linux/_ops.py +9 -0
- build/torch29-cxx11-cpu-x86_64-linux/_rmsnorm_a7a4369.abi3.so +3 -0
- build/torch29-cxx11-cpu-x86_64-linux/layers.py +36 -0
- build/torch29-cxx11-cpu-x86_64-linux/metadata.json +1 -0
- build/torch29-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py +26 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/__init__.py +14 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/_ops.py +9 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_a7a4369.abi3.so +3 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/layers.py +36 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/metadata.json +1 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__init__.py +22 -10
- build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__pycache__/layers.cpython-313.pyc +0 -0
.gitattributes
CHANGED
|
@@ -36,3 +36,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 36 |
build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 37 |
build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 38 |
build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
build/torch27-cxx11-xpu20250-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 37 |
build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 38 |
build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
build/torch28-cxx11-cpu-x86_64-linux/_rmsnorm_a7a4369.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
build/torch28-cxx11-xpu20251-x86_64-linux/_rmsnorm_a7a4369.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
build/torch29-cxx11-cpu-x86_64-linux/_rmsnorm_a7a4369.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
build/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_a7a4369.abi3.so filter=lfs diff=lfs merge=lfs -text
|
build/torch28-cxx11-cpu-x86_64-linux/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/{torch29-cxx11-xpu20252-x86_64-linux/rmsnorm → torch28-cxx11-cpu-x86_64-linux}/_ops.py
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _rmsnorm_a7a4369
|
| 3 |
+
ops = torch.ops._rmsnorm_a7a4369
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rmsnorm_a7a4369::{op_name}"
|
build/{torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so → torch28-cxx11-cpu-x86_64-linux/_rmsnorm_a7a4369.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:55621bcd39646f99f979ef03f823fcb35afceead03961675835a80a2c5b6d134
|
| 3 |
+
size 324616
|
build/{torch28-cxx11-xpu20251-x86_64-linux/rmsnorm → torch28-cxx11-cpu-x86_64-linux}/layers.py
RENAMED
|
File without changes
|
build/torch28-cxx11-cpu-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"python-depends":[]}
|
build/torch28-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/torch28-cxx11-xpu20251-x86_64-linux/{rmsnorm/_ops.py → _ops.py}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _rmsnorm_a7a4369
|
| 3 |
+
ops = torch.ops._rmsnorm_a7a4369
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rmsnorm_a7a4369::{op_name}"
|
build/{torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/_rmsnorm_0d12ee5.abi3.so → torch28-cxx11-xpu20251-x86_64-linux/_rmsnorm_a7a4369.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f265f642541565b741228747e4503426aadfaa9cdb428b1a571fa695fd726812
|
| 3 |
+
size 103861336
|
build/{torch29-cxx11-xpu20252-x86_64-linux/rmsnorm → torch28-cxx11-xpu20251-x86_64-linux}/layers.py
RENAMED
|
File without changes
|
build/torch28-cxx11-xpu20251-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"python-depends":[]}
|
build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/__init__.py
CHANGED
|
@@ -1,14 +1,26 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
| 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 |
|
|
|
|
|
|
| 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/rmsnorm/__pycache__/__init__.cpython-313.pyc
DELETED
|
Binary file (491 Bytes)
|
|
|
build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/__pycache__/_ops.cpython-313.pyc
DELETED
|
Binary file (520 Bytes)
|
|
|
build/torch28-cxx11-xpu20251-x86_64-linux/rmsnorm/__pycache__/layers.cpython-313.pyc
DELETED
|
Binary file (1.68 kB)
|
|
|
build/torch29-cxx11-cpu-x86_64-linux/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/torch29-cxx11-cpu-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rmsnorm_a7a4369
|
| 3 |
+
ops = torch.ops._rmsnorm_a7a4369
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rmsnorm_a7a4369::{op_name}"
|
build/torch29-cxx11-cpu-x86_64-linux/_rmsnorm_a7a4369.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ec310cc2696fcc0ef846f6e940e1eec2ba7a50848b69e59a7834f3ddee5927c
|
| 3 |
+
size 324592
|
build/torch29-cxx11-cpu-x86_64-linux/layers.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/torch29-cxx11-cpu-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"python-depends":[]}
|
build/torch29-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/torch29-cxx11-xpu20252-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rmsnorm_a7a4369
|
| 3 |
+
ops = torch.ops._rmsnorm_a7a4369
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rmsnorm_a7a4369::{op_name}"
|
build/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_a7a4369.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f13902ee157cb167ad294a906252f5a349ee13c8afe0d71b51a895cf6944cbfe
|
| 3 |
+
size 102340240
|
build/torch29-cxx11-xpu20252-x86_64-linux/layers.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/torch29-cxx11-xpu20252-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"python-depends":[]}
|
build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__init__.py
CHANGED
|
@@ -1,14 +1,26 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
| 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 |
|
|
|
|
|
|
| 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/rmsnorm/__pycache__/__init__.cpython-313.pyc
DELETED
|
Binary file (491 Bytes)
|
|
|
build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__pycache__/_ops.cpython-313.pyc
DELETED
|
Binary file (520 Bytes)
|
|
|
build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__pycache__/layers.cpython-313.pyc
DELETED
|
Binary file (1.68 kB)
|
|
|